Merge lp:~larryprice/libertine/python-i18n into lp:libertine

Proposed by Larry Price
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
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.

To post a comment you must log in.
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:418
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/491/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/889
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/733
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/733
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/733
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/733
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/899
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/890
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/890/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/890
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/890/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/890
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/890/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/890
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/890/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/491/rebuild

review: Approve (continuous-integration)
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:419
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/500/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/904
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/742
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/742
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/742
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/742
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/915
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/904
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/904/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/904
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/904/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/904
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/904/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/904
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/904/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/500/rebuild

review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Getting a merge conflict:)

Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

PASSED: Continuous integration, rev:420
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/511/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/918
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/754
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/754
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/754
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/754
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/929
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/918
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/918/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/918
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/918/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/918
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/918/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/918
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/918/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://jenkins.canonical.com/libertine/job/lp-libertine-ci/511/rebuild

review: Approve (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Ok, going to roll with this.

review: Approve
Revision history for this message
Libertine CI Bot (libertine-ci-bot) wrote :

FAILED: Autolanding.
Unapproved changes made after approval.
https://jenkins.canonical.com/libertine/job/lp-libertine-autoland/233/
Executed test runs:
    SUCCESS: https://jenkins.canonical.com/libertine/job/build/919
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=xenial+overlay,testname=default/755
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=amd64,release=zesty,testname=default/755
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=xenial+overlay,testname=default/755
    SUCCESS: https://jenkins.canonical.com/libertine/job/test-0-autopkgtest/label=i386,release=zesty,testname=default/755
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-0-fetch/930
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/919
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=xenial+overlay/919/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/919
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=amd64,release=zesty/919/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/919
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=xenial+overlay/919/artifact/output/*zip*/output.zip
    SUCCESS: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/919
        deb: https://jenkins.canonical.com/libertine/job/build-2-binpkg/arch=i386,release=zesty/919/artifact/output/*zip*/output.zip

review: Needs Fixing (continuous-integration)
Revision history for this message
Christopher Townsend (townsend) wrote :

Wut? Trying again...

review: Approve
Revision history for this message
Libertine CI Bot (libertine-ci-bot) :
review: Approve (continuous-integration)

Preview Diff

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

Subscribers

People subscribed via source and target branches