formatTime/Long can handle timestamp
Also replaced *_time with *_ts wherever possible.
This commit is contained in:
parent
b0efed5e37
commit
7855b98ca2
16 changed files with 39 additions and 22 deletions
|
|
@ -5275,8 +5275,8 @@ Build Info: %(weburl)s/buildinfo?buildID=%(build_id)i\r
|
|||
if target is not None:
|
||||
dest_tag = target['dest_tag_name']
|
||||
status = koji.BUILD_STATES[build['state']].lower()
|
||||
creation_time = koji.formatTimeLong(build['creation_time'])
|
||||
completion_time = koji.formatTimeLong(build['completion_time'])
|
||||
creation_time = koji.formatTimeLong(build['creation_ts'])
|
||||
completion_time = koji.formatTimeLong(build['completion_ts'])
|
||||
task_id = build['task_id']
|
||||
|
||||
task_data = self._getTaskData(task_id)
|
||||
|
|
|
|||
|
|
@ -3225,7 +3225,7 @@ def anon_handle_buildinfo(goptions, session, args):
|
|||
print("Task: %s %s" % (task['id'], koji.taskLabel(task)))
|
||||
else:
|
||||
print("Task: none")
|
||||
print("Finished: %s" % koji.formatTimeLong(info['completion_time']))
|
||||
print("Finished: %s" % koji.formatTimeLong(info['completion_ts']))
|
||||
maven_info = session.getMavenBuild(info['id'])
|
||||
if maven_info:
|
||||
print("Maven groupId: %s" % maven_info['group_id'])
|
||||
|
|
@ -4662,7 +4662,7 @@ def _do_parseTaskParams(session, method, task_id, topdir):
|
|||
oldrepo = params[2]
|
||||
if oldrepo:
|
||||
lines.append("Old Repo ID: %i" % oldrepo['id'])
|
||||
lines.append("Old Repo Creation: %s" % koji.formatTimeLong(oldrepo['creation_time']))
|
||||
lines.append("Old Repo Creation: %s" % koji.formatTimeLong(oldrepo['creation_ts']))
|
||||
if len(params) > 3:
|
||||
lines.append("External Repos: %s" %
|
||||
', '.join([ext['external_repo_name'] for ext in params[3]]))
|
||||
|
|
|
|||
|
|
@ -3270,10 +3270,12 @@ class DBHandler(logging.Handler):
|
|||
|
||||
def formatTime(value):
|
||||
"""Format a timestamp so it looks nicer"""
|
||||
if not value:
|
||||
if not value and not isinstance(value, (int, float)):
|
||||
return ''
|
||||
if isinstance(value, xmlrpc_client.DateTime):
|
||||
value = datetime.datetime.strptime(value.value, "%Y%m%dT%H:%M:%S")
|
||||
elif isinstance(value, (int, float)):
|
||||
value = datetime.datetime.fromtimestamp(value)
|
||||
if isinstance(value, datetime.datetime):
|
||||
return value.strftime('%Y-%m-%d %H:%M:%S')
|
||||
else:
|
||||
|
|
@ -3289,12 +3291,14 @@ def formatTimeLong(value):
|
|||
"""Format a timestamp to a more human-reable format, i.e.:
|
||||
Sat, 07 Sep 2002 00:00:01 GMT
|
||||
"""
|
||||
if not value:
|
||||
if not value and not isinstance(value, (int, float)):
|
||||
return ''
|
||||
if isinstance(value, six.string_types):
|
||||
t = dateutil.parser.parse(value)
|
||||
elif isinstance(value, xmlrpc_client.DateTime):
|
||||
t = dateutil.parser.parse(value.value)
|
||||
elif isinstance(value, (int, float)):
|
||||
t = datetime.datetime.fromtimestamp(value)
|
||||
else:
|
||||
t = value
|
||||
# return date in local timezone, py 2.6 has tzone as astimezone required parameter
|
||||
|
|
|
|||
|
|
@ -100,4 +100,17 @@ class TestFormatTime(unittest.TestCase):
|
|||
r = formatTimeLong(d3)
|
||||
self.assertEqual(r, desired)
|
||||
|
||||
# timestamps, local timezone
|
||||
d4 = 0
|
||||
desired = 'Thu, 01 Jan 1970 01:00:00 CET'
|
||||
r = formatTimeLong(d4)
|
||||
self.assertEqual(r, desired)
|
||||
|
||||
# timestamps, GMT
|
||||
desired = 'Thu, 01 Jan 1970 00:00:00 GMT'
|
||||
os.environ['TZ'] = 'GMT'
|
||||
time.tzset()
|
||||
r = formatTimeLong(d4)
|
||||
self.assertEqual(r, desired)
|
||||
|
||||
locale.resetlocale()
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@
|
|||
<td>$build.volume_name</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Started</th><td>$util.formatTimeLong($start_time)</td>
|
||||
<th>Started</th><td>$util.formatTimeLong($start_ts)</td>
|
||||
</tr>
|
||||
#if $build.state == $koji.BUILD_STATES.BUILDING
|
||||
#if $estCompletion
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
#end if
|
||||
#else
|
||||
<tr>
|
||||
<th>Completed</th><td>$util.formatTimeLong($build.completion_time)</td>
|
||||
<th>Completed</th><td>$util.formatTimeLong($build.completion_ts)</td>
|
||||
</tr>
|
||||
#end if
|
||||
#if $build.cg_id
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@
|
|||
<td><a href="taginfo?tagID=$build.tag_id">$build.tag_name</a></td>
|
||||
#end if
|
||||
<td class="user-$build.owner_name"><a href="userinfo?userID=$build.owner_id">$build.owner_name</a></td>
|
||||
<td>$util.formatTime($build.completion_time)</td>
|
||||
<td>$util.formatTime($build.completion_ts)</td>
|
||||
#set $stateName = $util.stateName($build.state)
|
||||
<td class="$stateName">$util.stateImage($build.state)</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
</tr>
|
||||
#if 'mtime' in $file and $file.mtime
|
||||
<tr>
|
||||
<th>Modification time</th><td>$util.formatTimeLong($datetime.datetime.fromtimestamp($file.mtime))</td>
|
||||
<th>Modification time</th><td>$util.formatTimeLong($file.mtime)</td>
|
||||
</tr>
|
||||
#end if
|
||||
#if 'user' in $file and $file.user
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@
|
|||
#if not $user
|
||||
<td class="user-$build.owner_name"><a href="userinfo?userID=$build.owner_id">$build.owner_name</a></td>
|
||||
#end if
|
||||
<td>$util.formatTime($build.completion_time)</td>
|
||||
<td>$util.formatTime($build.completion_ts)</td>
|
||||
<td class="$stateName">$util.stateImage($build.state)</td>
|
||||
</tr>
|
||||
#end for
|
||||
|
|
@ -65,7 +65,7 @@
|
|||
</td>
|
||||
#end if
|
||||
<td>$task.arch</td>
|
||||
<td>$util.formatTime($task.completion_time)</td>
|
||||
<td>$util.formatTime($task.completion_ts)</td>
|
||||
<td class="task$state">$util.imageTag($state)</td>
|
||||
</tr>
|
||||
#end for
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
<tr class="$util.rowToggle($self)">
|
||||
<td><a href="buildinfo?buildID=$build.build_id">$build.nvr</a></td>
|
||||
<td class="user-$build.owner_name"><a href="userinfo?userID=$build.owner_id">$build.owner_name</a></td>
|
||||
<td>$util.formatTime($build.completion_time)</td>
|
||||
<td>$util.formatTime($build.completion_ts)</td>
|
||||
#set $stateName = $util.stateName($build.state)
|
||||
<td class="$stateName">$util.stateImage($build.state)</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<title>$koji.BUILD_STATES[$build.state].lower(): $koji.buildLabel($build)#if $build.task then ', target: ' + $build.task.request[1] else ''#</title>
|
||||
<link>$weburl/buildinfo?buildID=$build.build_id</link>
|
||||
#if $build.completion_time
|
||||
<pubDate>$util.formatTimeRSS($build.completion_time)</pubDate>
|
||||
<pubDate>$util.formatTimeRSS($build.completion_ts)</pubDate>
|
||||
#end if
|
||||
#if $build.state == $koji.BUILD_STATES['COMPLETE'] and $build.changelog
|
||||
<description><pre>$util.escapeHTML($koji.util.formatChangelog($build.changelog))</pre></description>
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
<tr><th>Tag</th><td><a href="taginfo?tagID=$repo.tag_id">$repo.tag_name</a></td></tr>
|
||||
#set $state = $util.repoState($repo.state)
|
||||
<tr><th>State</th><td class="repo$state">$state</td></tr>
|
||||
<tr><th>Event</th><td>$repo.create_event ($util.formatTimeLong($repo.creation_time))</td></tr>
|
||||
<tr><th>Event</th><td>$repo.create_event ($util.formatTimeLong($repo.creation_ts))</td></tr>
|
||||
#if $repo.state != koji.REPO_STATES['DELETED']
|
||||
<tr><th>URL</th><td><a href="$url">repodata</a></td></tr>
|
||||
<tr><th>Repo json</th><td><a href="$repo_json">repo.json</a></td></tr>
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@
|
|||
<th>Repo created</th>
|
||||
<td>
|
||||
#if $repo
|
||||
<a href="repoinfo?repoID=$repo.id">$util.formatTimeRSS($repo.creation_time)</a>
|
||||
<a href="repoinfo?repoID=$repo.id">$util.formatTimeRSS($repo.creation_ts)</a>
|
||||
#end if
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -77,11 +77,11 @@
|
|||
#end for
|
||||
#end if
|
||||
<tr>
|
||||
<th>Created</th><td>$util.formatTimeLong($task.create_time)</td>
|
||||
<th>Created</th><td>$util.formatTimeLong($task.create_ts)</td>
|
||||
</tr>
|
||||
#if $task.start_time
|
||||
<tr>
|
||||
<th>Started</th><td>$util.formatTimeLong($task.start_time)</td>
|
||||
<th>Started</th><td>$util.formatTimeLong($task.start_ts)</td>
|
||||
#end if
|
||||
#set $end_ts = None
|
||||
#if $task.state == $koji.TASK_STATES.OPEN
|
||||
|
|
@ -93,7 +93,7 @@
|
|||
#end if
|
||||
#elif $task.completion_time
|
||||
<tr>
|
||||
<th>Completed</th><td>$util.formatTimeLong($task.completion_time)</td>
|
||||
<th>Completed</th><td>$util.formatTimeLong($task.completion_ts)</td>
|
||||
</tr>
|
||||
#set $end_ts = $task.completion_ts
|
||||
#end if
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ $printOpts($params[3])
|
|||
#set $oldrepo = $params[2]
|
||||
#if $oldrepo
|
||||
<strong>Old Repo ID:</strong> <a href="repoinfo?repoID=$oldrepo.id">$oldrepo.id</a><br/>
|
||||
<strong>Old Repo Creation:</strong> $koji.formatTimeLong($oldrepo.creation_time)<br/>
|
||||
<strong>Old Repo Creation:</strong> $koji.formatTimeLong($oldrepo.creation_ts)<br/>
|
||||
#end if
|
||||
#if $len($params) > 4 and $params[4]
|
||||
<strong>External Repos:</strong> $printValue(None, [ext['external_repo_name'] for ext in $params[3]])<br/>
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ All
|
|||
#end if
|
||||
</td>
|
||||
<td>$task.arch</td>
|
||||
<td>$util.formatTime($task.completion_time)</td>
|
||||
<td>$util.formatTime($task.completion_ts)</td>
|
||||
<td class="task$state">$util.imageTag($taskState)</td>
|
||||
</tr>
|
||||
#end for
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@
|
|||
<tr class="$util.rowToggle($self)">
|
||||
#set $stateName = $util.stateName($build.state)
|
||||
<td><a href="buildinfo?buildID=$build.build_id">$build.nvr</a></td>
|
||||
<td>$util.formatTime($build.completion_time)</td>
|
||||
<td>$util.formatTime($build.completion_ts)</td>
|
||||
<td class="$stateName">$util.stateImage($build.state)</td>
|
||||
</tr>
|
||||
#end for
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue