From d5b0d8fe52d05478ac95fba5cb7461f8b9400ee6 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 21 Jul 2015 11:29:07 +0200 Subject: [PATCH 1/3] print_jobhistory: Remove unused variables --- osc/core.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/osc/core.py b/osc/core.py index 36201512..02dbe625 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5769,9 +5769,6 @@ def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 't if not reason: reason = "unknown" code = node.get('code') - rt = int(node.get('readytime')) - readyt = time.gmtime(rt) - readyt = time.strftime('%Y-%m-%d %H:%M:%S %Z', readyt) st = int(node.get('starttime')) et = int(node.get('endtime')) endtime = time.strftime('%Y-%m-%d %H:%M:%S %Z', time.gmtime(et)) From 7896937f5056dcbcbc60ad41fcb726580c2b2979 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 21 Jul 2015 11:20:54 +0200 Subject: [PATCH 2/3] Remove use of %Z with gmtime %Z doesn't make sense for a time returned by gmtime. --- osc/core.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osc/core.py b/osc/core.py index 02dbe625..9245f20a 100644 --- a/osc/core.py +++ b/osc/core.py @@ -2911,7 +2911,7 @@ def shorttime(t): if time.gmtime()[0] == time.gmtime(t)[0]: # same year - return time.strftime('%b %d %H:%M %Z', time.gmtime(t)) + return time.strftime('%b %d %H:%M', time.gmtime(t)) else: return time.strftime('%b %d %Y', time.gmtime(t)) @@ -5736,7 +5736,7 @@ def get_buildhistory(apiurl, prj, package, repository, arch, format = 'text'): versrel = node.get('versrel') bcnt = int(node.get('bcnt')) t = time.gmtime(int(node.get('time'))) - t = time.strftime('%Y-%m-%d %H:%M:%S %Z', t) + t = time.strftime('%Y-%m-%d %H:%M:%S', t) if format == 'csv': r.append('%s|%s|%s|%s.%d' % (t, srcmd5, rev, versrel, bcnt)) @@ -5771,7 +5771,7 @@ def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 't code = node.get('code') st = int(node.get('starttime')) et = int(node.get('endtime')) - endtime = time.strftime('%Y-%m-%d %H:%M:%S %Z', time.gmtime(et)) + endtime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(et)) waittm = time.gmtime(et-st) if waittm.tm_mday > 1: waitbuild = "%1dd %2dh %2dm %2ds" % (waittm.tm_mday-1, waittm.tm_hour, waittm.tm_min, waittm.tm_sec) @@ -5833,7 +5833,7 @@ def get_commitlog(apiurl, prj, package, revision, format = 'text', meta = False, except: requestid = "" t = time.gmtime(int(node.find('time').text)) - t = time.strftime('%Y-%m-%d %H:%M:%S %Z', t) + t = time.strftime('%Y-%m-%d %H:%M:%S', t) if format == 'csv': s = '%s|%s|%s|%s|%s|%s|%s' % (rev, user, t, srcmd5, version, From 71297e31f45b9da40a2b7cc862cd22bfd38cae1f Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Tue, 21 Jul 2015 11:32:06 +0200 Subject: [PATCH 3/3] Don't use gmtime for a time difference The gmtime function is intended to be used for calendar time. --- osc/core.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/osc/core.py b/osc/core.py index 9245f20a..34c7cccb 100644 --- a/osc/core.py +++ b/osc/core.py @@ -5772,13 +5772,13 @@ def print_jobhistory(apiurl, prj, current_package, repository, arch, format = 't st = int(node.get('starttime')) et = int(node.get('endtime')) endtime = time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(et)) - waittm = time.gmtime(et-st) - if waittm.tm_mday > 1: - waitbuild = "%1dd %2dh %2dm %2ds" % (waittm.tm_mday-1, waittm.tm_hour, waittm.tm_min, waittm.tm_sec) - elif waittm.tm_hour: - waitbuild = " %2dh %2dm %2ds" % (waittm.tm_hour, waittm.tm_min, waittm.tm_sec) + waittm = et-st + if waittm > 24*60*60: + waitbuild = "%1dd %2dh %2dm %2ds" % (waittm / (24*60*60), (waittm / (60*60)) % 24, (waittm / 60) % 60, waittm % 60) + elif waittm > 60*60: + waitbuild = " %2dh %2dm %2ds" % (waittm / (60*60), (waittm / 60) % 60, waittm % 60) else: - waitbuild = " %2dm %2ds" % (waittm.tm_min, waittm.tm_sec) + waitbuild = " %2dm %2ds" % (waittm / 60, waittm % 60) if format == 'csv': print('%s|%s|%s|%s|%s|%s' % (endtime, package, reason, code, waitbuild, worker))