Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grok-pull fails in non-English locale #24

Open
thmo opened this issue Apr 24, 2018 · 1 comment
Open

grok-pull fails in non-English locale #24

thmo opened this issue Apr 24, 2018 · 1 comment
Assignees
Milestone

Comments

@thmo
Copy link

thmo commented Apr 24, 2018

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
Copy link
Owner

mricon commented Apr 24, 2018

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

@mricon mricon added this to the 1.1.1 milestone Apr 24, 2018
@mricon mricon self-assigned this Apr 24, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants