Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit 4813024

Browse files
author
Michael Smith
committed
Clean up CLI to handle bad or missing config filenames
1 parent 00fd392 commit 4813024

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

applications/multisite/intersite.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,12 @@ def _reload_sites(self, old_config, new_config):
10031003

10041004
def reload_config(self):
10051005
logging.info('')
1006-
with open(self.config_filename) as config_file:
1007-
new_config = json.load(config_file)
1006+
try:
1007+
with open(self.config_filename) as config_file:
1008+
new_config = json.load(config_file)
1009+
except IOError:
1010+
print '%% Could not load configuration file'
1011+
return
10081012
if 'config' not in new_config:
10091013
print '%% Invalid configuration file'
10101014
return
@@ -1154,8 +1158,11 @@ def do_configfile(self, filename):
11541158
configfile <filename>
11551159
Set the configuration file name.
11561160
'''
1157-
self.collector.config_filename = filename
1158-
print 'Configuration file is set to:', self.collector.config_filename
1161+
if len(filename):
1162+
self.collector.config_filename = filename
1163+
print 'Configuration file is set to:', self.collector.config_filename
1164+
else:
1165+
print 'No config filename given.'
11591166

11601167
def do_debug(self, keyword):
11611168
'''

0 commit comments

Comments
 (0)