Merge lp:~bjornt/landscape-client/apt-facade-reporter-optional into lp:landscape-client

Proposed by Björn Tillenius on 2011-10-26
Status: Merged
Approved by: Alberto Donato on 2011-10-27
Approved revision: 420
Merged at revision: 390
Proposed branch: lp:~bjornt/landscape-client/apt-facade-reporter-optional
Merge into: lp:landscape-client
Prerequisite: lp:~bjornt/landscape-client/apt-facade-reporter-tests
Diff against target: 60 lines (+13/-8) 3 files modified
To merge this branch: bzr merge lp:~bjornt/landscape-client/apt-facade-reporter-optional
Reviewer Review Type Date Requested Status
Alberto Donato 2011-10-26 Approve on 2011-10-27
Mike Milner (community) 2011-10-26 Approve on 2011-10-26
Review via email: mp+80445@code.launchpad.net

Description of the Change

Use AptFacade in the package reporter, if the USE_APT_FACADE environment
variable is set to a non-0 value.

This is so that we can test using the AptFacade on a real system,
without making it default just yet.

To post a comment you must log in.
Mike Milner (milner) wrote :

Good idea +1

There are a few pep8 errors but they seem to be all string literals for sample manifests and whatnot. I guess this is a know-when-to-bend-the-rules moment :)

Mike Milner (milner) wrote :

Oops, forgot to approve.

+1

review: Approve
Alberto Donato (ack) wrote :

Looks good! +1

review: Approve
Björn Tillenius (bjornt) wrote :

On Wed, Oct 26, 2011 at 07:54:23PM -0000, Mike Milner wrote:
> Good idea +1
>
> There are a few pep8 errors but they seem to be all string literals
> for sample manifests and whatnot. I guess this is a
> know-when-to-bend-the-rules moment :)

Right. Trying to make them to fit would make them less readable
probably.

--
Björn Tillenius | https://launchpad.net/~bjornt

Preview Diff

1=== modified file 'landscape/package/reporter.py'
2--- landscape/package/reporter.py 2011-10-17 13:16:25 +0000
3+++ landscape/package/reporter.py 2011-10-26 13:11:17 +0000
4@@ -672,7 +672,9 @@
5 elif "FAKE_PACKAGE_STORE" in os.environ:
6 return run_task_handler(FakeReporter, args)
7 else:
8- return run_task_handler(PackageReporter, args)
9+ use_apt_facade = os.environ.get("USE_APT_FACADE", False)
10+ return run_task_handler(
11+ PackageReporter, args, use_apt_facade=use_apt_facade)
12
13
14 def find_reporter_command():
15
16=== modified file 'landscape/package/taskhandler.py'
17--- landscape/package/taskhandler.py 2011-10-26 13:11:17 +0000
18+++ landscape/package/taskhandler.py 2011-10-26 13:11:17 +0000
19@@ -227,7 +227,7 @@
20 return result
21
22
23-def run_task_handler(cls, args, reactor=None):
24+def run_task_handler(cls, args, reactor=None, use_apt_facade=False):
25 # please only pass reactor when you have totally mangled everything with
26 # mocker. Otherwise bad things will happen.
27 if reactor is None:
28@@ -258,12 +258,15 @@
29 # 0644 so...
30 os.umask(022)
31
32- # Delay importing of the facade so that we don't
33+ package_store = cls.package_store_class(config.store_filename)
34+ # Delay importing of the facades so that we don't
35 # import Smart unless we need to.
36- from landscape.package.facade import SmartFacade
37-
38- package_store = cls.package_store_class(config.store_filename)
39- package_facade = SmartFacade()
40+ if use_apt_facade:
41+ from landscape.package.facade import AptFacade
42+ package_facade = AptFacade()
43+ else:
44+ from landscape.package.facade import SmartFacade
45+ package_facade = SmartFacade()
46
47 def finish():
48 connector.disconnect()
49
50=== modified file 'landscape/package/tests/test_reporter.py'
51--- landscape/package/tests/test_reporter.py 2011-10-26 13:11:17 +0000
52+++ landscape/package/tests/test_reporter.py 2011-10-26 13:11:17 +0000
53@@ -1269,7 +1269,7 @@
54 run_task_handler = self.mocker.replace("landscape.package.taskhandler"
55 ".run_task_handler",
56 passthrough=False)
57- run_task_handler(PackageReporter, ["ARGS"])
58+ run_task_handler(PackageReporter, ["ARGS"], use_apt_facade=False)
59 self.mocker.result("RESULT")
60 self.mocker.replay()
61

Subscribers

People subscribed via source and target branches