fix py26 compatibility

This commit is contained in:
Tomas Kopecek 2023-03-02 15:07:40 +01:00
parent d520dce8a2
commit 8acb4a4fd3

View file

@ -611,7 +611,11 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None,
if last_modified:
mtime = dateutil.parser.parse(last_modified)
if mtime:
os.utime(relpath, (time.time() ,time.mktime(mtime.astimezone().timetuple())))
# py 2.6 modifications, see koji.formatTimeLong
if mtime.tzinfo is None:
mtime = mtime.replace(tzinfo=dateutil.tz.gettz())
mtime = mtime.astimezone(dateutil.tz.gettz())
os.utime(relpath, (time.time(), time.mktime(mtime.timetuple())))
finally:
f.close()
if pos == 0: