Lomiri
Loading...
Searching...
No Matches
lomiri Namespace Reference

Namespaces

namespace  application_lifecycle
 
namespace  sensors
 
namespace  shell
 

Classes

class  LomiriException
 

Functions

 running_installed_tests ()
 
 get_lib_path ()
 
 get_default_extra_mock_libraries ()
 
 get_mocks_library_path ()
 
 get_binary_path (binary="lomiri")
 
 get_data_dirs (data_dirs_mock_enabled=True)
 
 _get_full_mock_data_path ()
 
 _get_xdg_env_path ()
 
 _get_xdg_upstart_env ()
 
 get_grid_size ()
 

Detailed Description

lomiri autopilot tests and helpers - top level package.

Function Documentation

◆ _get_full_mock_data_path()

lomiri._get_full_mock_data_path ( )
protected

Definition at line 111 of file __init__.py.

111def _get_full_mock_data_path():
112 if running_installed_tests():
113 data_path = "/usr/share/lomiri/mocks/data"
114 else:
115 data_path = "../../mocks/data"
116 return os.path.abspath(
117 os.path.join(
118 os.path.dirname(__file__),
119 data_path
120 )
121 )
122
123

◆ _get_xdg_env_path()

lomiri._get_xdg_env_path ( )
protected

Definition at line 124 of file __init__.py.

124def _get_xdg_env_path():
125 path = os.getenv("XDG_DATA_DIRS")
126 if path is None:
127 path = _get_xdg_upstart_env()
128 return path
129
130

◆ _get_xdg_upstart_env()

lomiri._get_xdg_upstart_env ( )
protected

Definition at line 131 of file __init__.py.

131def _get_xdg_upstart_env():
132 try:
133 return subprocess.check_output([
134 "/sbin/initctl",
135 "get-env",
136 "--global",
137 "XDG_DATA_DIRS"
138 ], universal_newlines=True).rstrip()
139 except subprocess.CalledProcessError:
140 return None
141
142

◆ get_binary_path()

lomiri.get_binary_path (   binary = "lomiri")
Return the path to the specified binary.

Definition at line 79 of file __init__.py.

79def get_binary_path(binary="lomiri"):
80 """Return the path to the specified binary."""
81 binary_path = os.path.abspath(
82 os.path.join(
83 os.path.dirname(__file__),
84 "../../../builddir/install/bin/%s" % binary
85 )
86 )
87 if not os.path.exists(binary_path):
88 try:
89 binary_path = subprocess.check_output(
90 ['which', binary],
91 universal_newlines=True,
92 ).strip()
93 except subprocess.CalledProcessError as e:
94 raise RuntimeError("Unable to locate %s binary: %r" % (binary, e))
95 return binary_path
96
97

◆ get_data_dirs()

lomiri.get_data_dirs (   data_dirs_mock_enabled = True)
Prepend a mock data path to XDG_DATA_DIRS.

Definition at line 98 of file __init__.py.

98def get_data_dirs(data_dirs_mock_enabled=True):
99 """Prepend a mock data path to XDG_DATA_DIRS."""
100 data_dirs = _get_xdg_env_path()
101 if data_dirs_mock_enabled:
102 mock_data_path = _get_full_mock_data_path()
103 if os.path.exists(mock_data_path):
104 if data_dirs is not None:
105 data_dirs = '{0}:{1}'.format(mock_data_path, data_dirs)
106 else:
107 data_dirs = mock_data_path
108 return data_dirs
109
110

◆ get_default_extra_mock_libraries()

lomiri.get_default_extra_mock_libraries ( )

Definition at line 50 of file __init__.py.

50def get_default_extra_mock_libraries():
51 mocks_path = get_mocks_library_path()
52 return os.path.join(mocks_path, 'libusermetrics')
53
54

◆ get_grid_size()

lomiri.get_grid_size ( )

Definition at line 143 of file __init__.py.

143def get_grid_size():
144 grid_size = os.getenv('GRID_UNIT_PX')
145 if grid_size is None:
146 raise RuntimeError(
147 "Environment variable GRID_UNIT_PX has not been set."
148 )
149 return int(grid_size)

◆ get_lib_path()

lomiri.get_lib_path ( )
Return the library path to use in this test run.

Definition at line 36 of file __init__.py.

36def get_lib_path():
37 """Return the library path to use in this test run."""
38 if running_installed_tests():
39 lib_path = os.path.join(
40 "/usr/lib/",
41 sysconfig.get_config_var('MULTIARCH'),
42 "lomiri"
43 )
44 else:
45 binary_path = get_binary_path()
46 lib_path = os.path.dirname(binary_path)
47 return lib_path
48
49

◆ get_mocks_library_path()

lomiri.get_mocks_library_path ( )

Definition at line 55 of file __init__.py.

55def get_mocks_library_path():
56 if running_installed_tests():
57 mock_path = "qml/mocks/"
58 else:
59 mock_path = os.path.join(
60 "../lib/",
61 sysconfig.get_config_var('MULTIARCH'),
62 "lomiri/qml/mocks/"
63 )
64 lib_path = get_lib_path()
65 ld_library_path = os.path.abspath(
66 os.path.join(
67 lib_path,
68 mock_path,
69 )
70 )
71
72 if not os.path.exists(ld_library_path):
73 raise RuntimeError(
74 "Expected library path does not exists: %s." % (ld_library_path)
75 )
76 return ld_library_path
77
78

◆ running_installed_tests()

lomiri.running_installed_tests ( )

Definition at line 31 of file __init__.py.

31def running_installed_tests():
32 binary_path = get_binary_path()
33 return binary_path.startswith('/usr')
34
35