setup.py: Use UTC for version number. Closes GH-717.

This commit is contained in:
Valentin Lorentz 2014-06-04 16:50:31 +02:00
parent e6db4edb44
commit 7d716aa8f3
2 changed files with 16 additions and 7 deletions

View File

@ -745,7 +745,7 @@ class Filter(callbacks.Plugin):
elif ord(c) >= 32:
turned.append(c)
tlen += 1
s = '%s \x02 \x02' % ''.join(reversed(turned))
s = u'%s \x02 \x02' % u''.join(reversed(turned))
irc.reply(s)
uniud = wrap(uniud, ['text'])
Filter = internationalizeDocstring(Filter)

View File

@ -32,6 +32,8 @@
import os
import sys
import time
import datetime
import tempfile
import subprocess
@ -47,13 +49,20 @@ version = None
try:
proc = subprocess.Popen('git show HEAD --format=%ci', shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
version = proc.stdout.readline()
date = proc.stdout.readline()
if sys.version_info[0] >= 3:
version = version.decode()
version = version \
.strip() \
.split(' ')[0] \
.replace('-', '.')
date = date.decode()
date = time.strptime(date.strip(), '%Y-%m-%d %H:%M:%S %z')
utc_date = time.gmtime(time.mktime(date))
version = time.strftime('%Y.%m.%d', utc_date)
else:
(date, timezone) = date.strip().rsplit(' ', 1)
date = datetime.datetime.strptime(date.strip(), '%Y-%m-%d %H:%M:%S')
offset = time.strptime(timezone[1:], '%H%M')
offset = datetime.timedelta(hours=offset.tm_hour,
minutes=offset.tm_min)
utc_date = date - offset
version = utc_date.strftime('%Y.%m.%d')
except:
pass
if not version: