Move some file creation code from main to utils

As part of engine creation, we create files for audit and repair cfg.
Move this to utils.

Change-Id: I9d5075cb854ab5585fddcb58013ffa2530add970
This commit is contained in:
pran1990 2014-05-30 15:17:02 -07:00
parent 3499d899c8
commit 0f5954359c
2 changed files with 10 additions and 7 deletions

View File

@ -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()

View File

@ -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