[Qa-jenkins-scm] [jenkins.debian.net] 04/05: reproducible: *.py: from datetime import datetime, timedelta instead of all datetime

Holger Levsen holger at moszumanska.debian.org
Fri Jun 12 18:03:58 UTC 2015


This is an automated email from the git hooks/post-receive script.

holger pushed a commit to branch master
in repository jenkins.debian.net.

commit fe9b6335b4876cb8f02a306199ed13e787e2b1f4
Author: Mattia Rizzolo <mattia at mapreri.org>
Date:   Fri Jun 12 19:17:56 2015 +0200

    reproducible: *.py: from datetime import datetime, timedelta instead of all datetime
---
 bin/reproducible_common.py           |  4 ++--
 bin/reproducible_db_maintenance.py   | 10 +++++-----
 bin/reproducible_remote_scheduler.py |  4 ++--
 bin/reproducible_scheduler.py        |  6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/bin/reproducible_common.py b/bin/reproducible_common.py
index 9a73a2c..58f60e2 100755
--- a/bin/reproducible_common.py
+++ b/bin/reproducible_common.py
@@ -17,12 +17,12 @@ import errno
 import sqlite3
 import logging
 import argparse
-import datetime
 import psycopg2
 import html as HTML
 from string import Template
 from subprocess import call
 from traceback import print_exception
+from datetime import datetime, timedelta
 
 DEBUG = False
 QUIET = False
@@ -229,7 +229,7 @@ def _gen_links(suite, arch):
 
 
 def write_html_page(title, body, destfile, suite=defaultsuite, arch=defaultarch, noheader=False, style_note=False, noendpage=False):
-    now = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC')
+    now = datetime.utcnow().strftime('%Y-%m-%d %H:%M UTC')
     html = ''
     html += html_header.substitute(page_title=title)
     if not noheader:
diff --git a/bin/reproducible_db_maintenance.py b/bin/reproducible_db_maintenance.py
index b294738..8b80220 100755
--- a/bin/reproducible_db_maintenance.py
+++ b/bin/reproducible_db_maintenance.py
@@ -13,7 +13,7 @@
 
 from reproducible_common import *
 
-now = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
+now = datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
 
 
 # the original schema is here
@@ -420,12 +420,12 @@ def db_update():
     log.info('Found schema updates.')
     for update in range(current+1, last+1):
         log.info('Applying database update #' + str(update) + '. Queries:')
-        startTime = datetime.datetime.now()
+        startTime = datetime.now()
         for query in schema_updates[update]:
             log.info('\t' + query)
             query_db(query)
         log.info(str(len(schema_updates[update])) + ' queries executed in ' +
-                 str(datetime.datetime.now() - startTime))
+                 str(datetime.now() - startTime))
     return True
 
 
@@ -440,7 +440,7 @@ if __name__ == '__main__':
         changed_created = db_create_tables()
     changed = db_update()
     if changed or changed_created:
-        log.info('Total execution time: ' + str(datetime.datetime.now() -
-                 datetime.datetime.strptime(now, "%Y-%m-%d-%H-%M-%S")))
+        log.info('Total execution time: ' + str(datetime.now() -
+                 datetime.strptime(now, "%Y-%m-%d-%H-%M-%S")))
     else:
         log.info('No pending updates.')
diff --git a/bin/reproducible_remote_scheduler.py b/bin/reproducible_remote_scheduler.py
index aeca6f0..55b7663 100755
--- a/bin/reproducible_remote_scheduler.py
+++ b/bin/reproducible_remote_scheduler.py
@@ -119,11 +119,11 @@ message += ': ' + ' '.join(pkgs)[0:256] + blablabla + artifacts_txt
 # schedule on the full hour so we can recognize them easily
 epoch = int(time.time())
 yesterday = epoch - 60*60*24
-now = datetime.datetime.now()
+now = datetime.now()
 days = int(now.strftime('%j'))*2
 hours = int(now.strftime('%H'))*2
 minutes = int(now.strftime('%M'))
-time_delta = datetime.timedelta(days=days, hours=hours, minutes=minutes)
+time_delta = timedelta(days=days, hours=hours, minutes=minutes)
 date = (now - time_delta).strftime('%Y-%m-%d %H:%M')
 log.debug('date_scheduled = ' + date + ' time_delta = ' + str(time_delta))
 
diff --git a/bin/reproducible_scheduler.py b/bin/reproducible_scheduler.py
index 1f6500b..cfa03d0 100755
--- a/bin/reproducible_scheduler.py
+++ b/bin/reproducible_scheduler.py
@@ -301,9 +301,9 @@ def scheduler():
                 'WHERE s.suite="{suite}"'.format(suite=suite)
         now_queued_here[suite] = int(query_db(query)[0][0]) + len(untested[suite]+new[suite]+old[suite])
         # schedule packages differently in the queue...
-        schedule_packages(untested[suite], datetime.datetime.now())
-        schedule_packages(new[suite], datetime.datetime.now()+datetime.timedelta(minutes=-720))
-        schedule_packages(old[suite], datetime.datetime.now()+datetime.timedelta(minutes=720))
+        schedule_packages(untested[suite], datetime.now())
+        schedule_packages(new[suite], datetime.now()+timedelta(minutes=-720))
+        schedule_packages(old[suite], datetime.now()+timedelta(minutes=720))
         log.info('### Suite ' + suite + ' done ###')
         log.info('==============================================================')
     # update the scheduled page

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git



More information about the Qa-jenkins-scm mailing list