Merge lp:~larryprice/libertine/no-such-backend into lp:libertine
- no-such-backend
- Merge into devel
Status: | Merged |
---|---|
Approved by: | Stephen M. Webb |
Approved revision: | 412 |
Merged at revision: | 442 |
Proposed branch: | lp:~larryprice/libertine/no-such-backend |
Merge into: | lp:libertine |
Diff against target: |
166 lines (+38/-14) 2 files modified
tools/libertine-container-manager (+26/-12) tools/libertine-launch (+12/-2) |
To merge this branch: | bzr merge lp:~larryprice/libertine/no-such-backend |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Stephen M. Webb (community) | Approve | ||
Libertine CI Bot | continuous-integration | Approve | |
Review via email: mp+319724@code.launchpad.net |
Commit message
Gracefully handle creating a LibertineContainer object when the container backend is unavailable.
Description of the change
Gracefully handle creating a LibertineContainer object when the container backend is unavailable.
- 410. By Larry Price
-
also in libertine-launch
Libertine CI Bot (libertine-ci-bot) wrote : | # |
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:410
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Stephen M. Webb (bregma) wrote : | # |
Need to add i18n for the user-facing messages. See python/
- 411. By Larry Price
-
add gettext support for new strings
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:411
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Stephen M. Webb (bregma) wrote : | # |
Need to use positional {0} or named {container_id} substitution in the .format() strings.
- 412. By Larry Price
-
give names to format args
Libertine CI Bot (libertine-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:412
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Stephen M. Webb (bregma) : | # |
Preview Diff
1 | === modified file 'tools/libertine-container-manager' |
2 | --- tools/libertine-container-manager 2017-03-03 18:34:34 +0000 |
3 | +++ tools/libertine-container-manager 2017-03-14 15:31:47 +0000 |
4 | @@ -24,6 +24,10 @@ |
5 | import sys |
6 | import re |
7 | |
8 | +import gettext |
9 | +gettext.textdomain('libertine') |
10 | +_ = gettext.gettext |
11 | + |
12 | from libertine import ContainerRunning, LibertineContainer |
13 | from libertine.ContainersConfig import ContainersConfig |
14 | from libertine.HostInfo import HostInfo |
15 | @@ -35,6 +39,16 @@ |
16 | self.containers_config = ContainersConfig() |
17 | self.host_info = HostInfo() |
18 | |
19 | + |
20 | + def _container(self, container_id): |
21 | + try: |
22 | + return LibertineContainer(container_id, self.containers_config) |
23 | + except ImportError as e: |
24 | + container_type = self.containers_config.get_container_type(container_id) |
25 | + libertine.utils.get_logger().error(_("Backend for container '{id}' not installed. Install " |
26 | + "'python3-libertine-{type}' and try again.").format(id=container_id, type=container_type)) |
27 | + sys.exit(1) |
28 | + |
29 | def _get_updated_locale(self, container_id): |
30 | host_locale = self.host_info.get_host_locale() |
31 | |
32 | @@ -99,7 +113,7 @@ |
33 | |
34 | try: |
35 | self.containers_config.update_container_locale(args.id, self.host_info.get_host_locale()) |
36 | - container = LibertineContainer(args.id) |
37 | + container = LibertineContainer(args.id, self.containers_config) |
38 | self.containers_config.update_container_install_status(args.id, "installing") |
39 | if not container.create_libertine_container(password, args.multiarch): |
40 | libertine.utils.get_logger().error("Failed to create container") |
41 | @@ -130,7 +144,7 @@ |
42 | |
43 | def destroy(self, args): |
44 | container_id = self.containers_config.check_container_id(args.id) |
45 | - container = LibertineContainer(container_id, self.containers_config) |
46 | + container = self._container(container_id) |
47 | |
48 | self.destroy_container(container, args.force) |
49 | |
50 | @@ -138,7 +152,7 @@ |
51 | |
52 | def install_package(self, args): |
53 | container_id = self.containers_config.check_container_id(args.id) |
54 | - container = LibertineContainer(container_id, self.containers_config) |
55 | + container = self._container(container_id) |
56 | failure = False |
57 | |
58 | with ContainerRunning(container.container): |
59 | @@ -193,7 +207,7 @@ |
60 | |
61 | def remove_package(self, args): |
62 | container_id = self.containers_config.check_container_id(args.id) |
63 | - container = LibertineContainer(container_id) |
64 | + container = self._container(container_id) |
65 | failure = False |
66 | |
67 | with ContainerRunning(container.container): |
68 | @@ -216,8 +230,8 @@ |
69 | |
70 | def search_cache(self, args): |
71 | container_id = self.containers_config.check_container_id(args.id) |
72 | + container = self._container(container_id) |
73 | |
74 | - container = LibertineContainer(container_id) |
75 | if container.search_package_cache(args.search_string) is not 0: |
76 | libertine.utils.get_logger().error("Search for '{}' in container '{}' exited with non-zero status" |
77 | .format(args.id, args.search_string)) |
78 | @@ -225,10 +239,10 @@ |
79 | |
80 | def update(self, args): |
81 | container_id = self.containers_config.check_container_id(args.id) |
82 | + container = self._container(container_id) |
83 | + |
84 | new_locale = self._get_updated_locale(container_id) |
85 | |
86 | - container = LibertineContainer(container_id) |
87 | - |
88 | if not container.update_libertine_container(new_locale): |
89 | sys.exit(1) |
90 | |
91 | @@ -242,7 +256,7 @@ |
92 | def list_apps(self, args): |
93 | container_id = self.containers_config.check_container_id(args.id) |
94 | |
95 | - app_ids = LibertineContainer(container_id).list_app_ids() |
96 | + app_ids = self._container(container_id).list_app_ids() |
97 | if args.json: |
98 | print(json.dumps(app_ids)) |
99 | else: |
100 | @@ -252,7 +266,7 @@ |
101 | def exec(self, args): |
102 | container_id = self.containers_config.check_container_id(args.id) |
103 | |
104 | - container = LibertineContainer(container_id) |
105 | + container = self._container(container_id) |
106 | |
107 | if not container.exec_command(args.command): |
108 | sys.exit(1) |
109 | @@ -269,7 +283,7 @@ |
110 | |
111 | def configure(self, args): |
112 | container_id = self.containers_config.check_container_id(args.id) |
113 | - container = LibertineContainer(container_id) |
114 | + container = self._container(container_id) |
115 | |
116 | if args.multiarch and self.host_info.get_host_architecture() == 'amd64': |
117 | multiarch = 'disabled' |
118 | @@ -377,7 +391,7 @@ |
119 | def fix_integrity(self, args): |
120 | if 'containerList' in self.containers_config.container_list: |
121 | for container in self.containers_config.container_list['containerList']: |
122 | - libertine_container = LibertineContainer(container['id']) |
123 | + libertine_container = self._container(container['id']) |
124 | |
125 | if 'installStatus' not in container or container['installStatus'] == 'removing': |
126 | self.destroy_container(libertine_container) |
127 | @@ -411,7 +425,7 @@ |
128 | libertine.utils.get_logger().error("The restart subcommand is only valid for LXC and LXD type containers.") |
129 | sys.exit(1) |
130 | |
131 | - container = LibertineContainer(container_id) |
132 | + container = self._container(container_id) |
133 | |
134 | container.restart_libertine_container() |
135 | |
136 | |
137 | === modified file 'tools/libertine-launch' |
138 | --- tools/libertine-launch 2017-02-23 18:18:29 +0000 |
139 | +++ tools/libertine-launch 2017-03-14 15:31:47 +0000 |
140 | @@ -19,6 +19,10 @@ |
141 | import os |
142 | import sys |
143 | |
144 | +import gettext |
145 | +gettext.textdomain('libertine') |
146 | +_ = gettext.gettext |
147 | + |
148 | from libertine import launcher |
149 | |
150 | def main(): |
151 | @@ -30,8 +34,14 @@ |
152 | utils.get_logger().error("No container with id '%s'" % config.container_id) |
153 | sys.exit(1) |
154 | |
155 | - from libertine import LibertineContainer |
156 | - container = LibertineContainer(container_id=config.container_id) |
157 | + try: |
158 | + from libertine import LibertineContainer |
159 | + container = LibertineContainer(container_id=config.container_id) |
160 | + except ImportError as e: |
161 | + container_type = self.containers_config.get_container_type(container_id) |
162 | + libertine.utils.get_logger().error(_("Backend for container '{id}' not installed. Install " |
163 | + "'python3-libertine-{type}' and try again.").format(id=config.container_id, type=container_type)) |
164 | + sys.exit(1) |
165 | else: |
166 | from libertine import NoContainer |
167 |
PASSED: Continuous integration, rev:409 /jenkins. canonical. com/libertine/ job/lp- libertine- ci/466/ /jenkins. canonical. com/libertine/ job/build/ 855 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=amd64, release= xenial+ overlay, testname= default/ 705 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=amd64, release= zesty,testname= default/ 705 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=i386, release= xenial+ overlay, testname= default/ 705 /jenkins. canonical. com/libertine/ job/test- 0-autopkgtest/ label=i386, release= zesty,testname= default/ 705 /jenkins. canonical. com/libertine/ job/build- 0-fetch/ 865 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= xenial+ overlay/ 857 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= xenial+ overlay/ 857/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= zesty/857 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=amd64, release= zesty/857/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= xenial+ overlay/ 857 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= xenial+ overlay/ 857/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= zesty/857 /jenkins. canonical. com/libertine/ job/build- 2-binpkg/ arch=i386, release= zesty/857/ artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/libertine/ job/lp- libertine- ci/466/ rebuild
https:/