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

monitor: clean up

parent 769ed5ec
......@@ -38,7 +38,7 @@ md5sum = cfcbf2002b8eff5153e2bf68ed24b720
[monitor-collect-csv-dump]
filename = script/collect_csv_dump.py
md5sum = 67a9d1c7173e0d99bf3a5c6eb15b2bd8
md5sum = d3cfa1f6760e3fa64ccd64acf213bdfb
[template-surykatka-ini]
_update_hash_filename_ = surykatka.ini.jinja2
......
......@@ -54,15 +54,14 @@ def parseArguments():
return parser.parse_args()
def writeFile(name, folder, date_scope, rows):
if os.path.exists(
os.path.join(folder, "%s/dump_%s.csv" % (date_scope, name))):
folder = os.path.join(folder, date_scope)
f = os.path.join(folder, "dump_%s.csv" % name)
if os.path.exists(f):
# File already exists, no reason to recreate it.
return
mkdir_p(os.path.join(folder, date_scope), 0o755)
file_io = open(os.path.join(folder, "%s/dump_%s.csv" % (date_scope, name)), "w")
csv_output = csv.writer(file_io)
csv_output.writerows(rows)
file_io.close()
mkdir_p(folder, 0o755)
with open(f, "w") as file_io:
csv.writer(file_io).writerows(rows)
def dump_table_into_csv(db, folder):
db.connect()
......
......@@ -65,7 +65,7 @@ class ServicesTestCase(SlapOSInstanceTestCase):
self.assertIn(expected_process_name, process_names)
class MonitorTestMixin(object):
class MonitorTestMixin:
monitor_setup_url_key = 'monitor-setup-url'
def test_monitor_setup(self):
......@@ -199,7 +199,7 @@ class EdgeSlaveMixin(MonitorTestMixin):
set(
glob.glob(
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():
self.assertEqual(
......@@ -247,7 +247,6 @@ class EdgeSlaveMixin(MonitorTestMixin):
except subprocess.CalledProcessError as e:
self.fail('%s failed with code %s and message %s' % (
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:
status_json = json.load(fh)
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