|
22 | 22 | import tarfile |
23 | 23 | import threading |
24 | 24 | import time |
25 | | -import locale |
26 | 25 |
|
27 | 26 | import lazylibrarian |
28 | 27 | import lib.requests as requests |
29 | 28 | from lazylibrarian import logger, version |
30 | 29 | from lazylibrarian.common import USER_AGENT, proxyList |
31 | 30 | from lazylibrarian.formatter import check_int |
32 | 31 |
|
33 | | -LOCALE_LOCK = threading.Lock() |
34 | | - |
35 | 32 |
|
36 | 33 | def logmsg(level, msg): |
37 | 34 | # log messages to logger if initialised, or print if not. |
@@ -267,13 +264,14 @@ def getLatestVersion_FromGit(): |
267 | 264 | timestamp = check_int(lazylibrarian.CONFIG['GIT_UPDATED'], 0) |
268 | 265 | age = '' |
269 | 266 | if timestamp: |
270 | | - with LOCALE_LOCK: |
271 | | - saved = locale.setlocale(locale.LC_ALL) |
272 | | - try: |
273 | | - locale.setlocale(locale.LC_ALL, 'C') |
274 | | - age = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(timestamp)) |
275 | | - finally: |
276 | | - locale.setlocale(locale.LC_ALL, saved) |
| 267 | + # timestring for 'If-Modified-Since' needs to be english short day/month names and in gmt |
| 268 | + # we already have english month names stored in MONTHNAMES[] but need capitalising |
| 269 | + # so use hard coded versions here instead |
| 270 | + DAYNAMES = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] |
| 271 | + MONNAMES = ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] |
| 272 | + tm = time.gmtime(timestamp) |
| 273 | + age = "%s, %02d %s %04d %02d:%02d:%02d GMT" %(DAYNAMES[tm.tm_wday], tm.tm_mday, |
| 274 | + MONNAMES[tm.tm_mon], tm.tm_year, tm.tm_hour, tm.tm_min, tm.tm_sec) |
277 | 275 | try: |
278 | 276 | headers = {'User-Agent': USER_AGENT} |
279 | 277 | if age: |
@@ -487,8 +485,9 @@ def update(): |
487 | 485 | os.remove(new_path) |
488 | 486 | os.renames(old_path, new_path) |
489 | 487 |
|
490 | | - # Update version.txt |
| 488 | + # Update version.txt and timestamo |
491 | 489 | updateVersionFile(lazylibrarian.CONFIG['LATEST_VERSION']) |
| 490 | + lazylibrarian.CONFIG['GIT_UPDATED'] = str(int(time.time())) |
492 | 491 | return True |
493 | 492 | else: |
494 | 493 | logmsg('error', "(update) Cannot perform update - Install Type not set") |
|
0 commit comments