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

Proposed by Larry Price on 2017-03-24
Status: Merged
Approved by: Christopher Townsend on 2017-04-06
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 on 2017-04-06
Christopher Townsend 2017-03-24 Approve on 2017-04-06
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.
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)
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)
Christopher Townsend (townsend) wrote :

Getting a merge conflict:)

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)
Christopher Townsend (townsend) wrote :

Ok, going to roll with this.

review: Approve
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)
Christopher Townsend (townsend) wrote :

Wut? Trying again...

review: Approve
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'po/CMakeLists.txt'
--- po/CMakeLists.txt 2016-12-05 19:41:37 +0000
+++ po/CMakeLists.txt 2017-04-06 14:39:25 +0000
@@ -1,7 +1,50 @@
1# Customize this function from cmake-extras to handle additional options for
2# parsing python files and our python command line tools (LP: #1675865)
3macro(_WRITE_INTLTOOL_MAKEFILE_IN ARG_PO_DIRECTORY ARG_KEYWORDS
4 ARG_COPYRIGHT_HOLDER)
5 set(_KEYWORDS "XGETTEXT_KEYWORDS=-Lc -Lc++ -Lpython")
6 if(NOT "${ARG_COPYRIGHT_HOLDER}" STREQUAL "")
7 set(_KEYWORDS "${_KEYWORDS} --copyright-holder='${ARG_COPYRIGHT_HOLDER}'")
8 endif()
9 foreach(_KEYWORD ${${ARG_KEYWORDS}})
10 set(_KEYWORDS "${_KEYWORDS} --keyword=${_KEYWORD}")
11 endforeach()
12 file(WRITE "${ARG_PO_DIRECTORY}/Makefile.in.in" "${_KEYWORDS}\n")
13endmacro()
14
15# Customize this function from cmake-extras to handle additional options for
16# parsing python files and our python command line tools (LP: #1675864)
17function(_INTLTOOL_LIST_FILTER INPUT OUTPUT)
18 set(_multiValueArgs EXPRESSIONS)
19 cmake_parse_arguments(_ARG "" "" "${_multiValueArgs}" ${ARGN})
20
21 if(_ARG_EXPRESSIONS)
22 set(_TMP "")
23 foreach(_ITEM ${${INPUT}})
24 unset(_MATCHED)
25 foreach(_REGEX ${_ARG_EXPRESSIONS})
26 if("${_ITEM}" MATCHES "${_REGEX}")
27 set(_MATCHED ON)
28 break()
29 endif()
30 endforeach()
31 if(NOT _MATCHED)
32 list(APPEND _TMP "${_ITEM}")
33 endif()
34 endforeach()
35 set(${OUTPUT} "${_TMP}" PARENT_SCOPE)
36 unset(_TMP)
37 else()
38 set(${OUTPUT} "${${INPUT}}" PARENT_SCOPE)
39 endif()
40endfunction()
41
1set (GETTEXT_PACKAGE "libertine")42set (GETTEXT_PACKAGE "libertine")
243
3intltool_update_potfile(44intltool_update_potfile(
4 UBUNTU_SDK_DEFAULTS45 UBUNTU_SDK_DEFAULTS
46 FILE_GLOBS "${CMAKE_SOURCE_DIR}/python/libertine/**/*.py;${CMAKE_SOURCE_DIR}/tools/libertine-*"
47 FILTER "__init__.py;.bzr/*;parts/*;stage/*;prime/*"
5 POTFILES_TEMPLATE POTFILES.in.in48 POTFILES_TEMPLATE POTFILES.in.in
6 COPYRIGHT_HOLDER "Canonical Ltd."49 COPYRIGHT_HOLDER "Canonical Ltd."
7 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}50 GETTEXT_PACKAGE ${GETTEXT_PACKAGE}
851
=== modified file 'python/libertine/ChrootContainer.py'
--- python/libertine/ChrootContainer.py 2017-03-08 21:23:54 +0000
+++ python/libertine/ChrootContainer.py 2017-04-06 14:39:25 +0000
@@ -75,12 +75,12 @@
75 cmd.wait()75 cmd.wait()
7676
77 if cmd.returncode != 0:77 if cmd.returncode != 0:
78 utils.get_logger().error("Failed to create container")78 utils.get_logger().error(utils._("Failed to create container"))
79 self.destroy_libertine_container()79 self.destroy_libertine_container()
80 return False80 return False
8181
82 # Remove symlinks as they can cause ill-behaved recursive behavior in the chroot82 # Remove symlinks as they can cause ill-behaved recursive behavior in the chroot
83 utils.get_logger().info("Fixing chroot symlinks...")83 utils.get_logger().info(utils._("Fixing chroot symlinks..."))
84 os.remove(os.path.join(self.root_path, 'dev'))84 os.remove(os.path.join(self.root_path, 'dev'))
85 os.remove(os.path.join(self.root_path, 'proc'))85 os.remove(os.path.join(self.root_path, 'proc'))
8686
@@ -101,7 +101,7 @@
101 else:101 else:
102 archive = "deb http://archive.ubuntu.com/ubuntu "102 archive = "deb http://archive.ubuntu.com/ubuntu "
103103
104 utils.get_logger().info("Updating chroot's sources.list entries...")104 utils.get_logger().info(utils._("Updating chroot's sources.list entries..."))
105105
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:
107 fd.write(archive + self.installed_release + "-updates main\n")107 fd.write(archive + self.installed_release + "-updates main\n")
@@ -115,22 +115,22 @@
115 self.update_locale()115 self.update_locale()
116116
117 if multiarch and self.architecture == 'amd64':117 if multiarch and self.architecture == 'amd64':
118 utils.get_logger().info("Adding i386 multiarch support...")118 utils.get_logger().info(utils._("Adding i386 multiarch support..."))
119 self.run_in_container("dpkg --add-architecture i386")119 self.run_in_container("dpkg --add-architecture i386")
120120
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..."))
122 self.update_packages()122 self.update_packages()
123123
124 for package in self.default_packages:124 for package in self.default_packages:
125 if not self.install_package(package, update_cache=False):125 if not self.install_package(package, update_cache=False):
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))
127 self.destroy_libertine_container()127 self.destroy_libertine_container()
128 return False128 return False
129129
130 if self.installed_release == "vivid" or self.installed_release == "xenial":130 if self.installed_release == "vivid" or self.installed_release == "xenial":
131 utils.get_logger().info("Installing the Stable Overlay PPA...")131 utils.get_logger().info(utils._("Installing the Stable Overlay PPA..."))
132 if not self.install_package("software-properties-common", update_cache=False):132 if not self.install_package("software-properties-common", update_cache=False):
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"))
134 self.destroy_libertine_container()134 self.destroy_libertine_container()
135 return False135 return False
136136
@@ -168,7 +168,7 @@
168 def _build_proot_command(self):168 def _build_proot_command(self):
169 proot_cmd = shutil.which('proot')169 proot_cmd = shutil.which('proot')
170 if not proot_cmd:170 if not proot_cmd:
171 raise RuntimeError('executable proot not found')171 raise RuntimeError(utils._('executable proot not found'))
172172
173 proot_cmd += " -R " + self.root_path173 proot_cmd += " -R " + self.root_path
174174
@@ -211,7 +211,7 @@
211 def _build_privileged_proot_cmd(self):211 def _build_privileged_proot_cmd(self):
212 proot_cmd = shutil.which('proot')212 proot_cmd = shutil.which('proot')
213 if not proot_cmd:213 if not proot_cmd:
214 raise RuntimeError('executable proot not found')214 raise RuntimeError(utils._('executable proot not found'))
215215
216 proot_cmd += " -b /usr/lib/locale -S " + self.root_path216 proot_cmd += " -b /usr/lib/locale -S " + self.root_path
217217
@@ -232,7 +232,7 @@
232 app.wait()232 app.wait()
233233
234 def _run_ldconfig(self):234 def _run_ldconfig(self):
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..."))
236236
237 command_line = self._build_privileged_proot_cmd() + " ldconfig.REAL"237 command_line = self._build_privileged_proot_cmd() + " ldconfig.REAL"
238238
239239
=== modified file 'python/libertine/ContainerControlClient.py'
--- python/libertine/ContainerControlClient.py 2017-03-08 21:26:57 +0000
+++ python/libertine/ContainerControlClient.py 2017-04-06 14:39:25 +0000
@@ -38,9 +38,9 @@
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)
39 self._interface = constants.CONTAINER_CONTROL_INTERFACE39 self._interface = constants.CONTAINER_CONTROL_INTERFACE
40 except ImportError as e:40 except ImportError as e:
41 utils.get_logger().warning("Libertine service libraries not installed.")41 utils.get_logger().warning(utils._("Libertine service libraries not installed."))
42 except dbus.exceptions.DBusException as e:42 except dbus.exceptions.DBusException as e:
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)))
4444
45 def _do_operation(self, operation):45 def _do_operation(self, operation):
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.
4747
=== modified file 'python/libertine/ContainersConfig.py'
--- python/libertine/ContainersConfig.py 2017-03-29 16:22:24 +0000
+++ python/libertine/ContainersConfig.py 2017-04-06 14:39:25 +0000
@@ -249,12 +249,12 @@
249249
250 def check_container_id(self, container_id):250 def check_container_id(self, container_id):
251 if container_id and not self.container_exists(container_id):251 if container_id and not self.container_exists(container_id):
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))
253 sys.exit(1)253 sys.exit(1)
254 elif not container_id:254 elif not container_id:
255 container_id = self.get_default_container_id()255 container_id = self.get_default_container_id()
256 if container_id is None:256 if container_id is None:
257 utils.get_logger().error("No default container available.")257 utils.get_logger().error(utils._("No default container available."))
258 sys.exit(1)258 sys.exit(1)
259259
260 return container_id260 return container_id
@@ -298,7 +298,7 @@
298298
299 def delete_container(self, container_id):299 def delete_container(self, container_id):
300 if not self.container_list:300 if not self.container_list:
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."))
302 sys.exit(1)302 sys.exit(1)
303303
304 container = self._get_container_entry(container_id)304 container = self._get_container_entry(container_id)
305305
=== modified file 'python/libertine/HostInfo.py'
--- python/libertine/HostInfo.py 2017-02-24 15:05:33 +0000
+++ python/libertine/HostInfo.py 2017-04-06 14:39:25 +0000
@@ -12,7 +12,6 @@
12# You should have received a copy of the GNU General Public License along12# You should have received a copy of the GNU General Public License along
13# with this program. If not, see <http://www.gnu.org/licenses/>.13# with this program. If not, see <http://www.gnu.org/licenses/>.
1414
15import libertine.utils
16import locale15import locale
17import lsb_release16import lsb_release
18import os17import os
@@ -20,6 +19,7 @@
20import subprocess19import subprocess
2120
22from distro_info import UbuntuDistroInfo21from distro_info import UbuntuDistroInfo
22from libertine import utils
2323
2424
25class HostInfo(object):25class HostInfo(object):
@@ -78,7 +78,7 @@
78 stdout=subprocess.PIPE,78 stdout=subprocess.PIPE,
79 universal_newlines=True)79 universal_newlines=True)
80 if dpkg.wait() != 0:80 if dpkg.wait() != 0:
81 parser.error("Failed to determine the local architecture.")81 parser.error(utils._("Failed to determine the local architecture."))
8282
83 return dpkg.stdout.read().strip()83 return dpkg.stdout.read().strip()
8484
8585
=== modified file 'python/libertine/Libertine.py'
--- python/libertine/Libertine.py 2017-03-23 14:35:57 +0000
+++ python/libertine/Libertine.py 2017-04-06 14:39:25 +0000
@@ -236,7 +236,7 @@
236236
237 if package_name.endswith('.deb'):237 if package_name.endswith('.deb'):
238 if not os.path.exists(package_name):238 if not os.path.exists(package_name):
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))
240 return False240 return False
241241
242 dest = os.path.join('/', 'tmp', package_name.split('/')[-1])242 dest = os.path.join('/', 'tmp', package_name.split('/')[-1])
@@ -377,7 +377,7 @@
377 def __init__(self, container):377 def __init__(self, container):
378 super().__init__()378 super().__init__()
379 if not container.start_container():379 if not container.start_container():
380 raise RuntimeError("Container failed to start.")380 raise RuntimeError(utils._("Container failed to start."))
381381
382 self.callback(lambda: container.stop_container())382 self.callback(lambda: container.stop_container())
383383
@@ -412,7 +412,7 @@
412 elif container_type == "mock":412 elif container_type == "mock":
413 self.container = LibertineMock(container_id, self.containers_config, service)413 self.container = LibertineMock(container_id, self.containers_config, service)
414 else:414 else:
415 raise RuntimeError("Unsupported container type %s" % container_type)415 raise RuntimeError(utils._("Unsupported container type '{container_type}'").format(container_type))
416416
417 @property417 @property
418 def container_id(self):418 def container_id(self):
419419
=== modified file 'python/libertine/LxcContainer.py'
--- python/libertine/LxcContainer.py 2017-03-08 21:23:54 +0000
+++ python/libertine/LxcContainer.py 2017-04-06 14:39:25 +0000
@@ -69,7 +69,7 @@
69 for line in fd:69 for line in fd:
70 print(line.lstrip())70 print(line.lstrip())
71 except Exception as ex:71 except Exception as ex:
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))
7373
7474
75def get_logfile(container):75def get_logfile(container):
@@ -90,20 +90,20 @@
9090
91 if container.state == 'STOPPED':91 if container.state == 'STOPPED':
92 if not container.start():92 if not container.start():
93 utils.get_logger().error("Container failed to start.")93 utils.get_logger().error(utils._("Container failed to start."))
94 return False94 return False
95 elif container.state == 'FROZEN':95 elif container.state == 'FROZEN':
96 if not container.unfreeze():96 if not container.unfreeze():
97 utils.get_logger().error("Container failed to unfreeze.")97 utils.get_logger().error(utils._("Container failed to unfreeze."))
98 return False98 return False
9999
100 if not container.wait("RUNNING", 10):100 if not container.wait("RUNNING", 10):
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."))
102 return False102 return False
103103
104 if not container.get_ips(timeout=30):104 if not container.get_ips(timeout=30):
105 lxc_stop(container)105 lxc_stop(container)
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."))
107 return False107 return False
108108
109 return True109 return True
@@ -116,12 +116,12 @@
116 if freeze_on_stop:116 if freeze_on_stop:
117 container.freeze()117 container.freeze()
118 if not container.wait("FROZEN", 10):118 if not container.wait("FROZEN", 10):
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."))
120 return False120 return False
121 else:121 else:
122 container.stop()122 container.stop()
123 if not container.wait("STOPPED", 10):123 if not container.wait("STOPPED", 10):
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."))
125 return False125 return False
126126
127 return True127 return True
@@ -246,7 +246,7 @@
246246
247 def restart_container(self):247 def restart_container(self):
248 if self.container.state != 'FROZEN':248 if self.container.state != 'FROZEN':
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))
250 return False250 return False
251251
252 if not (lxc_stop(self.container) and lxc_start(self.container)):252 if not (lxc_stop(self.container) and lxc_start(self.container)):
@@ -272,11 +272,11 @@
272 return False272 return False
273273
274 if self.container.state == 'RUNNING' and not force:274 if self.container.state == 'RUNNING' and not force:
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."))
276 return False276 return False
277277
278 if not lxc_stop(self.container):278 if not lxc_stop(self.container):
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."))
280 return False280 return False
281281
282 self.container.destroy()282 self.container.destroy()
@@ -322,13 +322,13 @@
322 {"dist": "ubuntu",322 {"dist": "ubuntu",
323 "release": self.installed_release,323 "release": self.installed_release,
324 "arch": self.architecture}):324 "arch": self.architecture}):
325 utils.get_logger().error("Failed to create container")325 utils.get_logger().error(utils._("Failed to create container"))
326 _dump_lxc_log(lxc_logfile)326 _dump_lxc_log(lxc_logfile)
327 return False327 return False
328328
329 self.create_libertine_config()329 self.create_libertine_config()
330330
331 utils.get_logger().info("starting container ...")331 utils.get_logger().info(utils._("starting container ..."))
332 if not self.start_container():332 if not self.start_container():
333 self.destroy_libertine_container()333 self.destroy_libertine_container()
334 return False334 return False
@@ -340,21 +340,21 @@
340 str(user_id), crypt.crypt(password), str(username)))340 str(user_id), crypt.crypt(password), str(username)))
341341
342 if multiarch and self.architecture == 'amd64':342 if multiarch and self.architecture == 'amd64':
343 utils.get_logger().info("Adding i386 multiarch support...")343 utils.get_logger().info(utils._("Adding i386 multiarch support..."))
344 self.run_in_container("dpkg --add-architecture i386")344 self.run_in_container("dpkg --add-architecture i386")
345345
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..."))
347 self.update_packages()347 self.update_packages()
348348
349 for package in self.default_packages:349 for package in self.default_packages:
350 if not self.install_package(package, update_cache=False):350 if not self.install_package(package, update_cache=False):
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))
352 self.destroy_libertine_container()352 self.destroy_libertine_container()
353 return False353 return False
354354
355 super().create_libertine_container()355 super().create_libertine_container()
356356
357 utils.get_logger().info("stopping container ...")357 utils.get_logger().info(utils._("stopping container ..."))
358 self.stop_container()358 self.stop_container()
359359
360 return True360 return True
361361
=== modified file 'python/libertine/LxdContainer.py'
--- python/libertine/LxdContainer.py 2017-03-23 14:42:39 +0000
+++ python/libertine/LxdContainer.py 2017-04-06 14:39:25 +0000
@@ -62,7 +62,7 @@
6262
63def _setup_lxd():63def _setup_lxd():
64 if utils.is_snap_environment():64 if utils.is_snap_environment():
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."))
66 return True66 return True
6767
68 utils.get_logger().debug("Running LXD setup.")68 utils.get_logger().debug("Running LXD setup.")
@@ -92,7 +92,7 @@
9292
9393
94def _setup_bind_mount_service(container, uid, username):94def _setup_bind_mount_service(container, uid, username):
95 utils.get_logger().info("Creating mount update shell script")95 utils.get_logger().info(utils._("Creating mount update shell script"))
96 script = '''96 script = '''
97#!/bin/sh97#!/bin/sh
9898
@@ -122,7 +122,7 @@
122 stdout=subprocess.PIPE, stderr=subprocess.PIPE)122 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
123 out, err = ping.communicate()123 out, err = ping.communicate()
124 if out:124 if out:
125 utils.get_logger().info("Network connection active")125 utils.get_logger().debug("Network connection active")
126 return True126 return True
127 time.sleep(1)127 time.sleep(1)
128 return False128 return False
@@ -137,7 +137,7 @@
137 container.sync(rollback=True) # required for pylxd=2.0.x137 container.sync(rollback=True) # required for pylxd=2.0.x
138138
139 if container.status != 'Running':139 if container.status != 'Running':
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))
141 return False141 return False
142142
143 return True143 return True
@@ -156,10 +156,10 @@
156156
157 if wait:157 if wait:
158 if freeze_on_stop and container.status != 'Frozen':158 if freeze_on_stop and container.status != 'Frozen':
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))
160 return False160 return False
161 elif not freeze_on_stop and container.status != 'Stopped':161 elif not freeze_on_stop and container.status != 'Stopped':
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))
163 return False163 return False
164164
165 return True165 return True
@@ -178,7 +178,7 @@
178def _sync_application_dirs_to_host(container):178def _sync_application_dirs_to_host(container):
179 host_root = utils.get_libertine_container_rootfs_path(container.name)179 host_root = utils.get_libertine_container_rootfs_path(container.name)
180 for container_path in _CONTAINER_DATA_DIRS:180 for container_path in _CONTAINER_DATA_DIRS:
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))
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)
183183
184 # find a list of files within the container184 # find a list of files within the container
@@ -194,7 +194,7 @@
194194
195 host_path = os.path.join(host_root, filepath.lstrip("/"))195 host_path = os.path.join(host_root, filepath.lstrip("/"))
196 if not os.path.exists(host_path):196 if not os.path.exists(host_path):
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)))
198 os.makedirs(os.path.dirname(host_path), exist_ok=True)198 os.makedirs(os.path.dirname(host_path), exist_ok=True)
199 with open(host_path, 'wb') as f:199 with open(host_path, 'wb') as f:
200 f.write(container.files.get(filepath))200 f.write(container.files.get(filepath))
@@ -230,7 +230,7 @@
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]]
231231
232 if len(broken_host_links) != len(container_link_endpoints):232 if len(broken_host_links) != len(container_link_endpoints):
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."))
234 return234 return
235235
236 for i in range(0, len(broken_host_links)):236 for i in range(0, len(broken_host_links)):
@@ -245,7 +245,8 @@
245 try:245 try:
246 f.write(container.files.get(container_link_endpoints[i]))246 f.write(container.files.get(container_link_endpoints[i]))
247 except pylxd.exceptions.NotFound as e:247 except pylxd.exceptions.NotFound as e:
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}")
249 .format(container_path=container_link_endpoints[i], error=str(e)))
249 continue250 continue
250251
251 subprocess.Popen(_lxc_args(container.name, "ln -sf --relative {} {}".format(252 subprocess.Popen(_lxc_args(container.name, "ln -sf --relative {} {}".format(
@@ -258,7 +259,7 @@
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)
259 find_stdout, stderr = find.communicate()260 find_stdout, stderr = find.communicate()
260 if find.returncode != 0:261 if find.returncode != 0:
261 utils.get_logger().warning("Finding local files to remove failed.")262 utils.get_logger().warning(utils._("Finding local files to remove failed."))
262 return263 return
263264
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]
@@ -271,20 +272,20 @@
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)
272 remove_stdout, stderr = missing_files.communicate()273 remove_stdout, stderr = missing_files.communicate()
273 if missing_files.returncode != 0:274 if missing_files.returncode != 0:
274 utils.get_logger().warning("Checking for missing files failed.")275 utils.get_logger().warning(utils._("Checking for missing files failed."))
275 return276 return
276277
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]:
278 try:279 try:
279 os.remove(f)280 os.remove(f)
280 except PermissionError as e:281 except PermissionError as e:
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)))
282283
283 # now remove any dangling directories284 # now remove any dangling directories
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)
285 empty_out, stderr = empty_dirs.communicate()286 empty_out, stderr = empty_dirs.communicate()
286 if empty_dirs.returncode != 0:287 if empty_dirs.returncode != 0:
287 utils.get_logger().warning("Looking for local empty directories failed.")288 utils.get_logger().warning(utils._("Looking for local empty directories failed."))
288 return289 return
289290
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]
@@ -330,7 +331,7 @@
330331
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('/')):
332 if not os.path.exists(user_dir[0]):333 if not os.path.exists(user_dir[0]):
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]))
334 continue335 continue
335336
336 if os.path.isabs(user_dir[1]):337 if os.path.isabs(user_dir[1]):
@@ -349,7 +350,7 @@
349 'type': 'disk'350 'type': 'disk'
350 }351 }
351352
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))
353354
354355
355def _setup_etc_hosts(container):356def _setup_etc_hosts(container):
@@ -368,13 +369,13 @@
368 try:369 try:
369 profile = client.profiles.get('libertine')370 profile = client.profiles.get('libertine')
370371
371 utils.get_logger().info('Updating existing lxd profile.')372 utils.get_logger().info(utils._('Updating existing lxd profile.'))
372 profile.devices = _get_devices_map()373 profile.devices = _get_devices_map()
373 profile.config['raw.idmap'] = 'both 1000 1000'374 profile.config['raw.idmap'] = 'both 1000 1000'
374375
375 _lxd_save(profile, 'Saving libertine lxd profile raised:')376 _lxd_save(profile, utils._('Saving libertine lxd profile raised:'))
376 except pylxd.exceptions.LXDAPIException:377 except pylxd.exceptions.LXDAPIException:
377 utils.get_logger().info('Creating libertine lxd profile.')378 utils.get_logger().info(utils._('Creating libertine lxd profile.'))
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())
379380
380381
@@ -398,17 +399,19 @@
398399
399 def create_libertine_container(self, password=None, multiarch=False):400 def create_libertine_container(self, password=None, multiarch=False):
400 if self._try_get_container():401 if self._try_get_container():
401 utils.get_logger().error("Container already exists")402 utils.get_logger().error(utils._("Container already exists"))
402 return False403 return False
403404
404 update_libertine_profile(self._lxd_client)405 update_libertine_profile(self._lxd_client)
405406
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}'")
408 .format(container_id=self.container_id, container_distro=self.installed_release))
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 '
408 'default --profile libertine'.format(410 'default --profile libertine'.format(
409 distro=self.installed_release, id=self.container_id)))411 distro=self.installed_release, id=self.container_id)))
410 if create.wait() is not 0:412 if create.wait() is not 0:
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}'")
414 .format(container_id=self.container_id, error_code=create.returncode))
412 return False415 return False
413416
414 self._try_get_container()417 self._try_get_container()
@@ -431,15 +434,16 @@
431 _setup_etc_hosts(self._container)434 _setup_etc_hosts(self._container)
432435
433 if multiarch and self.architecture == 'amd64':436 if multiarch and self.architecture == 'amd64':
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))
435 self.run_in_container("dpkg --add-architecture i386")438 self.run_in_container("dpkg --add-architecture i386")
436439
437 self.update_packages()440 self.update_packages()
438441
439 for package in self.default_packages:442 for package in self.default_packages:
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}'")
444 .format(package_name=package, container_id=self.container_id))
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):
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))
443 self.destroy_libertine_container()447 self.destroy_libertine_container()
444 return False448 return False
445449
@@ -461,7 +465,7 @@
461465
462 def update_packages(self, update_locale=False):466 def update_packages(self, update_locale=False):
463 if not self._timezone_in_sync():467 if not self._timezone_in_sync():
464 utils.get_logger().info("Re-syncing timezones")468 utils.get_logger().info(utils._("Re-syncing timezones"))
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())
466 self.run_in_container("rm -f /etc/localtime")470 self.run_in_container("rm -f /etc/localtime")
467 self.run_in_container("dpkg-reconfigure -f noninteractive tzdata")471 self.run_in_container("dpkg-reconfigure -f noninteractive tzdata")
@@ -474,11 +478,11 @@
474478
475 def destroy_libertine_container(self, force):479 def destroy_libertine_container(self, force):
476 if not self._try_get_container():480 if not self._try_get_container():
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))
478 return False482 return False
479483
480 if self._container.status == 'Running' and not force:484 if self._container.status == 'Running' and not force:
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."))
482 return False486 return False
483487
484 lxd_start(self._container)488 lxd_start(self._container)
@@ -526,7 +530,7 @@
526 self._config.update_container_install_status(self.container_id, "running")530 self._config.update_container_install_status(self.container_id, "running")
527531
528 if not _wait_for_network(self._container):532 if not _wait_for_network(self._container):
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))
530534
531 if requires_remount:535 if requires_remount:
532 self.run_in_container("/usr/bin/libertine-lxd-mount-update")536 self.run_in_container("/usr/bin/libertine-lxd-mount-update")
@@ -555,7 +559,7 @@
555 return False559 return False
556560
557 if self._container.status != 'Frozen':561 if self._container.status != 'Frozen':
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))
559 return False563 return False
560564
561 if not (lxd_stop(self._container) and lxd_start(self._container)):565 if not (lxd_stop(self._container) and lxd_start(self._container)):
@@ -565,7 +569,7 @@
565569
566 def start_application(self, app_exec_line, environ):570 def start_application(self, app_exec_line, environ):
567 if not self._try_get_container():571 if not self._try_get_container():
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))
569 return None573 return None
570574
571 if utils.is_snap_environment():575 if utils.is_snap_environment():
572576
=== modified file 'python/libertine/launcher/config.py'
--- python/libertine/launcher/config.py 2017-02-07 16:32:02 +0000
+++ python/libertine/launcher/config.py 2017-04-06 14:39:25 +0000
@@ -23,10 +23,6 @@
23from .task import TaskType, TaskConfig23from .task import TaskType, TaskConfig
24from .. import utils24from .. import utils
2525
26import gettext
27gettext.textdomain('libertine')
28_ = gettext.gettext
29
30log = utils.get_logger()26log = utils.get_logger()
3127
3228
@@ -129,21 +125,21 @@
129125
130 """126 """
131 log.debug('Config.__init__() begins')127 log.debug('Config.__init__() begins')
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'))
133 arg_parser.add_argument('-i', '--id',129 arg_parser.add_argument('-i', '--id',
134 help=_('Container identifier when launching containerized apps'))130 help=utils._('Container identifier when launching containerized apps'))
135 arg_parser.add_argument('-E', '--env',131 arg_parser.add_argument('-E', '--env',
136 default=[],132 default=[],
137 dest='environ',133 dest='environ',
138 action='append',134 action='append',
139 help=_('Set an environment variable'))135 help=utils._('Set an environment variable'))
140 arg_parser.add_argument('app_exec_line',136 arg_parser.add_argument('app_exec_line',
141 nargs=argparse.REMAINDER,137 nargs=argparse.REMAINDER,
142 help=_('exec line'))138 help=utils._('exec line'))
143 options = arg_parser.parse_args(args=argv)139 options = arg_parser.parse_args(args=argv)
144140
145 if not options.app_exec_line:141 if not options.app_exec_line:
146 arg_parser.error('Must specify an exec line')142 arg_parser.error(utils._('Must specify an exec line'))
147143
148 if options.id:144 if options.id:
149 self.container_id = options.id145 self.container_id = options.id
150146
=== modified file 'python/libertine/launcher/session.py'
--- python/libertine/launcher/session.py 2017-02-23 18:18:29 +0000
+++ python/libertine/launcher/session.py 2017-04-06 14:39:25 +0000
@@ -100,7 +100,7 @@
100 to_socket.sendall(b)100 to_socket.sendall(b)
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))
102 else:102 else:
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))
104 return len(b)104 return len(b)
105 except Exception as e:105 except Exception as e:
106 utils.get_logger().debug(e)106 utils.get_logger().debug(e)
@@ -169,7 +169,7 @@
169 with suppress(AttributeError):169 with suppress(AttributeError):
170 for task_config in self._config.prelaunch_tasks:170 for task_config in self._config.prelaunch_tasks:
171 if task_config.task_type == TaskType.LAUNCH_SERVICE:171 if task_config.task_type == TaskType.LAUNCH_SERVICE:
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]))
173 task = LaunchServiceTask(task_config)173 task = LaunchServiceTask(task_config)
174 self._child_processes.append(task)174 self._child_processes.append(task)
175 task.start(self._config.host_environ)175 task.start(self._config.host_environ)
@@ -329,17 +329,17 @@
329 data = os.read(fd, 4)329 data = os.read(fd, 4)
330 sig = struct.unpack('%uB' % len(data), data)330 sig = struct.unpack('%uB' % len(data), data)
331 if sig[0] == signal.SIGCHLD:331 if sig[0] == signal.SIGCHLD:
332 utils.get_logger().info('SIGCHLD received')332 utils.get_logger().info(utils._('SIGCHLD received'))
333 if self._handle_child_died():333 if self._handle_child_died():
334 raise StopIteration('launched program exited')334 raise StopIteration(utils._('launched program exited'))
335 elif sig[0] == signal.SIGINT:335 elif sig[0] == signal.SIGINT:
336 utils.get_logger().info('SIGINT received')336 utils.get_logger().info(utils._('SIGINT received'))
337 raise StopIteration('keyboard interrupt')337 raise StopIteration(utils._('keyboard interrupt'))
338 elif sig[0] == signal.SIGTERM:338 elif sig[0] == signal.SIGTERM:
339 utils.get_logger().info('SIGTERM received')339 utils.get_logger().info(utils._('SIGTERM received'))
340 raise StopIteration('terminate')340 raise StopIteration(utils._('terminate'))
341 else:341 else:
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]))
343343
344 def _set_signal_handlers(self):344 def _set_signal_handlers(self):
345 """Set the signal handlers."""345 """Set the signal handlers."""
346346
=== modified file 'python/libertine/service/container.py'
--- python/libertine/service/container.py 2017-03-16 19:59:08 +0000
+++ python/libertine/service/container.py 2017-04-06 14:39:25 +0000
@@ -16,7 +16,6 @@
16from libertine import utils16from libertine import utils
17from threading import Lock17from threading import Lock
1818
19
20if not utils.is_snap_environment():19if not utils.is_snap_environment():
21 from libertine.service import apt20 from libertine.service import apt
2221
@@ -33,7 +32,7 @@
33 self._tasks = []32 self._tasks = []
3433
35 if utils.is_snap_environment():34 if utils.is_snap_environment():
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"))
37 self._cache = None36 self._cache = None
38 else:37 else:
39 self._cache = apt.AptCache(self.id)38 self._cache = apt.AptCache(self.id)
4039
=== modified file 'python/libertine/service/container_control_client.py'
--- python/libertine/service/container_control_client.py 2017-03-09 14:40:58 +0000
+++ python/libertine/service/container_control_client.py 2017-04-06 14:39:25 +0000
@@ -40,7 +40,7 @@
40 else:40 else:
41 raise41 raise
42 except:42 except:
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']))
44 if container not in self._invalid_apps:44 if container not in self._invalid_apps:
45 self._invalid_apps[container] = [{app['appExecName'], app['pid']}]45 self._invalid_apps[container] = [{app['appExecName'], app['pid']}]
46 else:46 else:
4747
=== modified file 'python/libertine/utils.py'
--- python/libertine/utils.py 2017-02-15 21:12:37 +0000
+++ python/libertine/utils.py 2017-04-06 14:39:25 +0000
@@ -22,6 +22,10 @@
22import subprocess22import subprocess
23import xdg.BaseDirectory as basedir23import xdg.BaseDirectory as basedir
2424
25import gettext
26gettext.textdomain('libertine')
27_ = gettext.gettext
28
2529
26def get_logger():30def get_logger():
27 logger = logging.getLogger('__libertine_logger__')31 logger = logging.getLogger('__libertine_logger__')
@@ -174,7 +178,7 @@
174 except psutil.NoSuchProcess as e:178 except psutil.NoSuchProcess as e:
175 get_logger().warning(str(e))179 get_logger().warning(str(e))
176 except subprocess.CalledProcessError as e:180 except subprocess.CalledProcessError as e:
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)))
178 dbus_session_set = 'DBUS_SESSION_BUS_ADDRESS' in os.environ182 dbus_session_set = 'DBUS_SESSION_BUS_ADDRESS' in os.environ
179183
180 return dbus_session_set184 return dbus_session_set
181185
=== modified file 'tools/libertine-container-manager'
--- tools/libertine-container-manager 2017-03-23 16:02:52 +0000
+++ tools/libertine-container-manager 2017-04-06 14:39:25 +0000
@@ -19,16 +19,11 @@
19import argparse19import argparse
20import getpass20import getpass
21import json21import json
22import libertine.utils
23import os22import os
24import sys23import sys
25import re24import re
2625
27import gettext26from libertine import ContainerRunning, LibertineContainer, utils
28gettext.textdomain('libertine')
29_ = gettext.gettext
30
31from libertine import ContainerRunning, LibertineContainer
32from libertine.ContainersConfig import ContainersConfig27from libertine.ContainersConfig import ContainersConfig
33from libertine.HostInfo import HostInfo28from libertine.HostInfo import HostInfo
3429
@@ -45,7 +40,7 @@
45 return LibertineContainer(container_id, self.containers_config)40 return LibertineContainer(container_id, self.containers_config)
46 except ImportError as e:41 except ImportError as e:
47 container_type = self.containers_config.get_container_type(container_id)42 container_type = self.containers_config.get_container_type(container_id)
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 "
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))
50 sys.exit(1)45 sys.exit(1)
5146
@@ -61,14 +56,15 @@
61 password = None56 password = None
6257
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):
64 libertine.utils.get_logger().error("Invalid distro %s" % args.distro)59 utils.get_logger().error(utils._("Invalid distro {distro}").format(distro=args.distro))
65 sys.exit(1)60 sys.exit(1)
6661
67 if self.containers_config.container_exists(args.id):62 if self.containers_config.container_exists(args.id):
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))
69 sys.exit(1)64 sys.exit(1)
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:
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 "
67 "form ([a-z0-9][a-z0-9+.-]+).").format(container_id=args.id))
72 sys.exit(1)68 sys.exit(1)
7369
74 if not args.type:70 if not args.type:
@@ -76,8 +72,8 @@
76 else:72 else:
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 \
78 (args.type == 'lxd' and not self.host_info.has_lxd_support()):74 (args.type == 'lxd' and not self.host_info.has_lxd_support()):
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. "
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))
81 sys.exit(1)77 sys.exit(1)
82 container_type = args.type78 container_type = args.type
8379
@@ -87,9 +83,9 @@
87 host_distro = self.host_info.get_host_distro_release()83 host_distro = self.host_info.get_host_distro_release()
8884
89 if args.distro != host_distro:85 if args.distro != host_distro:
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"
91 " based containers. Please either use \'%s\' or omit the -d/--distro option."87 " based containers. Please either use '{host_distro}' or"
92 % host_distro)88 " omit the -d/--distro option.").format(host_distro=host_distro))
93 sys.exit(1)89 sys.exit(1)
9490
95 if not args.name:91 if not args.name:
@@ -99,7 +95,7 @@
99 if args.password:95 if args.password:
100 password = args.password96 password = args.password
101 elif sys.stdin.isatty():97 elif sys.stdin.isatty():
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:"))
103 password = getpass.getpass()99 password = getpass.getpass()
104 else:100 else:
105 password = sys.stdin.readline().rstrip()101 password = sys.stdin.readline().rstrip()
@@ -117,21 +113,21 @@
117 try:113 try:
118 self.containers_config.update_container_install_status(args.id, "installing")114 self.containers_config.update_container_install_status(args.id, "installing")
119 if not container.create_libertine_container(password, args.multiarch):115 if not container.create_libertine_container(password, args.multiarch):
120 libertine.utils.get_logger().error("Failed to create container")116 utils.get_logger().error(utils._("Failed to create container"))
121 self.containers_config.delete_container(args.id)117 self.containers_config.delete_container(args.id)
122 sys.exit(1)118 sys.exit(1)
123 except Exception as e:119 except Exception as e:
124 container.destroy_libertine_container(force=True)120 container.destroy_libertine_container(force=True)
125 raise121 raise
126 except Exception as e:122 except Exception as e:
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)))
128124
129 self.containers_config.delete_container(args.id)125 self.containers_config.delete_container(args.id)
130 sys.exit(1)126 sys.exit(1)
131127
132 self.containers_config.update_container_install_status(args.id, "ready")128 self.containers_config.update_container_install_status(args.id, "ready")
133129
134 libertine.utils.refresh_libertine_scope()130 utils.refresh_libertine_scope()
135131
136 def destroy_container(self, container, force):132 def destroy_container(self, container, force):
137 fallback = self.containers_config.get_container_install_status(container.container_id)133 fallback = self.containers_config.get_container_install_status(container.container_id)
@@ -150,7 +146,7 @@
150146
151 self.destroy_container(container, args.force)147 self.destroy_container(container, args.force)
152148
153 libertine.utils.refresh_libertine_scope()149 utils.refresh_libertine_scope()
154150
155 def install_package(self, args):151 def install_package(self, args):
156 container_id = self.containers_config.check_container_id(args.id)152 container_id = self.containers_config.check_container_id(args.id)
@@ -166,9 +162,9 @@
166162
167 if is_debian_package:163 if is_debian_package:
168 if os.path.exists(pkg):164 if os.path.exists(pkg):
169 package = libertine.utils.get_deb_package_name(pkg)165 package = utils.get_deb_package_name(pkg)
170 else:166 else:
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))
172 failure = True168 failure = True
173 continue169 continue
174 else:170 else:
@@ -176,7 +172,7 @@
176172
177 if self.containers_config.package_exists(container_id, package):173 if self.containers_config.package_exists(container_id, package):
178 if not is_debian_package:174 if not is_debian_package:
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))
180 failure = True176 failure = True
181 continue177 continue
182 else:178 else:
@@ -184,15 +180,15 @@
184180
185 self.containers_config.update_package_install_status(container_id, package, "installing")181 self.containers_config.update_package_install_status(container_id, package, "installing")
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):
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}'")
188 .format(package, container_id))184 .format(package_name=package, container_id=container_id))
189 self.containers_config.delete_package(container_id, package)185 self.containers_config.delete_package(container_id, package)
190 failure = True186 failure = True
191 continue187 continue
192188
193 self.containers_config.update_package_install_status(container_id, package, "installed")189 self.containers_config.update_package_install_status(container_id, package, "installed")
194190
195 libertine.utils.refresh_libertine_scope()191 utils.refresh_libertine_scope()
196192
197 if failure:193 if failure:
198 sys.exit(1)194 sys.exit(1)
@@ -221,17 +217,17 @@
221 continue217 continue
222218
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':
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))
225 failure = True221 failure = True
226 continue222 continue
227223
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):
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}'")
230 .format(pkg, container_id))226 .format(package_name=pkg, container_id=container_id))
231 failure = True227 failure = True
232 continue228 continue
233229
234 libertine.utils.refresh_libertine_scope()230 utils.refresh_libertine_scope()
235231
236 if failure:232 if failure:
237 sys.exit(1)233 sys.exit(1)
@@ -241,8 +237,8 @@
241 container = self._container(container_id)237 container = self._container(container_id)
242238
243 if container.search_package_cache(args.search_string) is not 0:239 if container.search_package_cache(args.search_string) is not 0:
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")
245 .format(args.id, args.search_string))241 .format(container_id=args.id, query_string=args.search_string))
246 sys.exit(1)242 sys.exit(1)
247243
248 def update(self, args):244 def update(self, args):
@@ -300,7 +296,7 @@
300296
301 current_multiarch = self.containers_config.get_container_multiarch_support(container_id)297 current_multiarch = self.containers_config.get_container_multiarch_support(container_id)
302 if current_multiarch == multiarch:298 if current_multiarch == multiarch:
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))
304 sys.exit(1)300 sys.exit(1)
305301
306 if container.configure_multiarch(args.multiarch) is not 0:302 if container.configure_multiarch(args.multiarch) is not 0:
@@ -310,7 +306,7 @@
310306
311 elif args.archive is not None:307 elif args.archive is not None:
312 if args.archive_name is None:308 if args.archive_name is None:
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."))
314 sys.exit(1)310 sys.exit(1)
315311
316 archive_name = args.archive_name.strip("\'\"")312 archive_name = args.archive_name.strip("\'\"")
@@ -318,7 +314,7 @@
318314
319 if args.archive == 'add':315 if args.archive == 'add':
320 if self.containers_config.archive_exists(container_id, archive_name):316 if self.containers_config.archive_exists(container_id, archive_name):
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))
322 sys.exit(1)318 sys.exit(1)
323319
324 self.containers_config.add_container_archive(container_id, archive_name)320 self.containers_config.add_container_archive(container_id, archive_name)
@@ -331,43 +327,48 @@
331327
332 elif args.archive == 'remove':328 elif args.archive == 'remove':
333 if not self.containers_config.archive_exists(container_id, archive_name):329 if not self.containers_config.archive_exists(container_id, archive_name):
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))
335 sys.exit(1)331 sys.exit(1)
336332
337 if not self.delete_archive_by_name(container, archive_name):333 if not self.delete_archive_by_name(container, archive_name):
338334
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))
340 sys.exit(1)336 sys.exit(1)
341337
342 elif args.bind_mount is not None:338 elif args.bind_mount is not None:
343 if args.mount_path is None:339 if args.mount_path is None:
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"))
345 sys.exit(1)341 sys.exit(1)
346342
347 mount_path = args.mount_path.rstrip('/').strip('"')343 mount_path = args.mount_path.rstrip('/').strip('"')
348344
349 # validate bind-mount345 # validate bind-mount
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']):
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 "
348 "/media/{username}.").format(mount_path=mount_path, \
349 home_dir=os.environ['HOME'], username=os.environ['USER']))
352 sys.exit(1)350 sys.exit(1)
353 if mount_path.startswith('/media/%s' % os.environ['USER']) and \351 if mount_path.startswith('/media/%s' % os.environ['USER']) and \
354 self.containers_config.get_container_type(container_id) == 'lxc':352 self.containers_config.get_container_type(container_id) == 'lxc':
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."))
356 sys.exit(1)354 sys.exit(1)
357 if not os.path.isdir(mount_path):355 if not os.path.isdir(mount_path):
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 "
357 "directory.").format(mount_path=mount_path))
359 sys.exit(1)358 sys.exit(1)
360359
361 # update database with new bind-mount360 # update database with new bind-mount
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)
363 if args.bind_mount == 'add':362 if args.bind_mount == 'add':
364 if mount_path in container_bind_mounts:363 if mount_path in container_bind_mounts:
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 "
365 "already exists.").format(mount_path=mount_path))
366 sys.exit(1)366 sys.exit(1)
367 self.containers_config.add_new_bind_mount(container_id, mount_path)367 self.containers_config.add_new_bind_mount(container_id, mount_path)
368 elif args.bind_mount == 'remove':368 elif args.bind_mount == 'remove':
369 if mount_path not in container_bind_mounts:369 if mount_path not in container_bind_mounts:
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 "
371 "does not exist.").format(mount_path=mount_path))
371 sys.exit(1)372 sys.exit(1)
372 self.containers_config.delete_bind_mount(container_id, mount_path)373 self.containers_config.delete_bind_mount(container_id, mount_path)
373374
@@ -376,20 +377,20 @@
376 if (container_type == 'lxc' or container_type == 'lxd' and377 if (container_type == 'lxc' or container_type == 'lxd' and
377 self.containers_config.get_freeze_on_stop(container_id)):378 self.containers_config.get_freeze_on_stop(container_id)):
378 if not container.restart_libertine_container():379 if not container.restart_libertine_container():
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 "
380 "restart the container at a later time using the \'restart\' subcommand.")381 "restart the container at a later time using the 'restart' subcommand."))
381382
382 elif args.freeze is not None:383 elif args.freeze is not None:
383 container_type = self.containers_config.get_container_type(container_id)384 container_type = self.containers_config.get_container_type(container_id)
384385
385 if container_type != 'lxc' and container_type != 'lxd':386 if container_type != 'lxc' and container_type != 'lxd':
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."))
387 sys.exit(1)388 sys.exit(1)
388389
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')
390391
391 else:392 else:
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."))
393 sys.exit(1)394 sys.exit(1)
394395
395396
@@ -430,7 +431,7 @@
430 container_type = self.containers_config.get_container_type(container_id)431 container_type = self.containers_config.get_container_type(container_id)
431432
432 if container_type != 'lxc' and container_type != 'lxd':433 if container_type != 'lxc' and container_type != 'lxd':
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."))
434 sys.exit(1)435 sys.exit(1)
435436
436 container = self._container(container_id)437 container = self._container(container_id)
@@ -439,20 +440,20 @@
439440
440441
441if __name__ == '__main__':442if __name__ == '__main__':
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"))
443444
444 if not os.geteuid():445 if not os.geteuid():
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))
446 sys.exit(1)447 sys.exit(1)
447448
448 container_manager = LibertineContainerManager()449 container_manager = LibertineContainerManager()
449450
450 parser.add_argument('-q', '--quiet',451 parser.add_argument('-q', '--quiet',
451 action='store_const', dest='verbosity', const=0,452 action='store_const', dest='verbosity', const=0,
452 help=('disables all non-vital output'))453 help=utils._('disables all non-vital output'))
453 parser.add_argument('-v', '--verbosity',454 parser.add_argument('-v', '--verbosity',
454 action='store_const', dest='verbosity', const=2,455 action='store_const', dest='verbosity', const=2,
455 help=('enables debug output'))456 help=utils._('enables debug output'))
456 subparsers = parser.add_subparsers(dest="subparser_name",457 subparsers = parser.add_subparsers(dest="subparser_name",
457 title="subcommands",458 title="subcommands",
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')
@@ -460,186 +461,186 @@
460 # Handle the create command and its options461 # Handle the create command and its options
461 parser_create = subparsers.add_parser(462 parser_create = subparsers.add_parser(
462 'create',463 'create',
463 help=("Create a new Libertine container."))464 help=utils._("Create a new Libertine container."))
464 parser_create.add_argument(465 parser_create.add_argument(
465 '-i', '--id',466 '-i', '--id',
466 required=True,467 required=True,
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."))
468 parser_create.add_argument(469 parser_create.add_argument(
469 '-t', '--type',470 '-t', '--type',
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'."))
471 parser_create.add_argument(472 parser_create.add_argument(
472 '-d', '--distro',473 '-d', '--distro',
473 help=("Ubuntu distro series to create."))474 help=utils._("Ubuntu distro series to create."))
474 parser_create.add_argument(475 parser_create.add_argument(
475 '-n', '--name',476 '-n', '--name',
476 help=("User friendly container name."))477 help=utils._("User friendly container name."))
477 parser_create.add_argument(478 parser_create.add_argument(
478 '--force', action='store_true',479 '--force', action='store_true',
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 "
480 "it is no longer supported."))481 "it is no longer supported."))
481 parser_create.add_argument(482 parser_create.add_argument(
482 '-m', '--multiarch', action='store_true',483 '-m', '--multiarch', action='store_true',
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 "
484 "no effect when the Libertine container is i386."))485 "no effect when the Libertine container is i386."))
485 parser_create.add_argument(486 parser_create.add_argument(
486 '--password',487 '--password',
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 "
488 "is intended for testing only and is very insecure."))489 "is intended for testing only and is very insecure."))
489 parser_create.set_defaults(func=container_manager.create)490 parser_create.set_defaults(func=container_manager.create)
490491
491 # Handle the destroy command and its options492 # Handle the destroy command and its options
492 parser_destroy = subparsers.add_parser(493 parser_destroy = subparsers.add_parser(
493 'destroy',494 'destroy',
494 help=("Destroy any existing environment entirely."))495 help=utils._("Destroy any existing environment entirely."))
495 parser_destroy.add_argument(496 parser_destroy.add_argument(
496 '-i', '--id',497 '-i', '--id',
497 help=("Container identifier. Default container is used if omitted."))498 help=utils._("Container identifier. Default container is used if omitted."))
498 parser_destroy.add_argument(499 parser_destroy.add_argument(
499 '-f', '--force', action='store_true', required=False,500 '-f', '--force', action='store_true', required=False,
500 help=("Force destroy. Forces running containers to stop before destruction."))501 help=utils._("Force destroy. Forces running containers to stop before destruction."))
501 parser_destroy.set_defaults(func=container_manager.destroy)502 parser_destroy.set_defaults(func=container_manager.destroy)
502503
503 # Handle the install-package command and its options504 # Handle the install-package command and its options
504 parser_install = subparsers.add_parser(505 parser_install = subparsers.add_parser(
505 'install-package',506 'install-package',
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."))
507 parser_install.add_argument(508 parser_install.add_argument(
508 '-p', '--package',509 '-p', '--package',
509 required=True,510 required=True,
510 nargs='+',511 nargs='+',
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 "
512 "can be entered, separated by a space. Required."))513 "can be entered, separated by a space. Required."))
513 parser_install.add_argument(514 parser_install.add_argument(
514 '-i', '--id',515 '-i', '--id',
515 help=("Container identifier. Default container is used if omitted."))516 help=utils._("Container identifier. Default container is used if omitted."))
516 parser_install.add_argument(517 parser_install.add_argument(
517 '-n', '--no-dialog', action='store_true',518 '-n', '--no-dialog', action='store_true',
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."))
519 parser_install.set_defaults(func=container_manager.install_package)520 parser_install.set_defaults(func=container_manager.install_package)
520521
521 # Handle the remove-package command and its options522 # Handle the remove-package command and its options
522 parser_remove = subparsers.add_parser(523 parser_remove = subparsers.add_parser(
523 'remove-package',524 'remove-package',
524 help=("Remove a package in the specified Libertine container."))525 help=utils._("Remove a package in the specified Libertine container."))
525 parser_remove.add_argument(526 parser_remove.add_argument(
526 '-p', '--package',527 '-p', '--package',
527 required=True,528 required=True,
528 nargs='+',529 nargs='+',
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 "
530 "by a space. Required."))531 "by a space. Required."))
531 parser_remove.add_argument(532 parser_remove.add_argument(
532 '-i', '--id',533 '-i', '--id',
533 help=("Container identifier. Default container is used if omitted."))534 help=utils._("Container identifier. Default container is used if omitted."))
534 parser_remove.add_argument(535 parser_remove.add_argument(
535 '-n', '--no-dialog', action='store_true',536 '-n', '--no-dialog', action='store_true',
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."))
537 parser_remove.set_defaults(func=container_manager.remove_package)538 parser_remove.set_defaults(func=container_manager.remove_package)
538539
539 # Handle the search-cache command and its options540 # Handle the search-cache command and its options
540 parser_search = subparsers.add_parser(541 parser_search = subparsers.add_parser(
541 'search-cache',542 'search-cache',
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."))
543 parser_search.add_argument(544 parser_search.add_argument(
544 '-s', '--search-string',545 '-s', '--search-string',
545 required=True,546 required=True,
546 help=("String to search for in the package cache. Required."))547 help=utils._("String to search for in the package cache. Required."))
547 parser_search.add_argument(548 parser_search.add_argument(
548 '-i', '--id',549 '-i', '--id',
549 help=("Container identifier. Default container is used if omitted."))550 help=utils._("Container identifier. Default container is used if omitted."))
550 parser_search.set_defaults(func=container_manager.search_cache)551 parser_search.set_defaults(func=container_manager.search_cache)
551552
552 # Handle the update command and its options553 # Handle the update command and its options
553 parser_update = subparsers.add_parser(554 parser_update = subparsers.add_parser(
554 'update',555 'update',
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 "
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."))
557 parser_update.add_argument(558 parser_update.add_argument(
558 '-i', '--id',559 '-i', '--id',
559 help=("Container identifier. Default container is used if omitted."))560 help=utils._("Container identifier. Default container is used if omitted."))
560 parser_update.set_defaults(func=container_manager.update)561 parser_update.set_defaults(func=container_manager.update)
561562
562 # Handle the list command563 # Handle the list command
563 parser_list = subparsers.add_parser(564 parser_list = subparsers.add_parser(
564 "list",565 "list",
565 help=("List all Libertine containers."))566 help=utils._("List all Libertine containers."))
566 parser_list.set_defaults(func=container_manager.list)567 parser_list.set_defaults(func=container_manager.list)
567568
568 # Handle the list-apps command and its options569 # Handle the list-apps command and its options
569 parser_list_apps = subparsers.add_parser(570 parser_list_apps = subparsers.add_parser(
570 'list-apps',571 'list-apps',
571 help=("List available app launchers in a container."))572 help=utils._("List available app launchers in a container."))
572 parser_list_apps.add_argument(573 parser_list_apps.add_argument(
573 '-i', '--id',574 '-i', '--id',
574 help=("Container identifier. Default container is used if omitted."))575 help=utils._("Container identifier. Default container is used if omitted."))
575 parser_list_apps.add_argument(576 parser_list_apps.add_argument(
576 '-j', '--json',577 '-j', '--json',
577 action='store_true',578 action='store_true',
578 help=("use JSON output format."))579 help=utils._("use JSON output format."))
579 parser_list_apps.set_defaults(func=container_manager.list_apps)580 parser_list_apps.set_defaults(func=container_manager.list_apps)
580581
581 # Handle the execute command and it's options582 # Handle the execute command and it's options
582 parser_exec = subparsers.add_parser(583 parser_exec = subparsers.add_parser(
583 'exec',584 'exec',
584 add_help=False)585 add_help=False)
585 #help=("Run an arbitrary command in the specified Libertine container."))586 #help=utils._("Run an arbitrary command in the specified Libertine container."))
586 parser_exec.add_argument(587 parser_exec.add_argument(
587 '-i', '--id',588 '-i', '--id',
588 help=("Container identifier. Default container is used if omitted."))589 help=utils._("Container identifier. Default container is used if omitted."))
589 parser_exec.add_argument(590 parser_exec.add_argument(
590 '-c', '--command',591 '-c', '--command',
591 help=("The command to run in the specified container."))592 help=utils._("The command to run in the specified container."))
592 parser_exec.set_defaults(func=container_manager.exec)593 parser_exec.set_defaults(func=container_manager.exec)
593594
594 # Handle the configure command and it's options595 # Handle the configure command and it's options
595 parser_configure = subparsers.add_parser(596 parser_configure = subparsers.add_parser(
596 'configure',597 'configure',
597 help=("Configure various options in the specified Libertine container."))598 help=utils._("Configure various options in the specified Libertine container."))
598 parser_configure.add_argument(599 parser_configure.add_argument(
599 '-i', '--id',600 '-i', '--id',
600 help=("Container identifier. Default container is used if omitted."))601 help=utils._("Container identifier. Default container is used if omitted."))
601 multiarch_group = parser_configure.add_argument_group("Multiarch support",602 multiarch_group = parser_configure.add_argument_group(utils._("Multiarch support"),
602 "Enable or disable multiarch support for a container.")603 utils._("Enable or disable multiarch support for a container."))
603 multiarch_group.add_argument(604 multiarch_group.add_argument(
604 '-m', '--multiarch',605 '-m', '--multiarch',
605 choices=['enable', 'disable'],606 choices=['enable', 'disable'],
606 help=("Enables or disables i386 multiarch support for amd64 Libertine "607 help=utils._("Enables or disables i386 multiarch support for amd64 Libertine "
607 "containers. This option has no effect when the Libertine "608 "containers. This option has no effect when the Libertine "
608 "container is i386."))609 "container is i386."))
609610
610 archive_group = parser_configure.add_argument_group("Additional archive support",611 archive_group = parser_configure.add_argument_group(utils._("Additional archive support"),
611 "Add or delete an additional archive (PPA).")612 utils._("Add or delete an additional archive (PPA)."))
612 archive_group.add_argument(613 archive_group.add_argument(
613 '-a', '--archive',614 '-a', '--archive',
614 choices=['add', 'remove'],615 choices=['add', 'remove'],
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."))
616 archive_group.add_argument(617 archive_group.add_argument(
617 '-n', '--archive-name',618 '-n', '--archive-name',
618 metavar='Archive name',619 metavar=utils._('Archive name'),
619 help=("Archive name to be added or removed."))620 help=utils._("Archive name to be added or removed."))
620 archive_group.add_argument(621 archive_group.add_argument(
621 '-k', '--public-key-file',622 '-k', '--public-key-file',
622 metavar='Public key file',623 metavar=utils._('Public key file'),
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. "
624 "Useful for third-party or private archives."))625 "Useful for third-party or private archives."))
625626
626 mount_group = parser_configure.add_argument_group("Additional bind-mounts",627 mount_group = parser_configure.add_argument_group(utils._("Additional bind-mounts"),
627 "Add or delete an additional bind-mount.")628 utils._("Add or delete an additional bind-mount."))
628 mount_group.add_argument(629 mount_group.add_argument(
629 '-b', '--bind-mount',630 '-b', '--bind-mount',
630 choices=['add', 'remove'],631 choices=['add', 'remove'],
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."))
632 mount_group.add_argument(633 mount_group.add_argument(
633 '-p', '--mount-path',634 '-p', '--mount-path',
634 metavar='Mount path',635 metavar=utils._('Mount path'),
635 help=("The absolute host path to bind-mount."))636 help=utils._("The absolute host path to bind-mount."))
636637
637 freeze_group = parser_configure.add_argument_group("Freeze container support",638 freeze_group = parser_configure.add_argument_group(utils._("Freeze container support"),
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."))
639 freeze_group.add_argument(640 freeze_group.add_argument(
640 '-f', '--freeze',641 '-f', '--freeze',
641 choices=['enable', 'disable'],642 choices=['enable', 'disable'],
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."
643 " When disabled, the container will stop."))644 " When disabled, the container will stop."))
644645
645 parser_configure.set_defaults(func=container_manager.configure)646 parser_configure.set_defaults(func=container_manager.configure)
@@ -662,30 +663,30 @@
662 # Set the default container in ContainersConfig663 # Set the default container in ContainersConfig
663 parser_default = subparsers.add_parser(664 parser_default = subparsers.add_parser(
664 'set-default',665 'set-default',
665 help=("Set the default container."))666 help=utils._("Set the default container."))
666 parser_default.add_argument(667 parser_default.add_argument(
667 '-i', '--id',668 '-i', '--id',
668 metavar='Container id',669 metavar=utils._('Container id'),
669 help=("Container identifier. Default container is used if omitted."))670 help=utils._("Container identifier. Default container is used if omitted."))
670 parser_default.add_argument(671 parser_default.add_argument(
671 '-c', '--clear', action='store_true',672 '-c', '--clear', action='store_true',
672 help=("Clear the default container."))673 help=utils._("Clear the default container."))
673 parser_default.set_defaults(func=container_manager.set_default)674 parser_default.set_defaults(func=container_manager.set_default)
674675
675 # Handle the restart command and its options676 # Handle the restart command and its options
676 parser_update = subparsers.add_parser(677 parser_update = subparsers.add_parser(
677 'restart',678 'restart',
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 "
679 "and LXD type containers."))680 "and LXD type containers."))
680 parser_update.add_argument(681 parser_update.add_argument(
681 '-i', '--id',682 '-i', '--id',
682 help=("Container identifier. Default container is used if omitted."))683 help=utils._("Container identifier. Default container is used if omitted."))
683 parser_update.set_defaults(func=container_manager.restart)684 parser_update.set_defaults(func=container_manager.restart)
684685
685 # Actually parse the args686 # Actually parse the args
686 args = parser.parse_args()687 args = parser.parse_args()
687688
688 libertine.utils.set_environmental_verbosity(args.verbosity)689 utils.set_environmental_verbosity(args.verbosity)
689690
690 if args.subparser_name == None:691 if args.subparser_name == None:
691 parser.print_help()692 parser.print_help()
692693
=== modified file 'tools/libertine-launch'
--- tools/libertine-launch 2017-03-14 15:31:27 +0000
+++ tools/libertine-launch 2017-04-06 14:39:25 +0000
@@ -19,11 +19,7 @@
19import os19import os
20import sys20import sys
2121
22import gettext22from libertine import launcher, utils
23gettext.textdomain('libertine')
24_ = gettext.gettext
25
26from libertine import launcher
2723
28def main():24def main():
29 config = launcher.Config()25 config = launcher.Config()
@@ -31,7 +27,7 @@
31 if config.container_id:27 if config.container_id:
32 from libertine import ContainersConfig, utils28 from libertine import ContainersConfig, utils
33 if not ContainersConfig.ContainersConfig().container_exists(config.container_id):29 if not ContainersConfig.ContainersConfig().container_exists(config.container_id):
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))
35 sys.exit(1)31 sys.exit(1)
3632
37 try:33 try:
@@ -39,8 +35,8 @@
39 container = LibertineContainer(container_id=config.container_id)35 container = LibertineContainer(container_id=config.container_id)
40 except ImportError as e:36 except ImportError as e:
41 container_type = self.containers_config.get_container_type(container_id)37 container_type = self.containers_config.get_container_type(container_id)
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 "
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))
44 sys.exit(1)40 sys.exit(1)
45 else:41 else:
46 from libertine import NoContainer42 from libertine import NoContainer
4743
=== modified file 'tools/libertined'
--- tools/libertined 2017-04-03 19:59:26 +0000
+++ tools/libertined 2017-04-06 14:39:25 +0000
@@ -30,13 +30,13 @@
3030
31class Config(object):31class Config(object):
32 def __init__(self):32 def __init__(self):
33 self._arg_parser = argparse.ArgumentParser(description=u'Libertine Store service')33 self._arg_parser = argparse.ArgumentParser(description=utils._('Libertine Store service'))
34 self._arg_parser.add_argument('-q', '--quiet', action='store_const',34 self._arg_parser.add_argument('-q', '--quiet', action='store_const',
35 dest='verbosity', const=0,35 dest='verbosity', const=0,
36 help=('disables all non-vital output'))36 help=utils._('disables all non-vital output'))
37 self._arg_parser.add_argument('-v', '--verbosity', action='store_const',37 self._arg_parser.add_argument('-v', '--verbosity', action='store_const',
38 dest='verbosity', const=2,38 dest='verbosity', const=2,
39 help=('enables debug output'))39 help=utils._('enables debug output'))
40 args = self._arg_parser.parse_args(namespace=Config)40 args = self._arg_parser.parse_args(namespace=Config)
4141
4242
@@ -54,7 +54,7 @@
54 self.shutdown()54 self.shutdown()
5555
56 def shutdown(self):56 def shutdown(self):
57 utils.get_logger().info("shutting service down")57 utils.get_logger().info(utils._("shutting service down"))
58 self.loop.quit()58 self.loop.quit()
5959
60 def run(self):60 def run(self):
@@ -65,15 +65,15 @@
65def main():65def main():
66 config = Config()66 config = Config()
6767
68 utils.get_logger().info("Initializing libertined...")68 utils.get_logger().info(utils._("Initializing libertined..."))
69 loop = Loop()69 loop = Loop()
7070
71 try:71 try:
72 bus_name = dbus.service.BusName(constants.SERVICE_NAME,72 bus_name = dbus.service.BusName(constants.SERVICE_NAME,
73 bus=dbus.SessionBus(),73 bus=dbus.SessionBus(),
74 do_not_queue=True)74 do_not_queue=True)
75 except dbus.exceptions.NameExistsException:75 except dbus.exceptions.NameExistsException:
76 utils.get_logger().warning("service is already running")76 utils.get_logger().warning(utils._("service is already running"))
77 raise77 raise
7878
79 client = container_control_client.ContainerControlClient()79 client = container_control_client.ContainerControlClient()
@@ -81,12 +81,12 @@
81 container_control.ContainerControl(manager.connection, client)81 container_control.ContainerControl(manager.connection, client)
8282
83 try:83 try:
84 utils.get_logger().info("libertined ready")84 utils.get_logger().info(utils._("libertined ready"))
85 loop.run()85 loop.run()
86 except KeyboardInterrupt:86 except KeyboardInterrupt:
87 utils.get_logger().debug("keyboard interrupt received")87 utils.get_logger().debug("keyboard interrupt received")
88 except Exception as e:88 except Exception as e:
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)))
90 finally:90 finally:
91 loop.shutdown()91 loop.shutdown()
9292

Subscribers

People subscribed via source and target branches