Browse Source

Merge "Move some file creation code from main to utils"

Jenkins 4 years ago
parent
commit
568d51bca2
2 changed files with 10 additions and 7 deletions
  1. 1
    7
      entropy/__main__.py
  2. 9
    0
      entropy/utils.py

+ 1
- 7
entropy/__main__.py View File

@@ -103,13 +103,7 @@ def start_engine(args):
103 103
     }
104 104
     utils.write_yaml(cfg, engine_cfg)
105 105
     # create cfg files
106
-    for filename in ['audit_cfg', 'repair_cfg']:
107
-        try:
108
-            with open(cfg_data[filename]):
109
-                pass
110
-        except IOError:
111
-            with open(cfg_data[filename], 'a'):
112
-                pass
106
+    utils.create_files([cfg_data['audit_cfg'], cfg_data['repair_cfg']])
113 107
     LOG.info('Added %s to engine cfg', args.name)
114 108
     entropy_engine = Engine(args.name, **cfg_data)
115 109
     entropy_engine.run()

+ 9
- 0
entropy/utils.py View File

@@ -223,3 +223,12 @@ class StopWatch(object):
223 223
         self._stopped_at = wallclock()
224 224
         self._state = self._STOPPED
225 225
         return self
226
+
227
+
228
+def create_files(list_of_files):
229
+    if not list_of_files:
230
+        return
231
+    for filename in list_of_files:
232
+        if not os.path.isfile(filename):
233
+            with open(filename, 'w'):
234
+                pass

Loading…
Cancel
Save