Merge lp:~bigkevmcd/landscape-client/bug-710621-exit-more-gracefully into lp:~landscape/landscape-client/trunk

Proposed by Kevin McDermott
Status: Merged
Approved by: Frank Wierzbicki
Approved revision: 317
Merged at revision: 316
Proposed branch: lp:~bigkevmcd/landscape-client/bug-710621-exit-more-gracefully
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 40 lines (+15/-1)
2 files modified
landscape/sysinfo/deployment.py (+5/-1)
landscape/sysinfo/tests/test_deployment.py (+10/-0)
To merge this branch: bzr merge lp:~bigkevmcd/landscape-client/bug-710621-exit-more-gracefully
Reviewer Review Type Date Requested Status
Frank Wierzbicki (community) Approve
Björn Tillenius (community) Approve
Review via email: mp+48879@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Björn Tillenius (bjornt) wrote :

Looks good to me, +1!

[1]

+ self.assertEqual(error.message,
+ "Unable to setup logging. Read-only filesystem.")

I would say that the expected output should be the first argument, but I'm fine with leaving it as it is, to keep it consistent with the rest of the tests in this file.

review: Approve
Revision history for this message
Frank Wierzbicki (fwierzbicki) wrote :

Some pep8 lints:

landscape/sysinfo/tests/test_deployment.py:237:48: E225 missing whitespace around operator
landscape/sysinfo/tests/test_deployment.py:285:80: E501 line too long (87 characters)

otherwise, looks good to me +1!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/sysinfo/deployment.py'
2--- landscape/sysinfo/deployment.py 2010-06-08 19:43:02 +0000
3+++ landscape/sysinfo/deployment.py 2011-02-08 08:12:57 +0000
4@@ -1,5 +1,6 @@
5 """Deployment code for the sysinfo tool."""
6 import os
7+import sys
8 from logging import getLogger, Formatter
9 from logging.handlers import RotatingFileHandler
10
11@@ -91,7 +92,10 @@
12 """
13 @param reactor: The reactor to (optionally) run the sysinfo plugins in.
14 """
15- setup_logging()
16+ try:
17+ setup_logging()
18+ except IOError, e:
19+ sys.exit("Unable to setup logging. %s" % e)
20
21 if sysinfo is None:
22 sysinfo = SysInfoPluginRegistry()
23
24=== modified file 'landscape/sysinfo/tests/test_deployment.py'
25--- landscape/sysinfo/tests/test_deployment.py 2010-06-08 07:59:32 +0000
26+++ landscape/sysinfo/tests/test_deployment.py 2011-02-08 08:12:57 +0000
27@@ -275,3 +275,13 @@
28 self.mocker.replay()
29
30 run(["--sysinfo-plugins", "TestPlugin"])
31+
32+ def test_run_setup_logging_exits_gracefully(self):
33+ setup_logging_mock = self.mocker.replace(
34+ "landscape.sysinfo.deployment.setup_logging")
35+ setup_logging_mock()
36+ self.mocker.throw(IOError("Read-only filesystem."))
37+ self.mocker.replay()
38+ error = self.assertRaises(SystemExit, run, ["--sysinfo-plugins", "TestPlugin"])
39+ self.assertEqual(error.message,
40+ "Unable to setup logging. Read-only filesystem.")

Subscribers

People subscribed via source and target branches

to all changes: