Merge lp:~larryprice/libertine/python-i18n into lp:libertine
- python-i18n
- Merge into devel
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Christopher Townsend | ||||
Approved revision: | 420 | ||||
Merged at revision: | 458 | ||||
Proposed branch: | lp:~larryprice/libertine/python-i18n | ||||
Merge into: | lp:libertine | ||||
Diff against target: |
1466 lines (+260/-217) 16 files modified
po/CMakeLists.txt (+43/-0) python/libertine/ChrootContainer.py (+11/-11) python/libertine/ContainerControlClient.py (+2/-2) python/libertine/ContainersConfig.py (+3/-3) python/libertine/HostInfo.py (+2/-2) python/libertine/Libertine.py (+3/-3) python/libertine/LxcContainer.py (+16/-16) python/libertine/LxdContainer.py (+35/-31) python/libertine/launcher/config.py (+5/-9) python/libertine/launcher/session.py (+9/-9) python/libertine/service/container.py (+1/-2) python/libertine/service/container_control_client.py (+1/-1) python/libertine/utils.py (+5/-1) tools/libertine-container-manager (+111/-110) tools/libertine-launch (+4/-8) tools/libertined (+9/-9) |
||||
To merge this branch: | bzr merge lp:~larryprice/libertine/python-i18n | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Libertine CI Bot | continuous-integration | Approve | |
Christopher Townsend | Approve | ||
Review via email: mp+320970@code.launchpad.net |
Commit message
Update all python strings to use gettext.
Description of the change
Update all python strings to use gettext. Also monkey-patch some cmake-extras functions to properly parse python files.
Libertine CI Bot (libertine-ci-bot) wrote : | # |
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:419
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Christopher Townsend (townsend) wrote : | # |
Getting a merge conflict:)
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:420
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Christopher Townsend (townsend) wrote : | # |
Ok, going to roll with this.
Libertine CI Bot (libertine-ci-bot) wrote : | # |
FAILED: Autolanding.
Unapproved changes made after approval.
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Christopher Townsend (townsend) wrote : | # |
Wut? Trying again...
Libertine CI Bot (libertine-ci-bot) : | # |
Preview Diff
1 | === modified file 'po/CMakeLists.txt' | |||
2 | --- po/CMakeLists.txt 2016-12-05 19:41:37 +0000 | |||
3 | +++ po/CMakeLists.txt 2017-04-06 14:39:25 +0000 | |||
4 | @@ -1,7 +1,50 @@ | |||
5 | 1 | # Customize this function from cmake-extras to handle additional options for | ||
6 | 2 | # parsing python files and our python command line tools (LP: #1675865) | ||
7 | 3 | macro(_WRITE_INTLTOOL_MAKEFILE_IN ARG_PO_DIRECTORY ARG_KEYWORDS | ||
8 | 4 | ARG_COPYRIGHT_HOLDER) | ||
9 | 5 | set(_KEYWORDS "XGETTEXT_KEYWORDS=-Lc -Lc++ -Lpython") | ||
10 | 6 | if(NOT "${ARG_COPYRIGHT_HOLDER}" STREQUAL "") | ||
11 | 7 | set(_KEYWORDS "${_KEYWORDS} --copyright-holder='${ARG_COPYRIGHT_HOLDER}'") | ||
12 | 8 | endif() | ||
13 | 9 | foreach(_KEYWORD ${${ARG_KEYWORDS}}) | ||
14 | 10 | set(_KEYWORDS "${_KEYWORDS} --keyword=${_KEYWORD}") | ||
15 | 11 | endforeach() | ||
16 | 12 | file(WRITE "${ARG_PO_DIRECTORY}/Makefile.in.in" "${_KEYWORDS}\n") | ||
17 | 13 | endmacro() | ||
18 | 14 | |||
19 | 15 | # Customize this function from cmake-extras to handle additional options for | ||
20 | 16 | # parsing python files and our python command line tools (LP: #1675864) | ||
21 | 17 | function(_INTLTOOL_LIST_FILTER INPUT OUTPUT) | ||
22 | 18 | set(_multiValueArgs EXPRESSIONS) | ||
23 | 19 | cmake_parse_arguments(_ARG "" "" "${_multiValueArgs}" ${ARGN}) | ||
24 | 20 | |||
25 | 21 | if(_ARG_EXPRESSIONS) | ||
26 | 22 | set(_TMP "") | ||
27 | 23 | foreach(_ITEM ${${INPUT}}) | ||
28 | 24 | unset(_MATCHED) | ||
29 | 25 | foreach(_REGEX ${_ARG_EXPRESSIONS}) | ||
30 | 26 | if("${_ITEM}" MATCHES "${_REGEX}") | ||
31 | 27 | set(_MATCHED ON) | ||
32 | 28 | break() | ||
33 | 29 | endif() | ||
34 | 30 | endforeach() | ||
35 | 31 | if(NOT _MATCHED) | ||
36 | 32 | list(APPEND _TMP "${_ITEM}") | ||
37 | 33 | endif() | ||
38 | 34 | endforeach() | ||
39 | 35 | set(${OUTPUT} "${_TMP}" PARENT_SCOPE) | ||
40 | 36 | unset(_TMP) | ||
41 | 37 | else() | ||
42 | 38 | set(${OUTPUT} "${${INPUT}}" PARENT_SCOPE) | ||
43 | 39 | endif() | ||
44 | 40 | endfunction() | ||
45 | 41 | |||
46 | 1 | set (GETTEXT_PACKAGE "libertine") | 42 | set (GETTEXT_PACKAGE "libertine") |
47 | 2 | 43 | ||
48 | 3 | intltool_update_potfile( | 44 | intltool_update_potfile( |
49 | 4 | UBUNTU_SDK_DEFAULTS | 45 | UBUNTU_SDK_DEFAULTS |
50 | 46 | FILE_GLOBS "${CMAKE_SOURCE_DIR}/python/libertine/**/*.py;${CMAKE_SOURCE_DIR}/tools/libertine-*" | ||
51 | 47 | FILTER "__init__.py;.bzr/*;parts/*;stage/*;prime/*" | ||
52 | 5 | POTFILES_TEMPLATE POTFILES.in.in | 48 | POTFILES_TEMPLATE POTFILES.in.in |
53 | 6 | COPYRIGHT_HOLDER "Canonical Ltd." | 49 | COPYRIGHT_HOLDER "Canonical Ltd." |
54 | 7 | GETTEXT_PACKAGE ${GETTEXT_PACKAGE} | 50 | GETTEXT_PACKAGE ${GETTEXT_PACKAGE} |
55 | 8 | 51 | ||
56 | === modified file 'python/libertine/ChrootContainer.py' | |||
57 | --- python/libertine/ChrootContainer.py 2017-03-08 21:23:54 +0000 | |||
58 | +++ python/libertine/ChrootContainer.py 2017-04-06 14:39:25 +0000 | |||
59 | @@ -75,12 +75,12 @@ | |||
60 | 75 | cmd.wait() | 75 | cmd.wait() |
61 | 76 | 76 | ||
62 | 77 | if cmd.returncode != 0: | 77 | if cmd.returncode != 0: |
64 | 78 | utils.get_logger().error("Failed to create container") | 78 | utils.get_logger().error(utils._("Failed to create container")) |
65 | 79 | self.destroy_libertine_container() | 79 | self.destroy_libertine_container() |
66 | 80 | return False | 80 | return False |
67 | 81 | 81 | ||
68 | 82 | # Remove symlinks as they can cause ill-behaved recursive behavior in the chroot | 82 | # Remove symlinks as they can cause ill-behaved recursive behavior in the chroot |
70 | 83 | utils.get_logger().info("Fixing chroot symlinks...") | 83 | utils.get_logger().info(utils._("Fixing chroot symlinks...")) |
71 | 84 | os.remove(os.path.join(self.root_path, 'dev')) | 84 | os.remove(os.path.join(self.root_path, 'dev')) |
72 | 85 | os.remove(os.path.join(self.root_path, 'proc')) | 85 | os.remove(os.path.join(self.root_path, 'proc')) |
73 | 86 | 86 | ||
74 | @@ -101,7 +101,7 @@ | |||
75 | 101 | else: | 101 | else: |
76 | 102 | archive = "deb http://archive.ubuntu.com/ubuntu " | 102 | archive = "deb http://archive.ubuntu.com/ubuntu " |
77 | 103 | 103 | ||
79 | 104 | utils.get_logger().info("Updating chroot's sources.list entries...") | 104 | utils.get_logger().info(utils._("Updating chroot's sources.list entries...")) |
80 | 105 | 105 | ||
81 | 106 | with open(os.path.join(self.root_path, 'etc', 'apt', 'sources.list'), 'a') as fd: | 106 | with open(os.path.join(self.root_path, 'etc', 'apt', 'sources.list'), 'a') as fd: |
82 | 107 | fd.write(archive + self.installed_release + "-updates main\n") | 107 | fd.write(archive + self.installed_release + "-updates main\n") |
83 | @@ -115,22 +115,22 @@ | |||
84 | 115 | self.update_locale() | 115 | self.update_locale() |
85 | 116 | 116 | ||
86 | 117 | if multiarch and self.architecture == 'amd64': | 117 | if multiarch and self.architecture == 'amd64': |
88 | 118 | utils.get_logger().info("Adding i386 multiarch support...") | 118 | utils.get_logger().info(utils._("Adding i386 multiarch support...")) |
89 | 119 | self.run_in_container("dpkg --add-architecture i386") | 119 | self.run_in_container("dpkg --add-architecture i386") |
90 | 120 | 120 | ||
92 | 121 | utils.get_logger().info("Updating the contents of the container after creation...") | 121 | utils.get_logger().info(utils._("Updating the contents of the container after creation...")) |
93 | 122 | self.update_packages() | 122 | self.update_packages() |
94 | 123 | 123 | ||
95 | 124 | for package in self.default_packages: | 124 | for package in self.default_packages: |
96 | 125 | if not self.install_package(package, update_cache=False): | 125 | if not self.install_package(package, update_cache=False): |
98 | 126 | utils.get_logger().error("Failure installing %s during container creation" % package) | 126 | utils.get_logger().error(utils._("Failure installing '{package_name}' during container creation".format(package_name=package)) |
99 | 127 | self.destroy_libertine_container() | 127 | self.destroy_libertine_container() |
100 | 128 | return False | 128 | return False |
101 | 129 | 129 | ||
102 | 130 | if self.installed_release == "vivid" or self.installed_release == "xenial": | 130 | if self.installed_release == "vivid" or self.installed_release == "xenial": |
104 | 131 | utils.get_logger().info("Installing the Stable Overlay PPA...") | 131 | utils.get_logger().info(utils._("Installing the Stable Overlay PPA...")) |
105 | 132 | if not self.install_package("software-properties-common", update_cache=False): | 132 | if not self.install_package("software-properties-common", update_cache=False): |
107 | 133 | utils.get_logger().error("Failure installing software-properties-common during container creation") | 133 | utils.get_logger().error(utils._("Failure installing software-properties-common during container creation")) |
108 | 134 | self.destroy_libertine_container() | 134 | self.destroy_libertine_container() |
109 | 135 | return False | 135 | return False |
110 | 136 | 136 | ||
111 | @@ -168,7 +168,7 @@ | |||
112 | 168 | def _build_proot_command(self): | 168 | def _build_proot_command(self): |
113 | 169 | proot_cmd = shutil.which('proot') | 169 | proot_cmd = shutil.which('proot') |
114 | 170 | if not proot_cmd: | 170 | if not proot_cmd: |
116 | 171 | raise RuntimeError('executable proot not found') | 171 | raise RuntimeError(utils._('executable proot not found')) |
117 | 172 | 172 | ||
118 | 173 | proot_cmd += " -R " + self.root_path | 173 | proot_cmd += " -R " + self.root_path |
119 | 174 | 174 | ||
120 | @@ -211,7 +211,7 @@ | |||
121 | 211 | def _build_privileged_proot_cmd(self): | 211 | def _build_privileged_proot_cmd(self): |
122 | 212 | proot_cmd = shutil.which('proot') | 212 | proot_cmd = shutil.which('proot') |
123 | 213 | if not proot_cmd: | 213 | if not proot_cmd: |
125 | 214 | raise RuntimeError('executable proot not found') | 214 | raise RuntimeError(utils._('executable proot not found')) |
126 | 215 | 215 | ||
127 | 216 | proot_cmd += " -b /usr/lib/locale -S " + self.root_path | 216 | proot_cmd += " -b /usr/lib/locale -S " + self.root_path |
128 | 217 | 217 | ||
129 | @@ -232,7 +232,7 @@ | |||
130 | 232 | app.wait() | 232 | app.wait() |
131 | 233 | 233 | ||
132 | 234 | def _run_ldconfig(self): | 234 | def _run_ldconfig(self): |
134 | 235 | utils.get_logger().info("Refreshing the container's dynamic linker run-time bindings...") | 235 | utils.get_logger().info(utils._("Refreshing the container's dynamic linker run-time bindings...")) |
135 | 236 | 236 | ||
136 | 237 | command_line = self._build_privileged_proot_cmd() + " ldconfig.REAL" | 237 | command_line = self._build_privileged_proot_cmd() + " ldconfig.REAL" |
137 | 238 | 238 | ||
138 | 239 | 239 | ||
139 | === modified file 'python/libertine/ContainerControlClient.py' | |||
140 | --- python/libertine/ContainerControlClient.py 2017-03-08 21:26:57 +0000 | |||
141 | +++ python/libertine/ContainerControlClient.py 2017-04-06 14:39:25 +0000 | |||
142 | @@ -38,9 +38,9 @@ | |||
143 | 38 | self._control = bus.get_object(constants.SERVICE_NAME, constants.CONTAINER_CONTROL_OBJECT) | 38 | self._control = bus.get_object(constants.SERVICE_NAME, constants.CONTAINER_CONTROL_OBJECT) |
144 | 39 | self._interface = constants.CONTAINER_CONTROL_INTERFACE | 39 | self._interface = constants.CONTAINER_CONTROL_INTERFACE |
145 | 40 | except ImportError as e: | 40 | except ImportError as e: |
147 | 41 | utils.get_logger().warning("Libertine service libraries not installed.") | 41 | utils.get_logger().warning(utils._("Libertine service libraries not installed.")) |
148 | 42 | except dbus.exceptions.DBusException as e: | 42 | except dbus.exceptions.DBusException as e: |
150 | 43 | utils.get_logger().warning("Exception raised while discovering d-bus service: {}".format(str(e))) | 43 | utils.get_logger().warning(utils._("Exception raised while discovering d-bus service: {error}").format(error=str(e))) |
151 | 44 | 44 | ||
152 | 45 | def _do_operation(self, operation): | 45 | def _do_operation(self, operation): |
153 | 46 | # It's possible that the service has gone down from when first getting the object. | 46 | # It's possible that the service has gone down from when first getting the object. |
154 | 47 | 47 | ||
155 | === modified file 'python/libertine/ContainersConfig.py' | |||
156 | --- python/libertine/ContainersConfig.py 2017-03-29 16:22:24 +0000 | |||
157 | +++ python/libertine/ContainersConfig.py 2017-04-06 14:39:25 +0000 | |||
158 | @@ -249,12 +249,12 @@ | |||
159 | 249 | 249 | ||
160 | 250 | def check_container_id(self, container_id): | 250 | def check_container_id(self, container_id): |
161 | 251 | if container_id and not self.container_exists(container_id): | 251 | if container_id and not self.container_exists(container_id): |
163 | 252 | utils.get_logger().error("Container id '{container_id}' does not exist.".format(container_id=container_id)) | 252 | utils.get_logger().error(utils._("Container id '{container_id}' does not exist.").format(container_id=container_id)) |
164 | 253 | sys.exit(1) | 253 | sys.exit(1) |
165 | 254 | elif not container_id: | 254 | elif not container_id: |
166 | 255 | container_id = self.get_default_container_id() | 255 | container_id = self.get_default_container_id() |
167 | 256 | if container_id is None: | 256 | if container_id is None: |
169 | 257 | utils.get_logger().error("No default container available.") | 257 | utils.get_logger().error(utils._("No default container available.")) |
170 | 258 | sys.exit(1) | 258 | sys.exit(1) |
171 | 259 | 259 | ||
172 | 260 | return container_id | 260 | return container_id |
173 | @@ -298,7 +298,7 @@ | |||
174 | 298 | 298 | ||
175 | 299 | def delete_container(self, container_id): | 299 | def delete_container(self, container_id): |
176 | 300 | if not self.container_list: | 300 | if not self.container_list: |
178 | 301 | utils.get_logger().error("Unable to delete container. No containers defined.") | 301 | utils.get_logger().error(utils._("Unable to delete container. No containers defined.")) |
179 | 302 | sys.exit(1) | 302 | sys.exit(1) |
180 | 303 | 303 | ||
181 | 304 | container = self._get_container_entry(container_id) | 304 | container = self._get_container_entry(container_id) |
182 | 305 | 305 | ||
183 | === modified file 'python/libertine/HostInfo.py' | |||
184 | --- python/libertine/HostInfo.py 2017-02-24 15:05:33 +0000 | |||
185 | +++ python/libertine/HostInfo.py 2017-04-06 14:39:25 +0000 | |||
186 | @@ -12,7 +12,6 @@ | |||
187 | 12 | # You should have received a copy of the GNU General Public License along | 12 | # You should have received a copy of the GNU General Public License along |
188 | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 13 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
189 | 14 | 14 | ||
190 | 15 | import libertine.utils | ||
191 | 16 | import locale | 15 | import locale |
192 | 17 | import lsb_release | 16 | import lsb_release |
193 | 18 | import os | 17 | import os |
194 | @@ -20,6 +19,7 @@ | |||
195 | 20 | import subprocess | 19 | import subprocess |
196 | 21 | 20 | ||
197 | 22 | from distro_info import UbuntuDistroInfo | 21 | from distro_info import UbuntuDistroInfo |
198 | 22 | from libertine import utils | ||
199 | 23 | 23 | ||
200 | 24 | 24 | ||
201 | 25 | class HostInfo(object): | 25 | class HostInfo(object): |
202 | @@ -78,7 +78,7 @@ | |||
203 | 78 | stdout=subprocess.PIPE, | 78 | stdout=subprocess.PIPE, |
204 | 79 | universal_newlines=True) | 79 | universal_newlines=True) |
205 | 80 | if dpkg.wait() != 0: | 80 | if dpkg.wait() != 0: |
207 | 81 | parser.error("Failed to determine the local architecture.") | 81 | parser.error(utils._("Failed to determine the local architecture.")) |
208 | 82 | 82 | ||
209 | 83 | return dpkg.stdout.read().strip() | 83 | return dpkg.stdout.read().strip() |
210 | 84 | 84 | ||
211 | 85 | 85 | ||
212 | === modified file 'python/libertine/Libertine.py' | |||
213 | --- python/libertine/Libertine.py 2017-03-23 14:35:57 +0000 | |||
214 | +++ python/libertine/Libertine.py 2017-04-06 14:39:25 +0000 | |||
215 | @@ -236,7 +236,7 @@ | |||
216 | 236 | 236 | ||
217 | 237 | if package_name.endswith('.deb'): | 237 | if package_name.endswith('.deb'): |
218 | 238 | if not os.path.exists(package_name): | 238 | if not os.path.exists(package_name): |
220 | 239 | utils.get_logger().error("File {} does not exist.".format(package_name)) | 239 | utils.get_logger().error(utils._("File '{package_name}' does not exist.").format(package_name=package_name)) |
221 | 240 | return False | 240 | return False |
222 | 241 | 241 | ||
223 | 242 | dest = os.path.join('/', 'tmp', package_name.split('/')[-1]) | 242 | dest = os.path.join('/', 'tmp', package_name.split('/')[-1]) |
224 | @@ -377,7 +377,7 @@ | |||
225 | 377 | def __init__(self, container): | 377 | def __init__(self, container): |
226 | 378 | super().__init__() | 378 | super().__init__() |
227 | 379 | if not container.start_container(): | 379 | if not container.start_container(): |
229 | 380 | raise RuntimeError("Container failed to start.") | 380 | raise RuntimeError(utils._("Container failed to start.")) |
230 | 381 | 381 | ||
231 | 382 | self.callback(lambda: container.stop_container()) | 382 | self.callback(lambda: container.stop_container()) |
232 | 383 | 383 | ||
233 | @@ -412,7 +412,7 @@ | |||
234 | 412 | elif container_type == "mock": | 412 | elif container_type == "mock": |
235 | 413 | self.container = LibertineMock(container_id, self.containers_config, service) | 413 | self.container = LibertineMock(container_id, self.containers_config, service) |
236 | 414 | else: | 414 | else: |
238 | 415 | raise RuntimeError("Unsupported container type %s" % container_type) | 415 | raise RuntimeError(utils._("Unsupported container type '{container_type}'").format(container_type)) |
239 | 416 | 416 | ||
240 | 417 | @property | 417 | @property |
241 | 418 | def container_id(self): | 418 | def container_id(self): |
242 | 419 | 419 | ||
243 | === modified file 'python/libertine/LxcContainer.py' | |||
244 | --- python/libertine/LxcContainer.py 2017-03-08 21:23:54 +0000 | |||
245 | +++ python/libertine/LxcContainer.py 2017-04-06 14:39:25 +0000 | |||
246 | @@ -69,7 +69,7 @@ | |||
247 | 69 | for line in fd: | 69 | for line in fd: |
248 | 70 | print(line.lstrip()) | 70 | print(line.lstrip()) |
249 | 71 | except Exception as ex: | 71 | except Exception as ex: |
251 | 72 | utils.get_logger().error("Could not open LXC log file: %s" % ex) | 72 | utils.get_logger().error(utils._("Could not open LXC log file: {logfile}").format(logfile=ex)) |
252 | 73 | 73 | ||
253 | 74 | 74 | ||
254 | 75 | def get_logfile(container): | 75 | def get_logfile(container): |
255 | @@ -90,20 +90,20 @@ | |||
256 | 90 | 90 | ||
257 | 91 | if container.state == 'STOPPED': | 91 | if container.state == 'STOPPED': |
258 | 92 | if not container.start(): | 92 | if not container.start(): |
260 | 93 | utils.get_logger().error("Container failed to start.") | 93 | utils.get_logger().error(utils._("Container failed to start.")) |
261 | 94 | return False | 94 | return False |
262 | 95 | elif container.state == 'FROZEN': | 95 | elif container.state == 'FROZEN': |
263 | 96 | if not container.unfreeze(): | 96 | if not container.unfreeze(): |
265 | 97 | utils.get_logger().error("Container failed to unfreeze.") | 97 | utils.get_logger().error(utils._("Container failed to unfreeze.")) |
266 | 98 | return False | 98 | return False |
267 | 99 | 99 | ||
268 | 100 | if not container.wait("RUNNING", 10): | 100 | if not container.wait("RUNNING", 10): |
270 | 101 | utils.get_logger().error("Container failed to enter the RUNNING state.") | 101 | utils.get_logger().error(utils._("Container failed to enter the RUNNING state.")) |
271 | 102 | return False | 102 | return False |
272 | 103 | 103 | ||
273 | 104 | if not container.get_ips(timeout=30): | 104 | if not container.get_ips(timeout=30): |
274 | 105 | lxc_stop(container) | 105 | lxc_stop(container) |
276 | 106 | utils.get_logger().error("Not able to connect to the network.") | 106 | utils.get_logger().error(utils._("Not able to connect to the network.")) |
277 | 107 | return False | 107 | return False |
278 | 108 | 108 | ||
279 | 109 | return True | 109 | return True |
280 | @@ -116,12 +116,12 @@ | |||
281 | 116 | if freeze_on_stop: | 116 | if freeze_on_stop: |
282 | 117 | container.freeze() | 117 | container.freeze() |
283 | 118 | if not container.wait("FROZEN", 10): | 118 | if not container.wait("FROZEN", 10): |
285 | 119 | utils.get_logger().error("Container failed to enter the FROZEN state.") | 119 | utils.get_logger().error(utils._("Container failed to enter the FROZEN state.")) |
286 | 120 | return False | 120 | return False |
287 | 121 | else: | 121 | else: |
288 | 122 | container.stop() | 122 | container.stop() |
289 | 123 | if not container.wait("STOPPED", 10): | 123 | if not container.wait("STOPPED", 10): |
291 | 124 | utils.get_logger().error("Container failed to enter the STOPPED state.") | 124 | utils.get_logger().error(utils._("Container failed to enter the STOPPED state.")) |
292 | 125 | return False | 125 | return False |
293 | 126 | 126 | ||
294 | 127 | return True | 127 | return True |
295 | @@ -246,7 +246,7 @@ | |||
296 | 246 | 246 | ||
297 | 247 | def restart_container(self): | 247 | def restart_container(self): |
298 | 248 | if self.container.state != 'FROZEN': | 248 | if self.container.state != 'FROZEN': |
300 | 249 | utils.get_logger().warning("Container {} is not frozen. Cannot restart.".format(self.container_id)) | 249 | utils.get_logger().warning(utils._("Container '{container_id}' is not frozen. Cannot restart.").format(container_id=self.container_id)) |
301 | 250 | return False | 250 | return False |
302 | 251 | 251 | ||
303 | 252 | if not (lxc_stop(self.container) and lxc_start(self.container)): | 252 | if not (lxc_stop(self.container) and lxc_start(self.container)): |
304 | @@ -272,11 +272,11 @@ | |||
305 | 272 | return False | 272 | return False |
306 | 273 | 273 | ||
307 | 274 | if self.container.state == 'RUNNING' and not force: | 274 | if self.container.state == 'RUNNING' and not force: |
309 | 275 | utils.get_logger().error("Canceling destruction due to running container. Use --force to override.") | 275 | utils.get_logger().error(utils._("Canceling destruction due to running container. Use --force to override.")) |
310 | 276 | return False | 276 | return False |
311 | 277 | 277 | ||
312 | 278 | if not lxc_stop(self.container): | 278 | if not lxc_stop(self.container): |
314 | 279 | utils.get_logger().error("Failed to force container to stop. Canceling destruction.") | 279 | utils.get_logger().error(utils._("Failed to force container to stop. Canceling destruction.")) |
315 | 280 | return False | 280 | return False |
316 | 281 | 281 | ||
317 | 282 | self.container.destroy() | 282 | self.container.destroy() |
318 | @@ -322,13 +322,13 @@ | |||
319 | 322 | {"dist": "ubuntu", | 322 | {"dist": "ubuntu", |
320 | 323 | "release": self.installed_release, | 323 | "release": self.installed_release, |
321 | 324 | "arch": self.architecture}): | 324 | "arch": self.architecture}): |
323 | 325 | utils.get_logger().error("Failed to create container") | 325 | utils.get_logger().error(utils._("Failed to create container")) |
324 | 326 | _dump_lxc_log(lxc_logfile) | 326 | _dump_lxc_log(lxc_logfile) |
325 | 327 | return False | 327 | return False |
326 | 328 | 328 | ||
327 | 329 | self.create_libertine_config() | 329 | self.create_libertine_config() |
328 | 330 | 330 | ||
330 | 331 | utils.get_logger().info("starting container ...") | 331 | utils.get_logger().info(utils._("starting container ...")) |
331 | 332 | if not self.start_container(): | 332 | if not self.start_container(): |
332 | 333 | self.destroy_libertine_container() | 333 | self.destroy_libertine_container() |
333 | 334 | return False | 334 | return False |
334 | @@ -340,21 +340,21 @@ | |||
335 | 340 | str(user_id), crypt.crypt(password), str(username))) | 340 | str(user_id), crypt.crypt(password), str(username))) |
336 | 341 | 341 | ||
337 | 342 | if multiarch and self.architecture == 'amd64': | 342 | if multiarch and self.architecture == 'amd64': |
339 | 343 | utils.get_logger().info("Adding i386 multiarch support...") | 343 | utils.get_logger().info(utils._("Adding i386 multiarch support...")) |
340 | 344 | self.run_in_container("dpkg --add-architecture i386") | 344 | self.run_in_container("dpkg --add-architecture i386") |
341 | 345 | 345 | ||
343 | 346 | utils.get_logger().info("Updating the contents of the container after creation...") | 346 | utils.get_logger().info(utils._("Updating the contents of the container after creation...")) |
344 | 347 | self.update_packages() | 347 | self.update_packages() |
345 | 348 | 348 | ||
346 | 349 | for package in self.default_packages: | 349 | for package in self.default_packages: |
347 | 350 | if not self.install_package(package, update_cache=False): | 350 | if not self.install_package(package, update_cache=False): |
349 | 351 | utils.get_logger().error("Failure installing %s during container creation" % package) | 351 | utils.get_logger().error(utils._("Failure installing '{package_name}' during container creation").format(package_name=package)) |
350 | 352 | self.destroy_libertine_container() | 352 | self.destroy_libertine_container() |
351 | 353 | return False | 353 | return False |
352 | 354 | 354 | ||
353 | 355 | super().create_libertine_container() | 355 | super().create_libertine_container() |
354 | 356 | 356 | ||
356 | 357 | utils.get_logger().info("stopping container ...") | 357 | utils.get_logger().info(utils._("stopping container ...")) |
357 | 358 | self.stop_container() | 358 | self.stop_container() |
358 | 359 | 359 | ||
359 | 360 | return True | 360 | return True |
360 | 361 | 361 | ||
361 | === modified file 'python/libertine/LxdContainer.py' | |||
362 | --- python/libertine/LxdContainer.py 2017-03-23 14:42:39 +0000 | |||
363 | +++ python/libertine/LxdContainer.py 2017-04-06 14:39:25 +0000 | |||
364 | @@ -62,7 +62,7 @@ | |||
365 | 62 | 62 | ||
366 | 63 | def _setup_lxd(): | 63 | def _setup_lxd(): |
367 | 64 | if utils.is_snap_environment(): | 64 | if utils.is_snap_environment(): |
369 | 65 | utils.get_logger().warning("Snapped libertine detected, you may need to run `sudo lxd init` manually.") | 65 | utils.get_logger().warning(utils._("Snapped libertine detected, you may need to run `sudo lxd init` manually.")) |
370 | 66 | return True | 66 | return True |
371 | 67 | 67 | ||
372 | 68 | utils.get_logger().debug("Running LXD setup.") | 68 | utils.get_logger().debug("Running LXD setup.") |
373 | @@ -92,7 +92,7 @@ | |||
374 | 92 | 92 | ||
375 | 93 | 93 | ||
376 | 94 | def _setup_bind_mount_service(container, uid, username): | 94 | def _setup_bind_mount_service(container, uid, username): |
378 | 95 | utils.get_logger().info("Creating mount update shell script") | 95 | utils.get_logger().info(utils._("Creating mount update shell script")) |
379 | 96 | script = ''' | 96 | script = ''' |
380 | 97 | #!/bin/sh | 97 | #!/bin/sh |
381 | 98 | 98 | ||
382 | @@ -122,7 +122,7 @@ | |||
383 | 122 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 122 | stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
384 | 123 | out, err = ping.communicate() | 123 | out, err = ping.communicate() |
385 | 124 | if out: | 124 | if out: |
387 | 125 | utils.get_logger().info("Network connection active") | 125 | utils.get_logger().debug("Network connection active") |
388 | 126 | return True | 126 | return True |
389 | 127 | time.sleep(1) | 127 | time.sleep(1) |
390 | 128 | return False | 128 | return False |
391 | @@ -137,7 +137,7 @@ | |||
392 | 137 | container.sync(rollback=True) # required for pylxd=2.0.x | 137 | container.sync(rollback=True) # required for pylxd=2.0.x |
393 | 138 | 138 | ||
394 | 139 | if container.status != 'Running': | 139 | if container.status != 'Running': |
396 | 140 | utils.get_logger().error("Container {} failed to start".format(container.name)) | 140 | utils.get_logger().error(utils._("Container '{container_id}' failed to start").format(container_id=container.name)) |
397 | 141 | return False | 141 | return False |
398 | 142 | 142 | ||
399 | 143 | return True | 143 | return True |
400 | @@ -156,10 +156,10 @@ | |||
401 | 156 | 156 | ||
402 | 157 | if wait: | 157 | if wait: |
403 | 158 | if freeze_on_stop and container.status != 'Frozen': | 158 | if freeze_on_stop and container.status != 'Frozen': |
405 | 159 | utils.get_logger().error("Container {} failed to freeze".format(container.name)) | 159 | utils.get_logger().error(utils._("Container '{container_id}' failed to freeze").format(container_id=container.name)) |
406 | 160 | return False | 160 | return False |
407 | 161 | elif not freeze_on_stop and container.status != 'Stopped': | 161 | elif not freeze_on_stop and container.status != 'Stopped': |
409 | 162 | utils.get_logger().error("Container {} failed to stop".format(container.name)) | 162 | utils.get_logger().error(utils._("Container '{container_id}' failed to stop").format(container_id=container.name)) |
410 | 163 | return False | 163 | return False |
411 | 164 | 164 | ||
412 | 165 | return True | 165 | return True |
413 | @@ -178,7 +178,7 @@ | |||
414 | 178 | def _sync_application_dirs_to_host(container): | 178 | def _sync_application_dirs_to_host(container): |
415 | 179 | host_root = utils.get_libertine_container_rootfs_path(container.name) | 179 | host_root = utils.get_libertine_container_rootfs_path(container.name) |
416 | 180 | for container_path in _CONTAINER_DATA_DIRS: | 180 | for container_path in _CONTAINER_DATA_DIRS: |
418 | 181 | utils.get_logger().info("Syncing applications directory: {}".format(container_path)) | 181 | utils.get_logger().info(utils._("Syncing applications directory: {sync_path}").format(sync_path=container_path)) |
419 | 182 | os.makedirs(os.path.join(host_root, container_path.lstrip("/")), exist_ok=True) | 182 | os.makedirs(os.path.join(host_root, container_path.lstrip("/")), exist_ok=True) |
420 | 183 | 183 | ||
421 | 184 | # find a list of files within the container | 184 | # find a list of files within the container |
422 | @@ -194,7 +194,7 @@ | |||
423 | 194 | 194 | ||
424 | 195 | host_path = os.path.join(host_root, filepath.lstrip("/")) | 195 | host_path = os.path.join(host_root, filepath.lstrip("/")) |
425 | 196 | if not os.path.exists(host_path): | 196 | if not os.path.exists(host_path): |
427 | 197 | utils.get_logger().info("Syncing file: {}:{}".format(filepath, host_path)) | 197 | utils.get_logger().info(utils._("Syncing file: {container_path}:{host_path}".format(container_path=filepath, host_path=host_path))) |
428 | 198 | os.makedirs(os.path.dirname(host_path), exist_ok=True) | 198 | os.makedirs(os.path.dirname(host_path), exist_ok=True) |
429 | 199 | with open(host_path, 'wb') as f: | 199 | with open(host_path, 'wb') as f: |
430 | 200 | f.write(container.files.get(filepath)) | 200 | f.write(container.files.get(filepath)) |
431 | @@ -230,7 +230,7 @@ | |||
432 | 230 | container_link_endpoints = [link.strip() for link in links_stdout.decode('utf-8').split('\n')[:-1]] | 230 | container_link_endpoints = [link.strip() for link in links_stdout.decode('utf-8').split('\n')[:-1]] |
433 | 231 | 231 | ||
434 | 232 | if len(broken_host_links) != len(container_link_endpoints): | 232 | if len(broken_host_links) != len(container_link_endpoints): |
436 | 233 | utils.get_logger().warning("Link mismatch while trying to fix symbolic links.") | 233 | utils.get_logger().warning(utils._("Link mismatch while trying to fix symbolic links.")) |
437 | 234 | return | 234 | return |
438 | 235 | 235 | ||
439 | 236 | for i in range(0, len(broken_host_links)): | 236 | for i in range(0, len(broken_host_links)): |
440 | @@ -245,7 +245,8 @@ | |||
441 | 245 | try: | 245 | try: |
442 | 246 | f.write(container.files.get(container_link_endpoints[i])) | 246 | f.write(container.files.get(container_link_endpoints[i])) |
443 | 247 | except pylxd.exceptions.NotFound as e: | 247 | except pylxd.exceptions.NotFound as e: |
445 | 248 | utils.get_logger().warning("Error during symlink copy of {}: {}".format(container_link_endpoints[i], str(e))) | 248 | utils.get_logger().warning(utils._("Error during symlink copy of {container_path}: {error}") |
446 | 249 | .format(container_path=container_link_endpoints[i], error=str(e))) | ||
447 | 249 | continue | 250 | continue |
448 | 250 | 251 | ||
449 | 251 | subprocess.Popen(_lxc_args(container.name, "ln -sf --relative {} {}".format( | 252 | subprocess.Popen(_lxc_args(container.name, "ln -sf --relative {} {}".format( |
450 | @@ -258,7 +259,7 @@ | |||
451 | 258 | find = subprocess.Popen(shlex.split("find {} -type f".format(root_path)), stdout=subprocess.PIPE) | 259 | find = subprocess.Popen(shlex.split("find {} -type f".format(root_path)), stdout=subprocess.PIPE) |
452 | 259 | find_stdout, stderr = find.communicate() | 260 | find_stdout, stderr = find.communicate() |
453 | 260 | if find.returncode != 0: | 261 | if find.returncode != 0: |
455 | 261 | utils.get_logger().warning("Finding local files to remove failed.") | 262 | utils.get_logger().warning(utils._("Finding local files to remove failed.")) |
456 | 262 | return | 263 | return |
457 | 263 | 264 | ||
458 | 264 | existing_files = [f.replace(root_path, '') for f in find_stdout.decode('UTF-8').strip().split('\n') if f] | 265 | existing_files = [f.replace(root_path, '') for f in find_stdout.decode('UTF-8').strip().split('\n') if f] |
459 | @@ -271,20 +272,20 @@ | |||
460 | 271 | 'bash -c "echo -n {} | xargs -d , -I % bash -c \'test -e % || echo %\'"'.format(','.join(existing_files))), stdout=subprocess.PIPE) | 272 | 'bash -c "echo -n {} | xargs -d , -I % bash -c \'test -e % || echo %\'"'.format(','.join(existing_files))), stdout=subprocess.PIPE) |
461 | 272 | remove_stdout, stderr = missing_files.communicate() | 273 | remove_stdout, stderr = missing_files.communicate() |
462 | 273 | if missing_files.returncode != 0: | 274 | if missing_files.returncode != 0: |
464 | 274 | utils.get_logger().warning("Checking for missing files failed.") | 275 | utils.get_logger().warning(utils._("Checking for missing files failed.")) |
465 | 275 | return | 276 | return |
466 | 276 | 277 | ||
467 | 277 | for f in [os.path.join(root_path, f.lstrip('/')) for f in remove_stdout.decode('UTF-8').strip().split('\n') if f]: | 278 | for f in [os.path.join(root_path, f.lstrip('/')) for f in remove_stdout.decode('UTF-8').strip().split('\n') if f]: |
468 | 278 | try: | 279 | try: |
469 | 279 | os.remove(f) | 280 | os.remove(f) |
470 | 280 | except PermissionError as e: | 281 | except PermissionError as e: |
472 | 281 | utils.get_logger().warning("Error while trying to remove local file {}: {}".format(f, str(e))) | 282 | utils.get_logger().warning(utils._("Error while trying to remove local file {filepath}: {error}").format(filepath=f, error=str(e))) |
473 | 282 | 283 | ||
474 | 283 | # now remove any dangling directories | 284 | # now remove any dangling directories |
475 | 284 | empty_dirs = subprocess.Popen(shlex.split("find {} -depth -type d -empty".format(root_path)), stdout=subprocess.PIPE) | 285 | empty_dirs = subprocess.Popen(shlex.split("find {} -depth -type d -empty".format(root_path)), stdout=subprocess.PIPE) |
476 | 285 | empty_out, stderr = empty_dirs.communicate() | 286 | empty_out, stderr = empty_dirs.communicate() |
477 | 286 | if empty_dirs.returncode != 0: | 287 | if empty_dirs.returncode != 0: |
479 | 287 | utils.get_logger().warning("Looking for local empty directories failed.") | 288 | utils.get_logger().warning(utils._("Looking for local empty directories failed.")) |
480 | 288 | return | 289 | return |
481 | 289 | 290 | ||
482 | 290 | deleteable_dirs = [d for d in empty_out.decode('UTF-8').strip().split('\n') if d] | 291 | deleteable_dirs = [d for d in empty_out.decode('UTF-8').strip().split('\n') if d] |
483 | @@ -330,7 +331,7 @@ | |||
484 | 330 | 331 | ||
485 | 331 | for user_dir in utils.generate_binding_directories(mounts, home_path.rstrip('/')): | 332 | for user_dir in utils.generate_binding_directories(mounts, home_path.rstrip('/')): |
486 | 332 | if not os.path.exists(user_dir[0]): | 333 | if not os.path.exists(user_dir[0]): |
488 | 333 | utils.get_logger().warning('Bind-mount path \'{}\' does not exist.'.format(user_dir[0])) | 334 | utils.get_logger().warning(utils._("Bind-mount path '{mount_path}' does not exist.").format(mount_path=user_dir[0])) |
489 | 334 | continue | 335 | continue |
490 | 335 | 336 | ||
491 | 336 | if os.path.isabs(user_dir[1]): | 337 | if os.path.isabs(user_dir[1]): |
492 | @@ -349,7 +350,7 @@ | |||
493 | 349 | 'type': 'disk' | 350 | 'type': 'disk' |
494 | 350 | } | 351 | } |
495 | 351 | 352 | ||
497 | 352 | _lxd_save(container, 'Saving bind mounts for container \'{}\' raised:'.format(container.name)) | 353 | _lxd_save(container, utils._("Saving bind mounts for container '{container_id}' raised:").format(container_id=container.name)) |
498 | 353 | 354 | ||
499 | 354 | 355 | ||
500 | 355 | def _setup_etc_hosts(container): | 356 | def _setup_etc_hosts(container): |
501 | @@ -368,13 +369,13 @@ | |||
502 | 368 | try: | 369 | try: |
503 | 369 | profile = client.profiles.get('libertine') | 370 | profile = client.profiles.get('libertine') |
504 | 370 | 371 | ||
506 | 371 | utils.get_logger().info('Updating existing lxd profile.') | 372 | utils.get_logger().info(utils._('Updating existing lxd profile.')) |
507 | 372 | profile.devices = _get_devices_map() | 373 | profile.devices = _get_devices_map() |
508 | 373 | profile.config['raw.idmap'] = 'both 1000 1000' | 374 | profile.config['raw.idmap'] = 'both 1000 1000' |
509 | 374 | 375 | ||
511 | 375 | _lxd_save(profile, 'Saving libertine lxd profile raised:') | 376 | _lxd_save(profile, utils._('Saving libertine lxd profile raised:')) |
512 | 376 | except pylxd.exceptions.LXDAPIException: | 377 | except pylxd.exceptions.LXDAPIException: |
514 | 377 | utils.get_logger().info('Creating libertine lxd profile.') | 378 | utils.get_logger().info(utils._('Creating libertine lxd profile.')) |
515 | 378 | client.profiles.create('libertine', config={'raw.idmap': 'both 1000 1000'}, devices=_get_devices_map()) | 379 | client.profiles.create('libertine', config={'raw.idmap': 'both 1000 1000'}, devices=_get_devices_map()) |
516 | 379 | 380 | ||
517 | 380 | 381 | ||
518 | @@ -398,17 +399,19 @@ | |||
519 | 398 | 399 | ||
520 | 399 | def create_libertine_container(self, password=None, multiarch=False): | 400 | def create_libertine_container(self, password=None, multiarch=False): |
521 | 400 | if self._try_get_container(): | 401 | if self._try_get_container(): |
523 | 401 | utils.get_logger().error("Container already exists") | 402 | utils.get_logger().error(utils._("Container already exists")) |
524 | 402 | return False | 403 | return False |
525 | 403 | 404 | ||
526 | 404 | update_libertine_profile(self._lxd_client) | 405 | update_libertine_profile(self._lxd_client) |
527 | 405 | 406 | ||
529 | 406 | utils.get_logger().info("Creating container '%s' with distro '%s'" % (self.container_id, self.installed_release)) | 407 | utils.get_logger().info(utils._("Creating container '{container_id}' with distro '{container_distro}'") |
530 | 408 | .format(container_id=self.container_id, container_distro=self.installed_release)) | ||
531 | 407 | create = subprocess.Popen(shlex.split('lxc launch ubuntu-daily:{distro} {id} --profile ' | 409 | create = subprocess.Popen(shlex.split('lxc launch ubuntu-daily:{distro} {id} --profile ' |
532 | 408 | 'default --profile libertine'.format( | 410 | 'default --profile libertine'.format( |
533 | 409 | distro=self.installed_release, id=self.container_id))) | 411 | distro=self.installed_release, id=self.container_id))) |
534 | 410 | if create.wait() is not 0: | 412 | if create.wait() is not 0: |
536 | 411 | utils.get_logger().error("Creating container '{}' failed with code '{}'".format(self.container_id, create.returncode)) | 413 | utils.get_logger().error(utils._("Creating container '{container_id}' failed with code '{error_code}'") |
537 | 414 | .format(container_id=self.container_id, error_code=create.returncode)) | ||
538 | 412 | return False | 415 | return False |
539 | 413 | 416 | ||
540 | 414 | self._try_get_container() | 417 | self._try_get_container() |
541 | @@ -431,15 +434,16 @@ | |||
542 | 431 | _setup_etc_hosts(self._container) | 434 | _setup_etc_hosts(self._container) |
543 | 432 | 435 | ||
544 | 433 | if multiarch and self.architecture == 'amd64': | 436 | if multiarch and self.architecture == 'amd64': |
546 | 434 | utils.get_logger().info("Adding i386 multiarch support to container '{}'".format(self.container_id)) | 437 | utils.get_logger().info(utils._("Adding i386 multiarch support to container '{container_id}'").format(container_id=self.container_id)) |
547 | 435 | self.run_in_container("dpkg --add-architecture i386") | 438 | self.run_in_container("dpkg --add-architecture i386") |
548 | 436 | 439 | ||
549 | 437 | self.update_packages() | 440 | self.update_packages() |
550 | 438 | 441 | ||
551 | 439 | for package in self.default_packages: | 442 | for package in self.default_packages: |
553 | 440 | utils.get_logger().info("Installing package '%s' in container '%s'" % (package, self.container_id)) | 443 | utils.get_logger().info(utils._("Installing package '{package_name}' in container '{container_id}'") |
554 | 444 | .format(package_name=package, container_id=self.container_id)) | ||
555 | 441 | if not self.install_package(package, no_dialog=True, update_cache=False): | 445 | if not self.install_package(package, no_dialog=True, update_cache=False): |
557 | 442 | utils.get_logger().error("Failure installing '%s' during container creation" % package) | 446 | utils.get_logger().error(utils._("Failure installing '{package_name}' during container creation").format(package_name=package)) |
558 | 443 | self.destroy_libertine_container() | 447 | self.destroy_libertine_container() |
559 | 444 | return False | 448 | return False |
560 | 445 | 449 | ||
561 | @@ -461,7 +465,7 @@ | |||
562 | 461 | 465 | ||
563 | 462 | def update_packages(self, update_locale=False): | 466 | def update_packages(self, update_locale=False): |
564 | 463 | if not self._timezone_in_sync(): | 467 | if not self._timezone_in_sync(): |
566 | 464 | utils.get_logger().info("Re-syncing timezones") | 468 | utils.get_logger().info(utils._("Re-syncing timezones")) |
567 | 465 | self.run_in_container("bash -c 'echo \"%s\" > /etc/timezone'" % self._host_info.get_host_timezone()) | 469 | self.run_in_container("bash -c 'echo \"%s\" > /etc/timezone'" % self._host_info.get_host_timezone()) |
568 | 466 | self.run_in_container("rm -f /etc/localtime") | 470 | self.run_in_container("rm -f /etc/localtime") |
569 | 467 | self.run_in_container("dpkg-reconfigure -f noninteractive tzdata") | 471 | self.run_in_container("dpkg-reconfigure -f noninteractive tzdata") |
570 | @@ -474,11 +478,11 @@ | |||
571 | 474 | 478 | ||
572 | 475 | def destroy_libertine_container(self, force): | 479 | def destroy_libertine_container(self, force): |
573 | 476 | if not self._try_get_container(): | 480 | if not self._try_get_container(): |
575 | 477 | utils.get_logger().error("No such container '%s'" % self.container_id) | 481 | utils.get_logger().error(utils._("No such container '{container_id}'").format(container_id=self.container_id)) |
576 | 478 | return False | 482 | return False |
577 | 479 | 483 | ||
578 | 480 | if self._container.status == 'Running' and not force: | 484 | if self._container.status == 'Running' and not force: |
580 | 481 | utils.get_logger().error("Canceling destruction due to running container. Use --force to override.") | 485 | utils.get_logger().error(utils._("Canceling destruction due to running container. Use --force to override.")) |
581 | 482 | return False | 486 | return False |
582 | 483 | 487 | ||
583 | 484 | lxd_start(self._container) | 488 | lxd_start(self._container) |
584 | @@ -526,7 +530,7 @@ | |||
585 | 526 | self._config.update_container_install_status(self.container_id, "running") | 530 | self._config.update_container_install_status(self.container_id, "running") |
586 | 527 | 531 | ||
587 | 528 | if not _wait_for_network(self._container): | 532 | if not _wait_for_network(self._container): |
589 | 529 | utils.get_logger().warning("Network unavailable in container '{}'".format(self.container_id)) | 533 | utils.get_logger().warning(utils._("Network unavailable in container '{container_id}'").format(container_id=self.container_id)) |
590 | 530 | 534 | ||
591 | 531 | if requires_remount: | 535 | if requires_remount: |
592 | 532 | self.run_in_container("/usr/bin/libertine-lxd-mount-update") | 536 | self.run_in_container("/usr/bin/libertine-lxd-mount-update") |
593 | @@ -555,7 +559,7 @@ | |||
594 | 555 | return False | 559 | return False |
595 | 556 | 560 | ||
596 | 557 | if self._container.status != 'Frozen': | 561 | if self._container.status != 'Frozen': |
598 | 558 | utils.get_logger().warning("Container {} is not frozen. Cannot restart.".format(self._container.name)) | 562 | utils.get_logger().warning(utils._("Container '{container_id}' is not frozen. Cannot restart.").format(container_id=self._container.name)) |
599 | 559 | return False | 563 | return False |
600 | 560 | 564 | ||
601 | 561 | if not (lxd_stop(self._container) and lxd_start(self._container)): | 565 | if not (lxd_stop(self._container) and lxd_start(self._container)): |
602 | @@ -565,7 +569,7 @@ | |||
603 | 565 | 569 | ||
604 | 566 | def start_application(self, app_exec_line, environ): | 570 | def start_application(self, app_exec_line, environ): |
605 | 567 | if not self._try_get_container(): | 571 | if not self._try_get_container(): |
607 | 568 | utils.get_logger().error("Could not get container '{}'".format(self.container_id)) | 572 | utils.get_logger().error(utils._("Could not get container '{container_id}'").format(container_id=self.container_id)) |
608 | 569 | return None | 573 | return None |
609 | 570 | 574 | ||
610 | 571 | if utils.is_snap_environment(): | 575 | if utils.is_snap_environment(): |
611 | 572 | 576 | ||
612 | === modified file 'python/libertine/launcher/config.py' | |||
613 | --- python/libertine/launcher/config.py 2017-02-07 16:32:02 +0000 | |||
614 | +++ python/libertine/launcher/config.py 2017-04-06 14:39:25 +0000 | |||
615 | @@ -23,10 +23,6 @@ | |||
616 | 23 | from .task import TaskType, TaskConfig | 23 | from .task import TaskType, TaskConfig |
617 | 24 | from .. import utils | 24 | from .. import utils |
618 | 25 | 25 | ||
619 | 26 | import gettext | ||
620 | 27 | gettext.textdomain('libertine') | ||
621 | 28 | _ = gettext.gettext | ||
622 | 29 | |||
623 | 30 | log = utils.get_logger() | 26 | log = utils.get_logger() |
624 | 31 | 27 | ||
625 | 32 | 28 | ||
626 | @@ -129,21 +125,21 @@ | |||
627 | 129 | 125 | ||
628 | 130 | """ | 126 | """ |
629 | 131 | log.debug('Config.__init__() begins') | 127 | log.debug('Config.__init__() begins') |
631 | 132 | arg_parser = argparse.ArgumentParser(description=_('Launch an application natively or in a Libertine container')) | 128 | arg_parser = argparse.ArgumentParser(description=utils._('Launch an application natively or in a Libertine container')) |
632 | 133 | arg_parser.add_argument('-i', '--id', | 129 | arg_parser.add_argument('-i', '--id', |
634 | 134 | help=_('Container identifier when launching containerized apps')) | 130 | help=utils._('Container identifier when launching containerized apps')) |
635 | 135 | arg_parser.add_argument('-E', '--env', | 131 | arg_parser.add_argument('-E', '--env', |
636 | 136 | default=[], | 132 | default=[], |
637 | 137 | dest='environ', | 133 | dest='environ', |
638 | 138 | action='append', | 134 | action='append', |
640 | 139 | help=_('Set an environment variable')) | 135 | help=utils._('Set an environment variable')) |
641 | 140 | arg_parser.add_argument('app_exec_line', | 136 | arg_parser.add_argument('app_exec_line', |
642 | 141 | nargs=argparse.REMAINDER, | 137 | nargs=argparse.REMAINDER, |
644 | 142 | help=_('exec line')) | 138 | help=utils._('exec line')) |
645 | 143 | options = arg_parser.parse_args(args=argv) | 139 | options = arg_parser.parse_args(args=argv) |
646 | 144 | 140 | ||
647 | 145 | if not options.app_exec_line: | 141 | if not options.app_exec_line: |
649 | 146 | arg_parser.error('Must specify an exec line') | 142 | arg_parser.error(utils._('Must specify an exec line')) |
650 | 147 | 143 | ||
651 | 148 | if options.id: | 144 | if options.id: |
652 | 149 | self.container_id = options.id | 145 | self.container_id = options.id |
653 | 150 | 146 | ||
654 | === modified file 'python/libertine/launcher/session.py' | |||
655 | --- python/libertine/launcher/session.py 2017-02-23 18:18:29 +0000 | |||
656 | +++ python/libertine/launcher/session.py 2017-04-06 14:39:25 +0000 | |||
657 | @@ -100,7 +100,7 @@ | |||
658 | 100 | to_socket.sendall(b) | 100 | to_socket.sendall(b) |
659 | 101 | utils.get_logger().debug('copied {} bytes from fd to {}'.format(len(b), from_socket, to_socket)) | 101 | utils.get_logger().debug('copied {} bytes from fd to {}'.format(len(b), from_socket, to_socket)) |
660 | 102 | else: | 102 | else: |
662 | 103 | utils.get_logger().info('close detected on {}'.format(from_socket)) | 103 | utils.get_logger().info(utils._('close detected on {socket}').format(socket=from_socket)) |
663 | 104 | return len(b) | 104 | return len(b) |
664 | 105 | except Exception as e: | 105 | except Exception as e: |
665 | 106 | utils.get_logger().debug(e) | 106 | utils.get_logger().debug(e) |
666 | @@ -169,7 +169,7 @@ | |||
667 | 169 | with suppress(AttributeError): | 169 | with suppress(AttributeError): |
668 | 170 | for task_config in self._config.prelaunch_tasks: | 170 | for task_config in self._config.prelaunch_tasks: |
669 | 171 | if task_config.task_type == TaskType.LAUNCH_SERVICE: | 171 | if task_config.task_type == TaskType.LAUNCH_SERVICE: |
671 | 172 | utils.get_logger().info("launching {}".format(task_config.datum[0])) | 172 | utils.get_logger().info(utils._("launching {launch_task}").format(launch_task=task_config.datum[0])) |
672 | 173 | task = LaunchServiceTask(task_config) | 173 | task = LaunchServiceTask(task_config) |
673 | 174 | self._child_processes.append(task) | 174 | self._child_processes.append(task) |
674 | 175 | task.start(self._config.host_environ) | 175 | task.start(self._config.host_environ) |
675 | @@ -329,17 +329,17 @@ | |||
676 | 329 | data = os.read(fd, 4) | 329 | data = os.read(fd, 4) |
677 | 330 | sig = struct.unpack('%uB' % len(data), data) | 330 | sig = struct.unpack('%uB' % len(data), data) |
678 | 331 | if sig[0] == signal.SIGCHLD: | 331 | if sig[0] == signal.SIGCHLD: |
680 | 332 | utils.get_logger().info('SIGCHLD received') | 332 | utils.get_logger().info(utils._('SIGCHLD received')) |
681 | 333 | if self._handle_child_died(): | 333 | if self._handle_child_died(): |
683 | 334 | raise StopIteration('launched program exited') | 334 | raise StopIteration(utils._('launched program exited')) |
684 | 335 | elif sig[0] == signal.SIGINT: | 335 | elif sig[0] == signal.SIGINT: |
687 | 336 | utils.get_logger().info('SIGINT received') | 336 | utils.get_logger().info(utils._('SIGINT received')) |
688 | 337 | raise StopIteration('keyboard interrupt') | 337 | raise StopIteration(utils._('keyboard interrupt')) |
689 | 338 | elif sig[0] == signal.SIGTERM: | 338 | elif sig[0] == signal.SIGTERM: |
692 | 339 | utils.get_logger().info('SIGTERM received') | 339 | utils.get_logger().info(utils._('SIGTERM received')) |
693 | 340 | raise StopIteration('terminate') | 340 | raise StopIteration(utils._('terminate')) |
694 | 341 | else: | 341 | else: |
696 | 342 | utils.get_logger().warning('unknown signal {} received'.format(sig[0])) | 342 | utils.get_logger().warning(utils._('unknown signal {signal} received').format(signal=sig[0])) |
697 | 343 | 343 | ||
698 | 344 | def _set_signal_handlers(self): | 344 | def _set_signal_handlers(self): |
699 | 345 | """Set the signal handlers.""" | 345 | """Set the signal handlers.""" |
700 | 346 | 346 | ||
701 | === modified file 'python/libertine/service/container.py' | |||
702 | --- python/libertine/service/container.py 2017-03-16 19:59:08 +0000 | |||
703 | +++ python/libertine/service/container.py 2017-04-06 14:39:25 +0000 | |||
704 | @@ -16,7 +16,6 @@ | |||
705 | 16 | from libertine import utils | 16 | from libertine import utils |
706 | 17 | from threading import Lock | 17 | from threading import Lock |
707 | 18 | 18 | ||
708 | 19 | |||
709 | 20 | if not utils.is_snap_environment(): | 19 | if not utils.is_snap_environment(): |
710 | 21 | from libertine.service import apt | 20 | from libertine.service import apt |
711 | 22 | 21 | ||
712 | @@ -33,7 +32,7 @@ | |||
713 | 33 | self._tasks = [] | 32 | self._tasks = [] |
714 | 34 | 33 | ||
715 | 35 | if utils.is_snap_environment(): | 34 | if utils.is_snap_environment(): |
717 | 36 | utils.get_logger().warning("Using AptCache not currently supported in snap environment") | 35 | utils.get_logger().warning(utils._("Using AptCache not currently supported in snap environment")) |
718 | 37 | self._cache = None | 36 | self._cache = None |
719 | 38 | else: | 37 | else: |
720 | 39 | self._cache = apt.AptCache(self.id) | 38 | self._cache = apt.AptCache(self.id) |
721 | 40 | 39 | ||
722 | === modified file 'python/libertine/service/container_control_client.py' | |||
723 | --- python/libertine/service/container_control_client.py 2017-03-09 14:40:58 +0000 | |||
724 | +++ python/libertine/service/container_control_client.py 2017-04-06 14:39:25 +0000 | |||
725 | @@ -40,7 +40,7 @@ | |||
726 | 40 | else: | 40 | else: |
727 | 41 | raise | 41 | raise |
728 | 42 | except: | 42 | except: |
730 | 43 | utils.get_logger().error("Container app {} is not valid.".format(app['appExecName'])) | 43 | utils.get_logger().error(utils._("Container app '{application_name}' is not valid.").format(application_name=app['appExecName'])) |
731 | 44 | if container not in self._invalid_apps: | 44 | if container not in self._invalid_apps: |
732 | 45 | self._invalid_apps[container] = [{app['appExecName'], app['pid']}] | 45 | self._invalid_apps[container] = [{app['appExecName'], app['pid']}] |
733 | 46 | else: | 46 | else: |
734 | 47 | 47 | ||
735 | === modified file 'python/libertine/utils.py' | |||
736 | --- python/libertine/utils.py 2017-02-15 21:12:37 +0000 | |||
737 | +++ python/libertine/utils.py 2017-04-06 14:39:25 +0000 | |||
738 | @@ -22,6 +22,10 @@ | |||
739 | 22 | import subprocess | 22 | import subprocess |
740 | 23 | import xdg.BaseDirectory as basedir | 23 | import xdg.BaseDirectory as basedir |
741 | 24 | 24 | ||
742 | 25 | import gettext | ||
743 | 26 | gettext.textdomain('libertine') | ||
744 | 27 | _ = gettext.gettext | ||
745 | 28 | |||
746 | 25 | 29 | ||
747 | 26 | def get_logger(): | 30 | def get_logger(): |
748 | 27 | logger = logging.getLogger('__libertine_logger__') | 31 | logger = logging.getLogger('__libertine_logger__') |
749 | @@ -174,7 +178,7 @@ | |||
750 | 174 | except psutil.NoSuchProcess as e: | 178 | except psutil.NoSuchProcess as e: |
751 | 175 | get_logger().warning(str(e)) | 179 | get_logger().warning(str(e)) |
752 | 176 | except subprocess.CalledProcessError as e: | 180 | except subprocess.CalledProcessError as e: |
754 | 177 | get_logger().warning("Exception caught while setting session dbus address: {}".format(str(e))) | 181 | get_logger().warning(utils._("Exception caught while setting session dbus address: {error}").format(error=str(e))) |
755 | 178 | dbus_session_set = 'DBUS_SESSION_BUS_ADDRESS' in os.environ | 182 | dbus_session_set = 'DBUS_SESSION_BUS_ADDRESS' in os.environ |
756 | 179 | 183 | ||
757 | 180 | return dbus_session_set | 184 | return dbus_session_set |
758 | 181 | 185 | ||
759 | === modified file 'tools/libertine-container-manager' | |||
760 | --- tools/libertine-container-manager 2017-03-23 16:02:52 +0000 | |||
761 | +++ tools/libertine-container-manager 2017-04-06 14:39:25 +0000 | |||
762 | @@ -19,16 +19,11 @@ | |||
763 | 19 | import argparse | 19 | import argparse |
764 | 20 | import getpass | 20 | import getpass |
765 | 21 | import json | 21 | import json |
766 | 22 | import libertine.utils | ||
767 | 23 | import os | 22 | import os |
768 | 24 | import sys | 23 | import sys |
769 | 25 | import re | 24 | import re |
770 | 26 | 25 | ||
776 | 27 | import gettext | 26 | from libertine import ContainerRunning, LibertineContainer, utils |
772 | 28 | gettext.textdomain('libertine') | ||
773 | 29 | _ = gettext.gettext | ||
774 | 30 | |||
775 | 31 | from libertine import ContainerRunning, LibertineContainer | ||
777 | 32 | from libertine.ContainersConfig import ContainersConfig | 27 | from libertine.ContainersConfig import ContainersConfig |
778 | 33 | from libertine.HostInfo import HostInfo | 28 | from libertine.HostInfo import HostInfo |
779 | 34 | 29 | ||
780 | @@ -45,7 +40,7 @@ | |||
781 | 45 | return LibertineContainer(container_id, self.containers_config) | 40 | return LibertineContainer(container_id, self.containers_config) |
782 | 46 | except ImportError as e: | 41 | except ImportError as e: |
783 | 47 | container_type = self.containers_config.get_container_type(container_id) | 42 | container_type = self.containers_config.get_container_type(container_id) |
785 | 48 | libertine.utils.get_logger().error(_("Backend for container '{id}' not installed. Install " | 43 | utils.get_logger().error(utils._("Backend for container '{id}' not installed. Install " |
786 | 49 | "'python3-libertine-{type}' and try again.").format(id=container_id, type=container_type)) | 44 | "'python3-libertine-{type}' and try again.").format(id=container_id, type=container_type)) |
787 | 50 | sys.exit(1) | 45 | sys.exit(1) |
788 | 51 | 46 | ||
789 | @@ -61,14 +56,15 @@ | |||
790 | 61 | password = None | 56 | password = None |
791 | 62 | 57 | ||
792 | 63 | if args.distro and not self.host_info.is_distro_valid(args.distro, args.force): | 58 | if args.distro and not self.host_info.is_distro_valid(args.distro, args.force): |
794 | 64 | libertine.utils.get_logger().error("Invalid distro %s" % args.distro) | 59 | utils.get_logger().error(utils._("Invalid distro {distro}").format(distro=args.distro)) |
795 | 65 | sys.exit(1) | 60 | sys.exit(1) |
796 | 66 | 61 | ||
797 | 67 | if self.containers_config.container_exists(args.id): | 62 | if self.containers_config.container_exists(args.id): |
799 | 68 | libertine.utils.get_logger().error("Container id '%s' is already used." % args.id) | 63 | utils.get_logger().error(utils._("Container id '{container_id}' is already used.").format(container_id=args.id)) |
800 | 69 | sys.exit(1) | 64 | sys.exit(1) |
801 | 70 | elif re.match("^[a-z0-9][a-z0-9+.-]+$", args.id) is None: | 65 | elif re.match("^[a-z0-9][a-z0-9+.-]+$", args.id) is None: |
803 | 71 | libertine.utils.get_logger().error("Container id '%s' invalid. ID must be of form ([a-z0-9][a-z0-9+.-]+)." % args.id) | 66 | utils.get_logger().error(utils._("Container id '{container_id}' invalid. ID must be of " |
804 | 67 | "form ([a-z0-9][a-z0-9+.-]+).").format(container_id=args.id)) | ||
805 | 72 | sys.exit(1) | 68 | sys.exit(1) |
806 | 73 | 69 | ||
807 | 74 | if not args.type: | 70 | if not args.type: |
808 | @@ -76,8 +72,8 @@ | |||
809 | 76 | else: | 72 | else: |
810 | 77 | if (args.type == 'lxc' and not self.host_info.has_lxc_support()) or \ | 73 | if (args.type == 'lxc' and not self.host_info.has_lxc_support()) or \ |
811 | 78 | (args.type == 'lxd' and not self.host_info.has_lxd_support()): | 74 | (args.type == 'lxd' and not self.host_info.has_lxd_support()): |
814 | 79 | libertine.utils.get_logger().error("System kernel does not support %s type containers. " | 75 | utils.get_logger().error(utils._("System kernel does not support {container_type} type containers. " |
815 | 80 | "Please either use chroot or omit the -t option." % args.type) | 76 | "Please either use chroot or omit the -t option.").format(container_type=args.type)) |
816 | 81 | sys.exit(1) | 77 | sys.exit(1) |
817 | 82 | container_type = args.type | 78 | container_type = args.type |
818 | 83 | 79 | ||
819 | @@ -87,9 +83,9 @@ | |||
820 | 87 | host_distro = self.host_info.get_host_distro_release() | 83 | host_distro = self.host_info.get_host_distro_release() |
821 | 88 | 84 | ||
822 | 89 | if args.distro != host_distro: | 85 | if args.distro != host_distro: |
826 | 90 | libertine.utils.get_logger().error("The container distribution needs to match the host ditribution for chroot" | 86 | utils.get_logger().error(utils._("The container distribution needs to match the host ditribution for chroot" |
827 | 91 | " based containers. Please either use \'%s\' or omit the -d/--distro option." | 87 | " based containers. Please either use '{host_distro}' or" |
828 | 92 | % host_distro) | 88 | " omit the -d/--distro option.").format(host_distro=host_distro)) |
829 | 93 | sys.exit(1) | 89 | sys.exit(1) |
830 | 94 | 90 | ||
831 | 95 | if not args.name: | 91 | if not args.name: |
832 | @@ -99,7 +95,7 @@ | |||
833 | 99 | if args.password: | 95 | if args.password: |
834 | 100 | password = args.password | 96 | password = args.password |
835 | 101 | elif sys.stdin.isatty(): | 97 | elif sys.stdin.isatty(): |
837 | 102 | print("Enter password for your user in the Libertine container or leave blank for no password:") | 98 | print(utils._("Enter password for your user in the Libertine container or leave blank for no password:")) |
838 | 103 | password = getpass.getpass() | 99 | password = getpass.getpass() |
839 | 104 | else: | 100 | else: |
840 | 105 | password = sys.stdin.readline().rstrip() | 101 | password = sys.stdin.readline().rstrip() |
841 | @@ -117,21 +113,21 @@ | |||
842 | 117 | try: | 113 | try: |
843 | 118 | self.containers_config.update_container_install_status(args.id, "installing") | 114 | self.containers_config.update_container_install_status(args.id, "installing") |
844 | 119 | if not container.create_libertine_container(password, args.multiarch): | 115 | if not container.create_libertine_container(password, args.multiarch): |
846 | 120 | libertine.utils.get_logger().error("Failed to create container") | 116 | utils.get_logger().error(utils._("Failed to create container")) |
847 | 121 | self.containers_config.delete_container(args.id) | 117 | self.containers_config.delete_container(args.id) |
848 | 122 | sys.exit(1) | 118 | sys.exit(1) |
849 | 123 | except Exception as e: | 119 | except Exception as e: |
850 | 124 | container.destroy_libertine_container(force=True) | 120 | container.destroy_libertine_container(force=True) |
851 | 125 | raise | 121 | raise |
852 | 126 | except Exception as e: | 122 | except Exception as e: |
854 | 127 | libertine.utils.get_logger().error("Failed to create container: '{}'".format(str(e))) | 123 | utils.get_logger().error(utils._("Failed to create container: '{error}'").format(error=str(e))) |
855 | 128 | 124 | ||
856 | 129 | self.containers_config.delete_container(args.id) | 125 | self.containers_config.delete_container(args.id) |
857 | 130 | sys.exit(1) | 126 | sys.exit(1) |
858 | 131 | 127 | ||
859 | 132 | self.containers_config.update_container_install_status(args.id, "ready") | 128 | self.containers_config.update_container_install_status(args.id, "ready") |
860 | 133 | 129 | ||
862 | 134 | libertine.utils.refresh_libertine_scope() | 130 | utils.refresh_libertine_scope() |
863 | 135 | 131 | ||
864 | 136 | def destroy_container(self, container, force): | 132 | def destroy_container(self, container, force): |
865 | 137 | fallback = self.containers_config.get_container_install_status(container.container_id) | 133 | fallback = self.containers_config.get_container_install_status(container.container_id) |
866 | @@ -150,7 +146,7 @@ | |||
867 | 150 | 146 | ||
868 | 151 | self.destroy_container(container, args.force) | 147 | self.destroy_container(container, args.force) |
869 | 152 | 148 | ||
871 | 153 | libertine.utils.refresh_libertine_scope() | 149 | utils.refresh_libertine_scope() |
872 | 154 | 150 | ||
873 | 155 | def install_package(self, args): | 151 | def install_package(self, args): |
874 | 156 | container_id = self.containers_config.check_container_id(args.id) | 152 | container_id = self.containers_config.check_container_id(args.id) |
875 | @@ -166,9 +162,9 @@ | |||
876 | 166 | 162 | ||
877 | 167 | if is_debian_package: | 163 | if is_debian_package: |
878 | 168 | if os.path.exists(pkg): | 164 | if os.path.exists(pkg): |
880 | 169 | package = libertine.utils.get_deb_package_name(pkg) | 165 | package = utils.get_deb_package_name(pkg) |
881 | 170 | else: | 166 | else: |
883 | 171 | libertine.utils.get_logger().error("%s does not exist." % pkg) | 167 | utils.get_logger().error(utils._("{package_name} does not exist.").format(package_name=pkg)) |
884 | 172 | failure = True | 168 | failure = True |
885 | 173 | continue | 169 | continue |
886 | 174 | else: | 170 | else: |
887 | @@ -176,7 +172,7 @@ | |||
888 | 176 | 172 | ||
889 | 177 | if self.containers_config.package_exists(container_id, package): | 173 | if self.containers_config.package_exists(container_id, package): |
890 | 178 | if not is_debian_package: | 174 | if not is_debian_package: |
892 | 179 | libertine.utils.get_logger().error("Package '%s' is already installed." % package) | 175 | utils.get_logger().error(utils._("Package '{package_name}' is already installed.").format(package_name=package)) |
893 | 180 | failure = True | 176 | failure = True |
894 | 181 | continue | 177 | continue |
895 | 182 | else: | 178 | else: |
896 | @@ -184,15 +180,15 @@ | |||
897 | 184 | 180 | ||
898 | 185 | self.containers_config.update_package_install_status(container_id, package, "installing") | 181 | self.containers_config.update_package_install_status(container_id, package, "installing") |
899 | 186 | if not container.install_package(pkg, args.no_dialog, update_cache=i==0): | 182 | if not container.install_package(pkg, args.no_dialog, update_cache=i==0): |
902 | 187 | libertine.utils.get_logger().error("Package '{}' failed to install in container '{}'" | 183 | utils.get_logger().error(utils._("Package '{package_name}' failed to install in container '{container_id}'") |
903 | 188 | .format(package, container_id)) | 184 | .format(package_name=package, container_id=container_id)) |
904 | 189 | self.containers_config.delete_package(container_id, package) | 185 | self.containers_config.delete_package(container_id, package) |
905 | 190 | failure = True | 186 | failure = True |
906 | 191 | continue | 187 | continue |
907 | 192 | 188 | ||
908 | 193 | self.containers_config.update_package_install_status(container_id, package, "installed") | 189 | self.containers_config.update_package_install_status(container_id, package, "installed") |
909 | 194 | 190 | ||
911 | 195 | libertine.utils.refresh_libertine_scope() | 191 | utils.refresh_libertine_scope() |
912 | 196 | 192 | ||
913 | 197 | if failure: | 193 | if failure: |
914 | 198 | sys.exit(1) | 194 | sys.exit(1) |
915 | @@ -221,17 +217,17 @@ | |||
916 | 221 | continue | 217 | continue |
917 | 222 | 218 | ||
918 | 223 | if self.containers_config.get_package_install_status(container_id, pkg) != 'installed': | 219 | if self.containers_config.get_package_install_status(container_id, pkg) != 'installed': |
920 | 224 | libertine.utils.get_logger().error("Package \'%s\' is not installed." % pkg) | 220 | utils.get_logger().error(utils._("Package '{package_name}' is not installed.").format(package_name=pkg)) |
921 | 225 | failure = True | 221 | failure = True |
922 | 226 | continue | 222 | continue |
923 | 227 | 223 | ||
924 | 228 | if not self.remove_package_by_name(container, pkg, args.no_dialog): | 224 | if not self.remove_package_by_name(container, pkg, args.no_dialog): |
927 | 229 | libertine.utils.get_logger().error("Package '{}' failed to be removed from container '{}'" | 225 | utils.get_logger().error(utils._("Package '{package_name}' failed to be removed from container '{container_id}'") |
928 | 230 | .format(pkg, container_id)) | 226 | .format(package_name=pkg, container_id=container_id)) |
929 | 231 | failure = True | 227 | failure = True |
930 | 232 | continue | 228 | continue |
931 | 233 | 229 | ||
933 | 234 | libertine.utils.refresh_libertine_scope() | 230 | utils.refresh_libertine_scope() |
934 | 235 | 231 | ||
935 | 236 | if failure: | 232 | if failure: |
936 | 237 | sys.exit(1) | 233 | sys.exit(1) |
937 | @@ -241,8 +237,8 @@ | |||
938 | 241 | container = self._container(container_id) | 237 | container = self._container(container_id) |
939 | 242 | 238 | ||
940 | 243 | if container.search_package_cache(args.search_string) is not 0: | 239 | if container.search_package_cache(args.search_string) is not 0: |
943 | 244 | libertine.utils.get_logger().error("Search for '{}' in container '{}' exited with non-zero status" | 240 | utils.get_logger().error(utils._("Search for '{query_string}' in container '{container_id}' exited with non-zero status") |
944 | 245 | .format(args.id, args.search_string)) | 241 | .format(container_id=args.id, query_string=args.search_string)) |
945 | 246 | sys.exit(1) | 242 | sys.exit(1) |
946 | 247 | 243 | ||
947 | 248 | def update(self, args): | 244 | def update(self, args): |
948 | @@ -300,7 +296,7 @@ | |||
949 | 300 | 296 | ||
950 | 301 | current_multiarch = self.containers_config.get_container_multiarch_support(container_id) | 297 | current_multiarch = self.containers_config.get_container_multiarch_support(container_id) |
951 | 302 | if current_multiarch == multiarch: | 298 | if current_multiarch == multiarch: |
953 | 303 | libertine.utils.get_logger().error("i386 multiarch support is already %s" % multiarch) | 299 | utils.get_logger().error(utils._("i386 multiarch support is already {enabled_or_disabled}").format(enabled_or_disabled=multiarch)) |
954 | 304 | sys.exit(1) | 300 | sys.exit(1) |
955 | 305 | 301 | ||
956 | 306 | if container.configure_multiarch(args.multiarch) is not 0: | 302 | if container.configure_multiarch(args.multiarch) is not 0: |
957 | @@ -310,7 +306,7 @@ | |||
958 | 310 | 306 | ||
959 | 311 | elif args.archive is not None: | 307 | elif args.archive is not None: |
960 | 312 | if args.archive_name is None: | 308 | if args.archive_name is None: |
962 | 313 | libertine.utils.get_logger().error("Configure archive called with no archive name. See configure --help for usage.") | 309 | utils.get_logger().error(utils._("Configure archive called with no archive name. See configure --help for usage.")) |
963 | 314 | sys.exit(1) | 310 | sys.exit(1) |
964 | 315 | 311 | ||
965 | 316 | archive_name = args.archive_name.strip("\'\"") | 312 | archive_name = args.archive_name.strip("\'\"") |
966 | @@ -318,7 +314,7 @@ | |||
967 | 318 | 314 | ||
968 | 319 | if args.archive == 'add': | 315 | if args.archive == 'add': |
969 | 320 | if self.containers_config.archive_exists(container_id, archive_name): | 316 | if self.containers_config.archive_exists(container_id, archive_name): |
971 | 321 | libertine.utils.get_logger().error("%s already added in container." % archive_name) | 317 | utils.get_logger().error(utils._("{archive_name} already added in container.").format(archive_name=archive_name)) |
972 | 322 | sys.exit(1) | 318 | sys.exit(1) |
973 | 323 | 319 | ||
974 | 324 | self.containers_config.add_container_archive(container_id, archive_name) | 320 | self.containers_config.add_container_archive(container_id, archive_name) |
975 | @@ -331,43 +327,48 @@ | |||
976 | 331 | 327 | ||
977 | 332 | elif args.archive == 'remove': | 328 | elif args.archive == 'remove': |
978 | 333 | if not self.containers_config.archive_exists(container_id, archive_name): | 329 | if not self.containers_config.archive_exists(container_id, archive_name): |
980 | 334 | libertine.utils.get_logger().error("%s is not added in container." % archive_name) | 330 | utils.get_logger().error(utils._("{archive_name} is not added in container.").format(archive_name=archive_name)) |
981 | 335 | sys.exit(1) | 331 | sys.exit(1) |
982 | 336 | 332 | ||
983 | 337 | if not self.delete_archive_by_name(container, archive_name): | 333 | if not self.delete_archive_by_name(container, archive_name): |
984 | 338 | 334 | ||
986 | 339 | libertine.utils.get_logger().error("%s was not properly deleted." % archive_name) | 335 | utils.get_logger().error(utils._("{archive_name} was not properly deleted.").format(archive_name=archive_name)) |
987 | 340 | sys.exit(1) | 336 | sys.exit(1) |
988 | 341 | 337 | ||
989 | 342 | elif args.bind_mount is not None: | 338 | elif args.bind_mount is not None: |
990 | 343 | if args.mount_path is None: | 339 | if args.mount_path is None: |
992 | 344 | libertine.utils.get_logger().error("Configure bind-mounts called without mount path. See configure --help for usage") | 340 | utils.get_logger().error(utils._("Configure bind-mounts called without mount path. See configure --help for usage")) |
993 | 345 | sys.exit(1) | 341 | sys.exit(1) |
994 | 346 | 342 | ||
995 | 347 | mount_path = args.mount_path.rstrip('/').strip('"') | 343 | mount_path = args.mount_path.rstrip('/').strip('"') |
996 | 348 | 344 | ||
997 | 349 | # validate bind-mount | 345 | # validate bind-mount |
998 | 350 | if not mount_path.startswith(os.environ['HOME']) and not mount_path.startswith('/media/%s' % os.environ['USER']): | 346 | if not mount_path.startswith(os.environ['HOME']) and not mount_path.startswith('/media/%s' % os.environ['USER']): |
1000 | 351 | libertine.utils.get_logger().error("Cannot mount {}, mount path must be in {} or /media/{}.".format(mount_path, os.environ['HOME'], os.environ['USER'])) | 347 | utils.get_logger().error(utils._("Cannot mount {mount_path}, mount path must be in {home_dir} or " |
1001 | 348 | "/media/{username}.").format(mount_path=mount_path, \ | ||
1002 | 349 | home_dir=os.environ['HOME'], username=os.environ['USER'])) | ||
1003 | 352 | sys.exit(1) | 350 | sys.exit(1) |
1004 | 353 | if mount_path.startswith('/media/%s' % os.environ['USER']) and \ | 351 | if mount_path.startswith('/media/%s' % os.environ['USER']) and \ |
1005 | 354 | self.containers_config.get_container_type(container_id) == 'lxc': | 352 | self.containers_config.get_container_type(container_id) == 'lxc': |
1007 | 355 | libertine.utils.get_logger().error("/media mounts not currently supported in lxc.") | 353 | utils.get_logger().error(utils._("/media mounts not currently supported in lxc.")) |
1008 | 356 | sys.exit(1) | 354 | sys.exit(1) |
1009 | 357 | if not os.path.isdir(mount_path): | 355 | if not os.path.isdir(mount_path): |
1011 | 358 | libertine.utils.get_logger().error("Cannot mount '%s', mount path must be an existing directory." % mount_path) | 356 | utils.get_logger().error(utils._("Cannot mount '{mount_path}', mount path must be an existing " |
1012 | 357 | "directory.").format(mount_path=mount_path)) | ||
1013 | 359 | sys.exit(1) | 358 | sys.exit(1) |
1014 | 360 | 359 | ||
1015 | 361 | # update database with new bind-mount | 360 | # update database with new bind-mount |
1016 | 362 | container_bind_mounts = self.containers_config.get_container_bind_mounts(container_id) | 361 | container_bind_mounts = self.containers_config.get_container_bind_mounts(container_id) |
1017 | 363 | if args.bind_mount == 'add': | 362 | if args.bind_mount == 'add': |
1018 | 364 | if mount_path in container_bind_mounts: | 363 | if mount_path in container_bind_mounts: |
1020 | 365 | libertine.utils.get_logger().error("Cannot add mount '%s', bind-mount already exists." % mount_path) | 364 | utils.get_logger().error(utils._("Cannot add mount '{mount_path}', bind-mount " |
1021 | 365 | "already exists.").format(mount_path=mount_path)) | ||
1022 | 366 | sys.exit(1) | 366 | sys.exit(1) |
1023 | 367 | self.containers_config.add_new_bind_mount(container_id, mount_path) | 367 | self.containers_config.add_new_bind_mount(container_id, mount_path) |
1024 | 368 | elif args.bind_mount == 'remove': | 368 | elif args.bind_mount == 'remove': |
1025 | 369 | if mount_path not in container_bind_mounts: | 369 | if mount_path not in container_bind_mounts: |
1027 | 370 | libertine.utils.get_logger().error("Cannot remove mount '%s', bind-mount does not exist." % mount_path) | 370 | utils.get_logger().error(utils._("Cannot remove mount '{mount_path}', bind-mount " |
1028 | 371 | "does not exist.").format(mount_path=mount_path)) | ||
1029 | 371 | sys.exit(1) | 372 | sys.exit(1) |
1030 | 372 | self.containers_config.delete_bind_mount(container_id, mount_path) | 373 | self.containers_config.delete_bind_mount(container_id, mount_path) |
1031 | 373 | 374 | ||
1032 | @@ -376,20 +377,20 @@ | |||
1033 | 376 | if (container_type == 'lxc' or container_type == 'lxd' and | 377 | if (container_type == 'lxc' or container_type == 'lxd' and |
1034 | 377 | self.containers_config.get_freeze_on_stop(container_id)): | 378 | self.containers_config.get_freeze_on_stop(container_id)): |
1035 | 378 | if not container.restart_libertine_container(): | 379 | if not container.restart_libertine_container(): |
1038 | 379 | libertine.utils.get_logger().warning("Container cannot be restarted at this time. You will need to " | 380 | utils.get_logger().warning(utils._("Container cannot be restarted at this time. You will need to " |
1039 | 380 | "restart the container at a later time using the \'restart\' subcommand.") | 381 | "restart the container at a later time using the 'restart' subcommand.")) |
1040 | 381 | 382 | ||
1041 | 382 | elif args.freeze is not None: | 383 | elif args.freeze is not None: |
1042 | 383 | container_type = self.containers_config.get_container_type(container_id) | 384 | container_type = self.containers_config.get_container_type(container_id) |
1043 | 384 | 385 | ||
1044 | 385 | if container_type != 'lxc' and container_type != 'lxd': | 386 | if container_type != 'lxc' and container_type != 'lxd': |
1046 | 386 | libertine.utils.get_logger().error("Configuring freeze is only valid on LXC and LXD container types.") | 387 | utils.get_logger().error(utils._("Configuring freeze is only valid on LXC and LXD container types.")) |
1047 | 387 | sys.exit(1) | 388 | sys.exit(1) |
1048 | 388 | 389 | ||
1049 | 389 | self.containers_config.update_freeze_on_stop(container_id, args.freeze == 'enable') | 390 | self.containers_config.update_freeze_on_stop(container_id, args.freeze == 'enable') |
1050 | 390 | 391 | ||
1051 | 391 | else: | 392 | else: |
1053 | 392 | libertine.utils.get_logger().error("Configure called with no subcommand. See configure --help for usage.") | 393 | utils.get_logger().error(utils._("Configure called with no subcommand. See configure --help for usage.")) |
1054 | 393 | sys.exit(1) | 394 | sys.exit(1) |
1055 | 394 | 395 | ||
1056 | 395 | 396 | ||
1057 | @@ -430,7 +431,7 @@ | |||
1058 | 430 | container_type = self.containers_config.get_container_type(container_id) | 431 | container_type = self.containers_config.get_container_type(container_id) |
1059 | 431 | 432 | ||
1060 | 432 | if container_type != 'lxc' and container_type != 'lxd': | 433 | if container_type != 'lxc' and container_type != 'lxd': |
1062 | 433 | libertine.utils.get_logger().error("The restart subcommand is only valid for LXC and LXD type containers.") | 434 | utils.get_logger().error(utils._("The restart subcommand is only valid for LXC and LXD type containers.")) |
1063 | 434 | sys.exit(1) | 435 | sys.exit(1) |
1064 | 435 | 436 | ||
1065 | 436 | container = self._container(container_id) | 437 | container = self._container(container_id) |
1066 | @@ -439,20 +440,20 @@ | |||
1067 | 439 | 440 | ||
1068 | 440 | 441 | ||
1069 | 441 | if __name__ == '__main__': | 442 | if __name__ == '__main__': |
1071 | 442 | parser = argparse.ArgumentParser(description="Legacy X application support for Unity 8") | 443 | parser = argparse.ArgumentParser(description=utils._("Classic X application support for Unity 8")) |
1072 | 443 | 444 | ||
1073 | 444 | if not os.geteuid(): | 445 | if not os.geteuid(): |
1075 | 445 | libertine.utils.get_logger().error("Please do not run %s using sudo" % parser.prog) | 446 | utils.get_logger().error(utils._("Please do not run '{program_name}' using sudo").format(program_name=parser.prog)) |
1076 | 446 | sys.exit(1) | 447 | sys.exit(1) |
1077 | 447 | 448 | ||
1078 | 448 | container_manager = LibertineContainerManager() | 449 | container_manager = LibertineContainerManager() |
1079 | 449 | 450 | ||
1080 | 450 | parser.add_argument('-q', '--quiet', | 451 | parser.add_argument('-q', '--quiet', |
1081 | 451 | action='store_const', dest='verbosity', const=0, | 452 | action='store_const', dest='verbosity', const=0, |
1083 | 452 | help=('disables all non-vital output')) | 453 | help=utils._('disables all non-vital output')) |
1084 | 453 | parser.add_argument('-v', '--verbosity', | 454 | parser.add_argument('-v', '--verbosity', |
1085 | 454 | action='store_const', dest='verbosity', const=2, | 455 | action='store_const', dest='verbosity', const=2, |
1087 | 455 | help=('enables debug output')) | 456 | help=utils._('enables debug output')) |
1088 | 456 | subparsers = parser.add_subparsers(dest="subparser_name", | 457 | subparsers = parser.add_subparsers(dest="subparser_name", |
1089 | 457 | title="subcommands", | 458 | title="subcommands", |
1090 | 458 | metavar='create, destroy, install-package, remove-package, search-cache, update, list, list-apps, configure') | 459 | metavar='create, destroy, install-package, remove-package, search-cache, update, list, list-apps, configure') |
1091 | @@ -460,186 +461,186 @@ | |||
1092 | 460 | # Handle the create command and its options | 461 | # Handle the create command and its options |
1093 | 461 | parser_create = subparsers.add_parser( | 462 | parser_create = subparsers.add_parser( |
1094 | 462 | 'create', | 463 | 'create', |
1096 | 463 | help=("Create a new Libertine container.")) | 464 | help=utils._("Create a new Libertine container.")) |
1097 | 464 | parser_create.add_argument( | 465 | parser_create.add_argument( |
1098 | 465 | '-i', '--id', | 466 | '-i', '--id', |
1099 | 466 | required=True, | 467 | required=True, |
1101 | 467 | help=("Container identifier of form ([a-z0-9][a-z0-9+.-]+). Required.")) | 468 | help=utils._("Container identifier of form ([a-z0-9][a-z0-9+.-]+). Required.")) |
1102 | 468 | parser_create.add_argument( | 469 | parser_create.add_argument( |
1103 | 469 | '-t', '--type', | 470 | '-t', '--type', |
1105 | 470 | help=("Type of Libertine container to create. Either 'lxd', 'lxc' or 'chroot'.")) | 471 | help=utils._("Type of Libertine container to create. Either 'lxd', 'lxc' or 'chroot'.")) |
1106 | 471 | parser_create.add_argument( | 472 | parser_create.add_argument( |
1107 | 472 | '-d', '--distro', | 473 | '-d', '--distro', |
1109 | 473 | help=("Ubuntu distro series to create.")) | 474 | help=utils._("Ubuntu distro series to create.")) |
1110 | 474 | parser_create.add_argument( | 475 | parser_create.add_argument( |
1111 | 475 | '-n', '--name', | 476 | '-n', '--name', |
1113 | 476 | help=("User friendly container name.")) | 477 | help=utils._("User friendly container name.")) |
1114 | 477 | parser_create.add_argument( | 478 | parser_create.add_argument( |
1115 | 478 | '--force', action='store_true', | 479 | '--force', action='store_true', |
1117 | 479 | help=("Force the installation of the given valid Ubuntu distro even if " | 480 | help=utils._("Force the installation of the given valid Ubuntu distro even if " |
1118 | 480 | "it is no longer supported.")) | 481 | "it is no longer supported.")) |
1119 | 481 | parser_create.add_argument( | 482 | parser_create.add_argument( |
1120 | 482 | '-m', '--multiarch', action='store_true', | 483 | '-m', '--multiarch', action='store_true', |
1122 | 483 | help=("Add i386 support to amd64 Libertine containers. This option has " | 484 | help=utils._("Add i386 support to amd64 Libertine containers. This option has " |
1123 | 484 | "no effect when the Libertine container is i386.")) | 485 | "no effect when the Libertine container is i386.")) |
1124 | 485 | parser_create.add_argument( | 486 | parser_create.add_argument( |
1125 | 486 | '--password', | 487 | '--password', |
1127 | 487 | help=("Pass in the user's password when creating an LXC container. This " | 488 | help=utils._("Pass in the user's password when creating an LXC container. This " |
1128 | 488 | "is intended for testing only and is very insecure.")) | 489 | "is intended for testing only and is very insecure.")) |
1129 | 489 | parser_create.set_defaults(func=container_manager.create) | 490 | parser_create.set_defaults(func=container_manager.create) |
1130 | 490 | 491 | ||
1131 | 491 | # Handle the destroy command and its options | 492 | # Handle the destroy command and its options |
1132 | 492 | parser_destroy = subparsers.add_parser( | 493 | parser_destroy = subparsers.add_parser( |
1133 | 493 | 'destroy', | 494 | 'destroy', |
1135 | 494 | help=("Destroy any existing environment entirely.")) | 495 | help=utils._("Destroy any existing environment entirely.")) |
1136 | 495 | parser_destroy.add_argument( | 496 | parser_destroy.add_argument( |
1137 | 496 | '-i', '--id', | 497 | '-i', '--id', |
1139 | 497 | help=("Container identifier. Default container is used if omitted.")) | 498 | help=utils._("Container identifier. Default container is used if omitted.")) |
1140 | 498 | parser_destroy.add_argument( | 499 | parser_destroy.add_argument( |
1141 | 499 | '-f', '--force', action='store_true', required=False, | 500 | '-f', '--force', action='store_true', required=False, |
1143 | 500 | help=("Force destroy. Forces running containers to stop before destruction.")) | 501 | help=utils._("Force destroy. Forces running containers to stop before destruction.")) |
1144 | 501 | parser_destroy.set_defaults(func=container_manager.destroy) | 502 | parser_destroy.set_defaults(func=container_manager.destroy) |
1145 | 502 | 503 | ||
1146 | 503 | # Handle the install-package command and its options | 504 | # Handle the install-package command and its options |
1147 | 504 | parser_install = subparsers.add_parser( | 505 | parser_install = subparsers.add_parser( |
1148 | 505 | 'install-package', | 506 | 'install-package', |
1150 | 506 | help=("Install a package or packages in the specified Libertine container.")) | 507 | help=utils._("Install a package or packages in the specified Libertine container.")) |
1151 | 507 | parser_install.add_argument( | 508 | parser_install.add_argument( |
1152 | 508 | '-p', '--package', | 509 | '-p', '--package', |
1153 | 509 | required=True, | 510 | required=True, |
1154 | 510 | nargs='+', | 511 | nargs='+', |
1156 | 511 | help=("Name of package or full path to a Debian package. Multiple packages " | 512 | help=utils._("Name of package or full path to a Debian package. Multiple packages " |
1157 | 512 | "can be entered, separated by a space. Required.")) | 513 | "can be entered, separated by a space. Required.")) |
1158 | 513 | parser_install.add_argument( | 514 | parser_install.add_argument( |
1159 | 514 | '-i', '--id', | 515 | '-i', '--id', |
1161 | 515 | help=("Container identifier. Default container is used if omitted.")) | 516 | help=utils._("Container identifier. Default container is used if omitted.")) |
1162 | 516 | parser_install.add_argument( | 517 | parser_install.add_argument( |
1163 | 517 | '-n', '--no-dialog', action='store_true', | 518 | '-n', '--no-dialog', action='store_true', |
1165 | 518 | help=("No dialog mode. Use text-based frontend during debconf interactions.")) | 519 | help=utils._("No dialog mode. Use text-based frontend during debconf interactions.")) |
1166 | 519 | parser_install.set_defaults(func=container_manager.install_package) | 520 | parser_install.set_defaults(func=container_manager.install_package) |
1167 | 520 | 521 | ||
1168 | 521 | # Handle the remove-package command and its options | 522 | # Handle the remove-package command and its options |
1169 | 522 | parser_remove = subparsers.add_parser( | 523 | parser_remove = subparsers.add_parser( |
1170 | 523 | 'remove-package', | 524 | 'remove-package', |
1172 | 524 | help=("Remove a package in the specified Libertine container.")) | 525 | help=utils._("Remove a package in the specified Libertine container.")) |
1173 | 525 | parser_remove.add_argument( | 526 | parser_remove.add_argument( |
1174 | 526 | '-p', '--package', | 527 | '-p', '--package', |
1175 | 527 | required=True, | 528 | required=True, |
1176 | 528 | nargs='+', | 529 | nargs='+', |
1178 | 529 | help=("Name of package to remove. Multiple packages can be entered, separated " | 530 | help=utils._("Name of package to remove. Multiple packages can be entered, separated " |
1179 | 530 | "by a space. Required.")) | 531 | "by a space. Required.")) |
1180 | 531 | parser_remove.add_argument( | 532 | parser_remove.add_argument( |
1181 | 532 | '-i', '--id', | 533 | '-i', '--id', |
1183 | 533 | help=("Container identifier. Default container is used if omitted.")) | 534 | help=utils._("Container identifier. Default container is used if omitted.")) |
1184 | 534 | parser_remove.add_argument( | 535 | parser_remove.add_argument( |
1185 | 535 | '-n', '--no-dialog', action='store_true', | 536 | '-n', '--no-dialog', action='store_true', |
1187 | 536 | help=("No dialog mode. Use text-based frontend during debconf interactions.")) | 537 | help=utils._("No dialog mode. Use text-based frontend during debconf interactions.")) |
1188 | 537 | parser_remove.set_defaults(func=container_manager.remove_package) | 538 | parser_remove.set_defaults(func=container_manager.remove_package) |
1189 | 538 | 539 | ||
1190 | 539 | # Handle the search-cache command and its options | 540 | # Handle the search-cache command and its options |
1191 | 540 | parser_search = subparsers.add_parser( | 541 | parser_search = subparsers.add_parser( |
1192 | 541 | 'search-cache', | 542 | 'search-cache', |
1194 | 542 | help=("Search for packages based on the search string in the specified Libertine container.")) | 543 | help=utils._("Search for packages based on the search string in the specified Libertine container.")) |
1195 | 543 | parser_search.add_argument( | 544 | parser_search.add_argument( |
1196 | 544 | '-s', '--search-string', | 545 | '-s', '--search-string', |
1197 | 545 | required=True, | 546 | required=True, |
1199 | 546 | help=("String to search for in the package cache. Required.")) | 547 | help=utils._("String to search for in the package cache. Required.")) |
1200 | 547 | parser_search.add_argument( | 548 | parser_search.add_argument( |
1201 | 548 | '-i', '--id', | 549 | '-i', '--id', |
1203 | 549 | help=("Container identifier. Default container is used if omitted.")) | 550 | help=utils._("Container identifier. Default container is used if omitted.")) |
1204 | 550 | parser_search.set_defaults(func=container_manager.search_cache) | 551 | parser_search.set_defaults(func=container_manager.search_cache) |
1205 | 551 | 552 | ||
1206 | 552 | # Handle the update command and its options | 553 | # Handle the update command and its options |
1207 | 553 | parser_update = subparsers.add_parser( | 554 | parser_update = subparsers.add_parser( |
1208 | 554 | 'update', | 555 | 'update', |
1210 | 555 | help=("Update the packages in the Libertine container. Also updates the container's " | 556 | help=utils._("Update the packages in the Libertine container. Also updates the container's " |
1211 | 556 | "locale and installs necessary language packs if the host's locale has changed.")) | 557 | "locale and installs necessary language packs if the host's locale has changed.")) |
1212 | 557 | parser_update.add_argument( | 558 | parser_update.add_argument( |
1213 | 558 | '-i', '--id', | 559 | '-i', '--id', |
1215 | 559 | help=("Container identifier. Default container is used if omitted.")) | 560 | help=utils._("Container identifier. Default container is used if omitted.")) |
1216 | 560 | parser_update.set_defaults(func=container_manager.update) | 561 | parser_update.set_defaults(func=container_manager.update) |
1217 | 561 | 562 | ||
1218 | 562 | # Handle the list command | 563 | # Handle the list command |
1219 | 563 | parser_list = subparsers.add_parser( | 564 | parser_list = subparsers.add_parser( |
1220 | 564 | "list", | 565 | "list", |
1222 | 565 | help=("List all Libertine containers.")) | 566 | help=utils._("List all Libertine containers.")) |
1223 | 566 | parser_list.set_defaults(func=container_manager.list) | 567 | parser_list.set_defaults(func=container_manager.list) |
1224 | 567 | 568 | ||
1225 | 568 | # Handle the list-apps command and its options | 569 | # Handle the list-apps command and its options |
1226 | 569 | parser_list_apps = subparsers.add_parser( | 570 | parser_list_apps = subparsers.add_parser( |
1227 | 570 | 'list-apps', | 571 | 'list-apps', |
1229 | 571 | help=("List available app launchers in a container.")) | 572 | help=utils._("List available app launchers in a container.")) |
1230 | 572 | parser_list_apps.add_argument( | 573 | parser_list_apps.add_argument( |
1231 | 573 | '-i', '--id', | 574 | '-i', '--id', |
1233 | 574 | help=("Container identifier. Default container is used if omitted.")) | 575 | help=utils._("Container identifier. Default container is used if omitted.")) |
1234 | 575 | parser_list_apps.add_argument( | 576 | parser_list_apps.add_argument( |
1235 | 576 | '-j', '--json', | 577 | '-j', '--json', |
1236 | 577 | action='store_true', | 578 | action='store_true', |
1238 | 578 | help=("use JSON output format.")) | 579 | help=utils._("use JSON output format.")) |
1239 | 579 | parser_list_apps.set_defaults(func=container_manager.list_apps) | 580 | parser_list_apps.set_defaults(func=container_manager.list_apps) |
1240 | 580 | 581 | ||
1241 | 581 | # Handle the execute command and it's options | 582 | # Handle the execute command and it's options |
1242 | 582 | parser_exec = subparsers.add_parser( | 583 | parser_exec = subparsers.add_parser( |
1243 | 583 | 'exec', | 584 | 'exec', |
1244 | 584 | add_help=False) | 585 | add_help=False) |
1246 | 585 | #help=("Run an arbitrary command in the specified Libertine container.")) | 586 | #help=utils._("Run an arbitrary command in the specified Libertine container.")) |
1247 | 586 | parser_exec.add_argument( | 587 | parser_exec.add_argument( |
1248 | 587 | '-i', '--id', | 588 | '-i', '--id', |
1250 | 588 | help=("Container identifier. Default container is used if omitted.")) | 589 | help=utils._("Container identifier. Default container is used if omitted.")) |
1251 | 589 | parser_exec.add_argument( | 590 | parser_exec.add_argument( |
1252 | 590 | '-c', '--command', | 591 | '-c', '--command', |
1254 | 591 | help=("The command to run in the specified container.")) | 592 | help=utils._("The command to run in the specified container.")) |
1255 | 592 | parser_exec.set_defaults(func=container_manager.exec) | 593 | parser_exec.set_defaults(func=container_manager.exec) |
1256 | 593 | 594 | ||
1257 | 594 | # Handle the configure command and it's options | 595 | # Handle the configure command and it's options |
1258 | 595 | parser_configure = subparsers.add_parser( | 596 | parser_configure = subparsers.add_parser( |
1259 | 596 | 'configure', | 597 | 'configure', |
1261 | 597 | help=("Configure various options in the specified Libertine container.")) | 598 | help=utils._("Configure various options in the specified Libertine container.")) |
1262 | 598 | parser_configure.add_argument( | 599 | parser_configure.add_argument( |
1263 | 599 | '-i', '--id', | 600 | '-i', '--id', |
1267 | 600 | help=("Container identifier. Default container is used if omitted.")) | 601 | help=utils._("Container identifier. Default container is used if omitted.")) |
1268 | 601 | multiarch_group = parser_configure.add_argument_group("Multiarch support", | 602 | multiarch_group = parser_configure.add_argument_group(utils._("Multiarch support"), |
1269 | 602 | "Enable or disable multiarch support for a container.") | 603 | utils._("Enable or disable multiarch support for a container.")) |
1270 | 603 | multiarch_group.add_argument( | 604 | multiarch_group.add_argument( |
1271 | 604 | '-m', '--multiarch', | 605 | '-m', '--multiarch', |
1272 | 605 | choices=['enable', 'disable'], | 606 | choices=['enable', 'disable'], |
1274 | 606 | help=("Enables or disables i386 multiarch support for amd64 Libertine " | 607 | help=utils._("Enables or disables i386 multiarch support for amd64 Libertine " |
1275 | 607 | "containers. This option has no effect when the Libertine " | 608 | "containers. This option has no effect when the Libertine " |
1276 | 608 | "container is i386.")) | 609 | "container is i386.")) |
1277 | 609 | 610 | ||
1280 | 610 | archive_group = parser_configure.add_argument_group("Additional archive support", | 611 | archive_group = parser_configure.add_argument_group(utils._("Additional archive support"), |
1281 | 611 | "Add or delete an additional archive (PPA).") | 612 | utils._("Add or delete an additional archive (PPA).")) |
1282 | 612 | archive_group.add_argument( | 613 | archive_group.add_argument( |
1283 | 613 | '-a', '--archive', | 614 | '-a', '--archive', |
1284 | 614 | choices=['add', 'remove'], | 615 | choices=['add', 'remove'], |
1286 | 615 | help=("Adds or removes an archive (PPA) in the specified Libertine container.")) | 616 | help=utils._("Adds or removes an archive (PPA) in the specified Libertine container.")) |
1287 | 616 | archive_group.add_argument( | 617 | archive_group.add_argument( |
1288 | 617 | '-n', '--archive-name', | 618 | '-n', '--archive-name', |
1291 | 618 | metavar='Archive name', | 619 | metavar=utils._('Archive name'), |
1292 | 619 | help=("Archive name to be added or removed.")) | 620 | help=utils._("Archive name to be added or removed.")) |
1293 | 620 | archive_group.add_argument( | 621 | archive_group.add_argument( |
1294 | 621 | '-k', '--public-key-file', | 622 | '-k', '--public-key-file', |
1297 | 622 | metavar='Public key file', | 623 | metavar=utils._('Public key file'), |
1298 | 623 | help=("File containing the key used to sign the given archive. " | 624 | help=utils._("File containing the key used to sign the given archive. " |
1299 | 624 | "Useful for third-party or private archives.")) | 625 | "Useful for third-party or private archives.")) |
1300 | 625 | 626 | ||
1303 | 626 | mount_group = parser_configure.add_argument_group("Additional bind-mounts", | 627 | mount_group = parser_configure.add_argument_group(utils._("Additional bind-mounts"), |
1304 | 627 | "Add or delete an additional bind-mount.") | 628 | utils._("Add or delete an additional bind-mount.")) |
1305 | 628 | mount_group.add_argument( | 629 | mount_group.add_argument( |
1306 | 629 | '-b', '--bind-mount', | 630 | '-b', '--bind-mount', |
1307 | 630 | choices=['add', 'remove'], | 631 | choices=['add', 'remove'], |
1309 | 631 | help="Adds or removes a bind-mount in the specified Libertine container.") | 632 | help=utils._("Adds or removes a bind-mount in the specified Libertine container.")) |
1310 | 632 | mount_group.add_argument( | 633 | mount_group.add_argument( |
1311 | 633 | '-p', '--mount-path', | 634 | '-p', '--mount-path', |
1314 | 634 | metavar='Mount path', | 635 | metavar=utils._('Mount path'), |
1315 | 635 | help=("The absolute host path to bind-mount.")) | 636 | help=utils._("The absolute host path to bind-mount.")) |
1316 | 636 | 637 | ||
1319 | 637 | freeze_group = parser_configure.add_argument_group("Freeze container support", | 638 | freeze_group = parser_configure.add_argument_group(utils._("Freeze container support"), |
1320 | 638 | "Enable or disable freezing LXC/LXD containers when not in use.") | 639 | utils._("Enable or disable freezing LXC/LXD containers when not in use.")) |
1321 | 639 | freeze_group.add_argument( | 640 | freeze_group.add_argument( |
1322 | 640 | '-f', '--freeze', | 641 | '-f', '--freeze', |
1323 | 641 | choices=['enable', 'disable'], | 642 | choices=['enable', 'disable'], |
1325 | 642 | help=("Enables or disables freezing of LXC/LXD containers when not in use." | 643 | help=utils._("Enables or disables freezing of LXC/LXD containers when not in use." |
1326 | 643 | " When disabled, the container will stop.")) | 644 | " When disabled, the container will stop.")) |
1327 | 644 | 645 | ||
1328 | 645 | parser_configure.set_defaults(func=container_manager.configure) | 646 | parser_configure.set_defaults(func=container_manager.configure) |
1329 | @@ -662,30 +663,30 @@ | |||
1330 | 662 | # Set the default container in ContainersConfig | 663 | # Set the default container in ContainersConfig |
1331 | 663 | parser_default = subparsers.add_parser( | 664 | parser_default = subparsers.add_parser( |
1332 | 664 | 'set-default', | 665 | 'set-default', |
1334 | 665 | help=("Set the default container.")) | 666 | help=utils._("Set the default container.")) |
1335 | 666 | parser_default.add_argument( | 667 | parser_default.add_argument( |
1336 | 667 | '-i', '--id', | 668 | '-i', '--id', |
1339 | 668 | metavar='Container id', | 669 | metavar=utils._('Container id'), |
1340 | 669 | help=("Container identifier. Default container is used if omitted.")) | 670 | help=utils._("Container identifier. Default container is used if omitted.")) |
1341 | 670 | parser_default.add_argument( | 671 | parser_default.add_argument( |
1342 | 671 | '-c', '--clear', action='store_true', | 672 | '-c', '--clear', action='store_true', |
1344 | 672 | help=("Clear the default container.")) | 673 | help=utils._("Clear the default container.")) |
1345 | 673 | parser_default.set_defaults(func=container_manager.set_default) | 674 | parser_default.set_defaults(func=container_manager.set_default) |
1346 | 674 | 675 | ||
1347 | 675 | # Handle the restart command and its options | 676 | # Handle the restart command and its options |
1348 | 676 | parser_update = subparsers.add_parser( | 677 | parser_update = subparsers.add_parser( |
1349 | 677 | 'restart', | 678 | 'restart', |
1351 | 678 | help=("Restart a frozen Libertine container. This only works on LXC " | 679 | help=utils._("Restart a frozen Libertine container. This only works on LXC " |
1352 | 679 | "and LXD type containers.")) | 680 | "and LXD type containers.")) |
1353 | 680 | parser_update.add_argument( | 681 | parser_update.add_argument( |
1354 | 681 | '-i', '--id', | 682 | '-i', '--id', |
1356 | 682 | help=("Container identifier. Default container is used if omitted.")) | 683 | help=utils._("Container identifier. Default container is used if omitted.")) |
1357 | 683 | parser_update.set_defaults(func=container_manager.restart) | 684 | parser_update.set_defaults(func=container_manager.restart) |
1358 | 684 | 685 | ||
1359 | 685 | # Actually parse the args | 686 | # Actually parse the args |
1360 | 686 | args = parser.parse_args() | 687 | args = parser.parse_args() |
1361 | 687 | 688 | ||
1363 | 688 | libertine.utils.set_environmental_verbosity(args.verbosity) | 689 | utils.set_environmental_verbosity(args.verbosity) |
1364 | 689 | 690 | ||
1365 | 690 | if args.subparser_name == None: | 691 | if args.subparser_name == None: |
1366 | 691 | parser.print_help() | 692 | parser.print_help() |
1367 | 692 | 693 | ||
1368 | === modified file 'tools/libertine-launch' | |||
1369 | --- tools/libertine-launch 2017-03-14 15:31:27 +0000 | |||
1370 | +++ tools/libertine-launch 2017-04-06 14:39:25 +0000 | |||
1371 | @@ -19,11 +19,7 @@ | |||
1372 | 19 | import os | 19 | import os |
1373 | 20 | import sys | 20 | import sys |
1374 | 21 | 21 | ||
1380 | 22 | import gettext | 22 | from libertine import launcher, utils |
1376 | 23 | gettext.textdomain('libertine') | ||
1377 | 24 | _ = gettext.gettext | ||
1378 | 25 | |||
1379 | 26 | from libertine import launcher | ||
1381 | 27 | 23 | ||
1382 | 28 | def main(): | 24 | def main(): |
1383 | 29 | config = launcher.Config() | 25 | config = launcher.Config() |
1384 | @@ -31,7 +27,7 @@ | |||
1385 | 31 | if config.container_id: | 27 | if config.container_id: |
1386 | 32 | from libertine import ContainersConfig, utils | 28 | from libertine import ContainersConfig, utils |
1387 | 33 | if not ContainersConfig.ContainersConfig().container_exists(config.container_id): | 29 | if not ContainersConfig.ContainersConfig().container_exists(config.container_id): |
1389 | 34 | utils.get_logger().error("No container with id '%s'" % config.container_id) | 30 | utils.get_logger().error(utils._("No container with id '{container_id}'").format(container_id=config.container_id)) |
1390 | 35 | sys.exit(1) | 31 | sys.exit(1) |
1391 | 36 | 32 | ||
1392 | 37 | try: | 33 | try: |
1393 | @@ -39,8 +35,8 @@ | |||
1394 | 39 | container = LibertineContainer(container_id=config.container_id) | 35 | container = LibertineContainer(container_id=config.container_id) |
1395 | 40 | except ImportError as e: | 36 | except ImportError as e: |
1396 | 41 | container_type = self.containers_config.get_container_type(container_id) | 37 | container_type = self.containers_config.get_container_type(container_id) |
1399 | 42 | libertine.utils.get_logger().error(_("Backend for container '{id}' not installed. Install " | 38 | utils.get_logger().error(utils._("Backend for container '{id}' not installed. Install " |
1400 | 43 | "'python3-libertine-{type}' and try again.").format(id=config.container_id, type=container_type)) | 39 | "'python3-libertine-{type}' and try again.").format(id=config.container_id, type=container_type)) |
1401 | 44 | sys.exit(1) | 40 | sys.exit(1) |
1402 | 45 | else: | 41 | else: |
1403 | 46 | from libertine import NoContainer | 42 | from libertine import NoContainer |
1404 | 47 | 43 | ||
1405 | === modified file 'tools/libertined' | |||
1406 | --- tools/libertined 2017-04-03 19:59:26 +0000 | |||
1407 | +++ tools/libertined 2017-04-06 14:39:25 +0000 | |||
1408 | @@ -30,13 +30,13 @@ | |||
1409 | 30 | 30 | ||
1410 | 31 | class Config(object): | 31 | class Config(object): |
1411 | 32 | def __init__(self): | 32 | def __init__(self): |
1413 | 33 | self._arg_parser = argparse.ArgumentParser(description=u'Libertine Store service') | 33 | self._arg_parser = argparse.ArgumentParser(description=utils._('Libertine Store service')) |
1414 | 34 | self._arg_parser.add_argument('-q', '--quiet', action='store_const', | 34 | self._arg_parser.add_argument('-q', '--quiet', action='store_const', |
1415 | 35 | dest='verbosity', const=0, | 35 | dest='verbosity', const=0, |
1417 | 36 | help=('disables all non-vital output')) | 36 | help=utils._('disables all non-vital output')) |
1418 | 37 | self._arg_parser.add_argument('-v', '--verbosity', action='store_const', | 37 | self._arg_parser.add_argument('-v', '--verbosity', action='store_const', |
1419 | 38 | dest='verbosity', const=2, | 38 | dest='verbosity', const=2, |
1421 | 39 | help=('enables debug output')) | 39 | help=utils._('enables debug output')) |
1422 | 40 | args = self._arg_parser.parse_args(namespace=Config) | 40 | args = self._arg_parser.parse_args(namespace=Config) |
1423 | 41 | 41 | ||
1424 | 42 | 42 | ||
1425 | @@ -54,7 +54,7 @@ | |||
1426 | 54 | self.shutdown() | 54 | self.shutdown() |
1427 | 55 | 55 | ||
1428 | 56 | def shutdown(self): | 56 | def shutdown(self): |
1430 | 57 | utils.get_logger().info("shutting service down") | 57 | utils.get_logger().info(utils._("shutting service down")) |
1431 | 58 | self.loop.quit() | 58 | self.loop.quit() |
1432 | 59 | 59 | ||
1433 | 60 | def run(self): | 60 | def run(self): |
1434 | @@ -65,15 +65,15 @@ | |||
1435 | 65 | def main(): | 65 | def main(): |
1436 | 66 | config = Config() | 66 | config = Config() |
1437 | 67 | 67 | ||
1439 | 68 | utils.get_logger().info("Initializing libertined...") | 68 | utils.get_logger().info(utils._("Initializing libertined...")) |
1440 | 69 | loop = Loop() | 69 | loop = Loop() |
1441 | 70 | 70 | ||
1442 | 71 | try: | 71 | try: |
1443 | 72 | bus_name = dbus.service.BusName(constants.SERVICE_NAME, | 72 | bus_name = dbus.service.BusName(constants.SERVICE_NAME, |
1444 | 73 | bus=dbus.SessionBus(), | 73 | bus=dbus.SessionBus(), |
1446 | 74 | do_not_queue=True) | 74 | do_not_queue=True) |
1447 | 75 | except dbus.exceptions.NameExistsException: | 75 | except dbus.exceptions.NameExistsException: |
1449 | 76 | utils.get_logger().warning("service is already running") | 76 | utils.get_logger().warning(utils._("service is already running")) |
1450 | 77 | raise | 77 | raise |
1451 | 78 | 78 | ||
1452 | 79 | client = container_control_client.ContainerControlClient() | 79 | client = container_control_client.ContainerControlClient() |
1453 | @@ -81,12 +81,12 @@ | |||
1454 | 81 | container_control.ContainerControl(manager.connection, client) | 81 | container_control.ContainerControl(manager.connection, client) |
1455 | 82 | 82 | ||
1456 | 83 | try: | 83 | try: |
1458 | 84 | utils.get_logger().info("libertined ready") | 84 | utils.get_logger().info(utils._("libertined ready")) |
1459 | 85 | loop.run() | 85 | loop.run() |
1460 | 86 | except KeyboardInterrupt: | 86 | except KeyboardInterrupt: |
1461 | 87 | utils.get_logger().debug("keyboard interrupt received") | 87 | utils.get_logger().debug("keyboard interrupt received") |
1462 | 88 | except Exception as e: | 88 | except Exception as e: |
1464 | 89 | utils.get_logger().error("Unexpected exception occurred: '{}'".format(str(e))) | 89 | utils.get_logger().error(utils._("Unexpected exception occurred: '{error}'").format(error=str(e))) |
1465 | 90 | finally: | 90 | finally: |
1466 | 91 | loop.shutdown() | 91 | loop.shutdown() |
1467 | 92 | 92 |
PASSED: Continuous integration, rev:418 /jenkins. canonical. com/libertine/ job/lp- libertine- ci/491/ /jenkins. canonical. com/libertine/ job/build/ 889 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=amd64, release= xenial+ overlay, testname= default/ 733 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=amd64, release= zesty,testname= default/ 733 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=i386, release= xenial+ overlay, testname= default/ 733 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=i386, release= zesty,testname= default/ 733 /jenkins. canonical. com/libertine/ job/build- 0-fetch/ 899 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= xenial+ overlay/ 890 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= xenial+ overlay/ 890/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= zesty/890 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= zesty/890/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= xenial+ overlay/ 890 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= xenial+ overlay/ 890/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= zesty/890 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= zesty/890/ artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/libertine/ job/lp- libertine- ci/491/ rebuild
https:/