jenkins-bot has submitted this change and it was merged.

Change subject: Keep checkimages from outputting time.
......................................................................


Keep checkimages from outputting time.

This is primarily when it is called with -help.
Also clean up the implementation of execution time to be sane.

Bug: 68613
Change-Id: Ie53a5deedc30eabb84ba6cfa2cc1fa0a5f14ff42
---
M scripts/checkimages.py
M tests/script_tests.py
2 files changed, 7 insertions(+), 9 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/scripts/checkimages.py b/scripts/checkimages.py
index 69aa050..24b3b64 100644
--- a/scripts/checkimages.py
+++ b/scripts/checkimages.py
@@ -1961,13 +1961,12 @@
 
 
 if __name__ == "__main__":
-    old = datetime.datetime.strptime(
-        str(datetime.datetime.utcnow()).split('.')[0], "%Y-%m-%d %H:%M:%S")
+    start = time.time()
     try:
         main()
-    finally:
-        final = datetime.datetime.strptime(
-            str(datetime.datetime.utcnow()).split('.')[0], "%Y-%m-%d %H:%M:%S")
-        delta = final - old
-        secs_of_diff = delta.seconds
-        pywikibot.output("Execution time: %s seconds\n" % secs_of_diff)
+    except SystemExit:
+        pass
+    else:
+        final = time.time()
+        delta = int(final - start)
+        pywikibot.output("Execution time: %s seconds\n" % delta)
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 7d96152..5f8af4a 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -201,7 +201,6 @@
                 test_name = 'test_' + script_name + '_execution'
             dct[test_name] = test_execution(script_name, ['-help'])
             if script_name in ['shell', 'version',
-                               'checkimages',     # bug 68613
                                'data_ingestion',  # bug 68611
                                'flickrripper',    # bug 68606 (and others)
                                'replicate_wiki',  # bug 68664

-- 
To view, visit https://gerrit.wikimedia.org/r/151996
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ie53a5deedc30eabb84ba6cfa2cc1fa0a5f14ff42
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Audiodude <[email protected]>
Gerrit-Reviewer: Audiodude <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to