Merge lp:~therve/landscape-client/earlier-hardware-info into lp:~landscape/landscape-client/trunk

Proposed by Thomas Herve
Status: Merged
Approved by: Jerry Seutter
Approved revision: 469
Merged at revision: 470
Proposed branch: lp:~therve/landscape-client/earlier-hardware-info
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 72 lines (+14/-15)
4 files modified
landscape/broker/client.py (+12/-0)
landscape/manager/hardwareinfo.py (+1/-2)
landscape/manager/tests/test_hardwareinfo.py (+1/-1)
landscape/monitor/plugin.py (+0/-12)
To merge this branch: bzr merge lp:~therve/landscape-client/earlier-hardware-info
Reviewer Review Type Date Requested Status
Jerry Seutter (community) Approve
Chris Glass (community) Approve
Review via email: mp+95375@code.launchpad.net

Description of the change

The branch moves a feature only accessible to monitor previously, so that all plugins can use it (call_on_accepted).

To post a comment you must log in.
Revision history for this message
Chris Glass (tribaal) wrote :

Looks good! +1!

review: Approve
Revision history for this message
Jerry Seutter (jseutter) wrote :

+1 looks good :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/broker/client.py'
2--- landscape/broker/client.py 2011-07-21 23:55:47 +0000
3+++ landscape/broker/client.py 2012-03-01 14:54:27 +0000
4@@ -41,6 +41,18 @@
5 """An alias for the C{client} attribute."""
6 return self.client
7
8+ def call_on_accepted(self, type, callable, *args, **kwargs):
9+ """
10+ Register a callback fired upon a C{message-type-acceptance-changed}.
11+ """
12+
13+ def acceptance_changed(acceptance):
14+ if acceptance:
15+ return callable(*args, **kwargs)
16+
17+ self.client.reactor.call_on(("message-type-acceptance-changed", type),
18+ acceptance_changed)
19+
20
21 class BrokerClient(object):
22 """Basic plugin registry for clients that have to deal with the broker.
23
24=== modified file 'landscape/manager/hardwareinfo.py'
25--- landscape/manager/hardwareinfo.py 2011-12-02 08:29:46 +0000
26+++ landscape/manager/hardwareinfo.py 2012-03-01 14:54:27 +0000
27@@ -14,8 +14,7 @@
28 command = "/usr/bin/lshw"
29
30 def run(self):
31- return self.registry.broker.call_if_accepted(
32- self.message_type, self.send_message)
33+ self.call_on_accepted(self.message_type, self.send_message)
34
35 def send_message(self):
36 result = getProcessOutput(
37
38=== modified file 'landscape/manager/tests/test_hardwareinfo.py'
39--- landscape/manager/tests/test_hardwareinfo.py 2011-12-01 13:38:58 +0000
40+++ landscape/manager/tests/test_hardwareinfo.py 2012-03-01 14:54:27 +0000
41@@ -19,7 +19,7 @@
42 """
43 L{HardwareInfo} sends the output of its command when running.
44 """
45- deferred = self.info.run()
46+ deferred = self.info.send_message()
47
48 def check(ignored):
49 self.assertMessages(
50
51=== modified file 'landscape/monitor/plugin.py'
52--- landscape/monitor/plugin.py 2010-12-10 13:57:11 +0000
53+++ landscape/monitor/plugin.py 2012-03-01 14:54:27 +0000
54@@ -36,18 +36,6 @@
55 """An alias for the C{client} attribute."""
56 return self.client
57
58- def call_on_accepted(self, type, callable, *args, **kwargs):
59- """
60- Register a callback fired upon a C{message-type-acceptance-changed}.
61- """
62-
63- def acceptance_changed(acceptance):
64- if acceptance:
65- return callable(*args, **kwargs)
66-
67- self.monitor.reactor.call_on(("message-type-acceptance-changed",
68- type), acceptance_changed)
69-
70
71 class DataWatcher(MonitorPlugin):
72 """

Subscribers

People subscribed via source and target branches

to all changes: