Commit d7e9ab1c authored by Bryton Lacquement's avatar Bryton Lacquement 🚪

monitor: clean up

parent 769ed5ec
...@@ -38,7 +38,7 @@ md5sum = cfcbf2002b8eff5153e2bf68ed24b720 ...@@ -38,7 +38,7 @@ md5sum = cfcbf2002b8eff5153e2bf68ed24b720
[monitor-collect-csv-dump] [monitor-collect-csv-dump]
filename = script/collect_csv_dump.py filename = script/collect_csv_dump.py
md5sum = 67a9d1c7173e0d99bf3a5c6eb15b2bd8 md5sum = d3cfa1f6760e3fa64ccd64acf213bdfb
[template-surykatka-ini] [template-surykatka-ini]
_update_hash_filename_ = surykatka.ini.jinja2 _update_hash_filename_ = surykatka.ini.jinja2
......
...@@ -54,15 +54,14 @@ def parseArguments(): ...@@ -54,15 +54,14 @@ def parseArguments():
return parser.parse_args() return parser.parse_args()
def writeFile(name, folder, date_scope, rows): def writeFile(name, folder, date_scope, rows):
if os.path.exists( folder = os.path.join(folder, date_scope)
os.path.join(folder, "%s/dump_%s.csv" % (date_scope, name))): f = os.path.join(folder, "dump_%s.csv" % name)
if os.path.exists(f):
# File already exists, no reason to recreate it. # File already exists, no reason to recreate it.
return return
mkdir_p(os.path.join(folder, date_scope), 0o755) mkdir_p(folder, 0o755)
file_io = open(os.path.join(folder, "%s/dump_%s.csv" % (date_scope, name)), "w") with open(f, "w") as file_io:
csv_output = csv.writer(file_io) csv.writer(file_io).writerows(rows)
csv_output.writerows(rows)
file_io.close()
def dump_table_into_csv(db, folder): def dump_table_into_csv(db, folder):
db.connect() db.connect()
......
...@@ -65,7 +65,7 @@ class ServicesTestCase(SlapOSInstanceTestCase): ...@@ -65,7 +65,7 @@ class ServicesTestCase(SlapOSInstanceTestCase):
self.assertIn(expected_process_name, process_names) self.assertIn(expected_process_name, process_names)
class MonitorTestMixin(object): class MonitorTestMixin:
monitor_setup_url_key = 'monitor-setup-url' monitor_setup_url_key = 'monitor-setup-url'
def test_monitor_setup(self): def test_monitor_setup(self):
...@@ -199,7 +199,7 @@ class EdgeSlaveMixin(MonitorTestMixin): ...@@ -199,7 +199,7 @@ class EdgeSlaveMixin(MonitorTestMixin):
set( set(
glob.glob( glob.glob(
os.path.join(self.bot_partition_path, 'etc', 'surykatka*.ini'))), os.path.join(self.bot_partition_path, 'etc', 'surykatka*.ini'))),
set([q['ini-file'] for q in self.surykatka_dict.values()]) {q['ini-file'] for q in self.surykatka_dict.values()}
) )
for info_dict in self.surykatka_dict.values(): for info_dict in self.surykatka_dict.values():
self.assertEqual( self.assertEqual(
...@@ -247,7 +247,6 @@ class EdgeSlaveMixin(MonitorTestMixin): ...@@ -247,7 +247,6 @@ class EdgeSlaveMixin(MonitorTestMixin):
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
self.fail('%s failed with code %s and message %s' % ( self.fail('%s failed with code %s and message %s' % (
info_dict['status-json'], e.returncode, e.output)) info_dict['status-json'], e.returncode, e.output))
self.assertTrue(os.path.exists(info_dict['json-file']))
with open(info_dict['json-file']) as fh: with open(info_dict['json-file']) as fh:
status_json = json.load(fh) status_json = json.load(fh)
self.assertIn('bot_status', status_json) self.assertIn('bot_status', status_json)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment