diff --git a/entropy/__main__.py b/entropy/__main__.py index cd641da..b310874 100644 --- a/entropy/__main__.py +++ b/entropy/__main__.py @@ -103,13 +103,7 @@ def start_engine(args): } utils.write_yaml(cfg, engine_cfg) # create cfg files - for filename in ['audit_cfg', 'repair_cfg']: - try: - with open(cfg_data[filename]): - pass - except IOError: - with open(cfg_data[filename], 'a'): - pass + utils.create_files([cfg_data['audit_cfg'], cfg_data['repair_cfg']]) LOG.info('Added %s to engine cfg', args.name) entropy_engine = Engine(args.name, **cfg_data) entropy_engine.run() diff --git a/entropy/utils.py b/entropy/utils.py index c419f50..55f7cf0 100644 --- a/entropy/utils.py +++ b/entropy/utils.py @@ -223,3 +223,12 @@ class StopWatch(object): self._stopped_at = wallclock() self._state = self._STOPPED return self + + +def create_files(list_of_files): + if not list_of_files: + return + for filename in list_of_files: + if not os.path.isfile(filename): + with open(filename, 'w'): + pass