From 2c1227c0eeb32f96ac39fb97332e9f23d93e5eb8 Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Mon, 8 Jun 2020 18:05:20 -0500 Subject: [PATCH] Separate actual functionality out into a separate function. --- metrics | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/metrics b/metrics index 0bb6a41..1a7c481 100755 --- a/metrics +++ b/metrics @@ -20,6 +20,7 @@ from modules.jenkins import JenkinsModule ENABLED_MODULES = [JenkinsModule] + def sqlite_run(command, db=":memory:"): """Run the given SQLite command on our db @@ -32,8 +33,14 @@ def sqlite_run(command, db=":memory:"): conn.commit() conn.close() + +def main(module): + """Given a specific module, set it up and insert recent values""" + module = module() + sqlite_run(module.sqlite_setup()) + sqlite_run(module.sqlite_add()) + + if __name__ == "__main__": for module in ENABLED_MODULES: - module = module() - sqlite_run(module.sqlite_setup()) - sqlite_run(module.sqlite_add()) + main(module)