Skip to content

Commit fa4f5ce

Browse files
authored
Merge pull request #1151 from philborman/master
Hard coded english names for git dates
2 parents e0414cb + 7257b74 commit fa4f5ce

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

lazylibrarian/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,12 @@ def config_read(reloaded=False):
639639
ebook_dir = check_setting('str', 'General', 'destination_dir', '')
640640
CFG.set('General', 'ebook_dir', ebook_dir)
641641
CFG.remove_option('General', 'destination_dir')
642+
# legacy type conversion
643+
if CFG.has_option('Git', 'git_updated'):
644+
val = CFG.get('Git', 'git_updated')
645+
newval = check_int(val, 0)
646+
if newval != val:
647+
CFG.set('Git', 'git_updated', newval)
642648
# legacy name conversions, separate out host/port
643649
for provider in ['NZBGet', 'UTORRENT', 'QBITTORRENT', 'TRANSMISSION']:
644650
if not CFG.has_option(provider, '%s_port' % provider.lower()):

lazylibrarian/versioncheck.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,13 @@
2222
import tarfile
2323
import threading
2424
import time
25-
import locale
2625

2726
import lazylibrarian
2827
import lib.requests as requests
2928
from lazylibrarian import logger, version
3029
from lazylibrarian.common import USER_AGENT, proxyList
3130
from lazylibrarian.formatter import check_int
3231

33-
LOCALE_LOCK = threading.Lock()
34-
3532

3633
def logmsg(level, msg):
3734
# log messages to logger if initialised, or print if not.
@@ -267,13 +264,14 @@ def getLatestVersion_FromGit():
267264
timestamp = check_int(lazylibrarian.CONFIG['GIT_UPDATED'], 0)
268265
age = ''
269266
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)
277275
try:
278276
headers = {'User-Agent': USER_AGENT}
279277
if age:
@@ -487,8 +485,9 @@ def update():
487485
os.remove(new_path)
488486
os.renames(old_path, new_path)
489487

490-
# Update version.txt
488+
# Update version.txt and timestamo
491489
updateVersionFile(lazylibrarian.CONFIG['LATEST_VERSION'])
490+
lazylibrarian.CONFIG['GIT_UPDATED'] = str(int(time.time()))
492491
return True
493492
else:
494493
logmsg('error', "(update) Cannot perform update - Install Type not set")

0 commit comments

Comments
 (0)