Merge lp:~gocept/landscape-client/py3-monitor-mountinfo into lp:~landscape/landscape-client/trunk

Proposed by Steffen Allner
Status: Merged
Approved by: Eric Snow
Approved revision: 992
Merged at revision: 990
Proposed branch: lp:~gocept/landscape-client/py3-monitor-mountinfo
Merge into: lp:~landscape/landscape-client/trunk
Prerequisite: lp:~gocept/landscape-client/py3-monitor-computeruptime
Diff against target: 63 lines (+14/-6)
3 files modified
landscape/monitor/mountinfo.py (+4/-2)
landscape/monitor/tests/test_mountinfo.py (+9/-3)
py3_ready_tests (+1/-1)
To merge this branch: bzr merge lp:~gocept/landscape-client/py3-monitor-mountinfo
Reviewer Review Type Date Requested Status
Eric Snow (community) Approve
Michael Howitz (community) Approve
🤖 Landscape Builder test results Approve
Review via email: mp+321296@code.launchpad.net

Commit message

This is the Py3 port of landscape.monitor.mountinfo.

It adjusts to Py3 changes in the filter() builtin and the iterator protocol.

Description of the change

This MP considers landscape.monitor.mountinfo and its tests. Fixes where necessary as we can not get a len() from generators and we have to use the builtin next() to call the next item of an iterable.

To post a comment you must log in.
Revision history for this message
🤖 Landscape Builder (landscape-builder) :
review: Abstain (executing tests)
Revision history for this message
🤖 Landscape Builder (landscape-builder) wrote :

Command: TRIAL_ARGS=-j4 make ci-check
Result: Success
Revno: 992
Branch: lp:~gocept/landscape-client/py3-monitor-mountinfo
Jenkins: https://ci.lscape.net/job/latch-test-xenial/3815/

review: Approve (test results)
Revision history for this message
Michael Howitz (mh-gocept) wrote :

LGTM.

review: Approve
Revision history for this message
Eric Snow (ericsnowcurrently) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/monitor/mountinfo.py'
2--- landscape/monitor/mountinfo.py 2017-03-10 15:25:44 +0000
3+++ landscape/monitor/mountinfo.py 2017-03-29 13:50:32 +0000
4@@ -44,8 +44,10 @@
5 self.call_on_accepted("mount-info", self.send_messages, True)
6
7 def create_messages(self):
8- return filter(None, [self.create_mount_info_message(),
9- self.create_free_space_message()])
10+ return [message
11+ for message in [self.create_mount_info_message(),
12+ self.create_free_space_message()]
13+ if message is not None]
14
15 def create_mount_info_message(self):
16 if self._mount_info:
17
18=== modified file 'landscape/monitor/tests/test_mountinfo.py'
19--- landscape/monitor/tests/test_mountinfo.py 2017-03-10 15:19:26 +0000
20+++ landscape/monitor/tests/test_mountinfo.py 2017-03-29 13:50:32 +0000
21@@ -149,7 +149,9 @@
22 runs it gets a different value from our sample statvfs()
23 function which should cause it to queue new messages.
24 """
25- def statvfs(path, multiplier=mock_counter(1).next):
26+ counter = mock_counter(1)
27+
28+ def statvfs(path, multiplier=lambda: next(counter)):
29 return os.statvfs_result(
30 (4096, 0, mb(multiplier() * 1000), mb(100), 0, 0, 0, 0, 0, 0))
31
32@@ -181,7 +183,9 @@
33 messages should only be queued for / after the first message
34 is created.
35 """
36- def statvfs(path, multiplier=mock_counter(1).next):
37+ counter = mock_counter(1)
38+
39+ def statvfs(path, multiplier=lambda: next(counter)):
40 if path == "/":
41 return os.statvfs_result(
42 (4096, 0, mb(1000), mb(100), 0, 0, 0, 0, 0, 0))
43@@ -333,7 +337,9 @@
44
45 def test_sample_free_space(self):
46 """Test collecting information about free space."""
47- def statvfs(path, multiplier=mock_counter(1).next):
48+ counter = mock_counter(1)
49+
50+ def statvfs(path, multiplier=lambda: next(counter)):
51 return os.statvfs_result(
52 (4096, 0, mb(1000), mb(multiplier() * 100), 0, 0, 0, 0, 0, 0))
53
54
55=== modified file 'py3_ready_tests'
56--- py3_ready_tests 2017-03-29 13:50:32 +0000
57+++ py3_ready_tests 2017-03-29 13:50:32 +0000
58@@ -9,7 +9,7 @@
59
60 landscape.monitor.tests.test_activeprocessinfo
61 landscape.monitor.tests.test_computeruptime
62-
63+landscape.monitor.tests.test_mountinfo
64
65
66

Subscribers

People subscribed via source and target branches

to all changes: