grok-pull fails in non-English locale
Opened this issue · 1 comments
thmo commented
When running grok-pull
in a non-English locale, it fails like this:
Traceback (most recent call last):
File "/env/grokmirror/bin/grok-pull", line 11, in <module>
sys.exit(command())
File "/env/grokmirror/local/lib/python2.7/site-packages/grokmirror/pull.py", line 1186, in command
opts.forcepurge)
File "/env/grokmirror/local/lib/python2.7/site-packages/grokmirror/pull.py", line 1170, in grok_pull
noreuse, purge, pretty, forcepurge)
File "/env/grokmirror/local/lib/python2.7/site-packages/grokmirror/pull.py", line 579, in pull_mirror
last_modified = time.strptime(last_modified, '%a, %d %b %Y %H:%M:%S %Z')
File "/usr/lib/python2.7/_strptime.py", line 478, in _strptime_time
return _strptime(data_string, format)[0]
File "/usr/lib/python2.7/_strptime.py", line 332, in _strptime
(data_string, format))
ValueError: time data 'Tue, 24 Apr 2018 18:06:08 GMT' does not match format '%a, %d %b %Y %H:%M:%S %Z'
This is while parsing the Last-Modified header, which has a fixed, locale-independent format.
One option could be to replace
last_modified = ufh.headers.get('Last-Modified')
last_modified = time.strptime(last_modified, '%a, %d %b %Y %H:%M:%S %Z')
last_modified = calendar.timegm(last_modified)
with
last_modified = ufh.headers.getdate_tz('Last-Modified')
last_modified = calendar.timegm(last_modified)
getting rid of the locale-dependent strptime()
.
mricon commented
We should actually force locale to C for a number of reasons -- partly because of the way we filter fsck messages. I will add this to 1.1.1