Merge lp:~adam-collard/landscape-client/config-file-sysinfo into lp:~landscape/landscape-client/trunk
Proposed by
Adam Collard
Status: | Merged |
---|---|
Approved by: | Adam Collard |
Approved revision: | 763 |
Merged at revision: | 759 |
Proposed branch: | lp:~adam-collard/landscape-client/config-file-sysinfo |
Merge into: | lp:~landscape/landscape-client/trunk |
Diff against target: |
199 lines (+33/-40) 5 files modified
landscape/__init__.py (+1/-1) landscape/broker/config.py (+2/-3) landscape/configuration.py (+1/-1) landscape/deployment.py (+18/-21) landscape/tests/test_deployment.py (+11/-14) |
To merge this branch: | bzr merge lp:~adam-collard/landscape-client/config-file-sysinfo |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Björn Tillenius (community) | Approve | ||
Geoff Teale (community) | Approve | ||
Review via email: mp+212052@code.launchpad.net |
Commit message
Only complain about missing default configuration files if they are present but unreadable.
Description of the change
Only complain about missing default configuration files if they are present but unreadable.
To test:
rm /etc/landscape/
landscape-sysinfo should not error out.
To post a comment you must log in.
[1]
This code:
51 + if os.path. isfile( self.config) and os.access( self.config, os.R_OK): configuration_ file(self. config) nonexistent_ config:
52 + self.load_
53 + elif not accept_
54 + sys.exit("error: config file %s can't be read" % self.config)
looks a lot like this code:
77 + if os.path. isfile( config_ filename) : config_ filename, os.R_OK): append( "error: config file %s can't be read" % configuration_ file(config_ filename)
78 + if not os.access(
79 + errors.
80 + config_filename)
81 + else:
82 + self.load_
83 + break
I had trouble seeing the difference at first. Only after re-reading the code several
time I spotted what was different.
I'd suggest being a bit more explicit and write the whole think like this:
if (self.config and not os.path. isfile( self.config) nonexistent_ config) :
sys. exit("error: config file %s doesn't exist" % self.config)
and not accept_
if self.config:
config_ filenames = [self.config]
config_ filenames = self.default_ config_ filenames
else:
errors = [] isfile( config_ filename) : config_ filename, os.R_OK):
errors. append( "error: config file %s can't be read" %
config_ filename)
else:
self. load_configurat ion_file( config_ filename)
break nonexistent_ config:
sys.exit( "\n".join( errors) )
for config_filename in config_filenames:
if os.path.
if not os.access(
else:
if errors and not accept_
I.e., first check whether self.config exists, and then do the general checking
that was already in place. What do you think?