mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix server not working on some windows systems with non-English locales
This commit is contained in:
parent
2089449769
commit
8743efbed1
@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import os, httplib, hashlib, uuid, struct, repr as reprlib, time
|
||||
import os, httplib, hashlib, uuid, struct, repr as reprlib
|
||||
from collections import namedtuple
|
||||
from io import BytesIO, DEFAULT_BUFFER_SIZE
|
||||
from itertools import chain, repeat, izip_longest
|
||||
@ -22,7 +22,7 @@ from calibre.srv.http_request import HTTPRequest, read_headers
|
||||
from calibre.srv.sendfile import file_metadata, sendfile_to_socket_async, CannotSendfile, SendfileInterrupted
|
||||
from calibre.srv.utils import (
|
||||
MultiDict, http_date, HTTP1, HTTP11, socket_errors_socket_closed,
|
||||
sort_q_values, get_translator_for_lang, Cookie)
|
||||
sort_q_values, get_translator_for_lang, Cookie, fast_now_strftime)
|
||||
from calibre.utils.speedups import ReadOnlyFileBuffer
|
||||
from calibre.utils.monotonic import monotonic
|
||||
|
||||
@ -526,7 +526,7 @@ class HTTPConnection(HTTPRequest):
|
||||
return
|
||||
line = '%s port-%s %s %s "%s" %s %s' % (
|
||||
self.remote_addr, self.remote_port, username or '-',
|
||||
time.strftime('%d/%b/%Y:%H:%M:%S %z'),
|
||||
fast_now_strftime('%d/%b/%Y:%H:%M:%S %z'),
|
||||
force_unicode(self.request_line or '', 'utf-8'),
|
||||
status_code, ('-' if response_size is None else response_size))
|
||||
self.access_log(line)
|
||||
|
@ -6,7 +6,7 @@ from __future__ import (unicode_literals, division, absolute_import,
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2015, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import errno, socket, select, os
|
||||
import errno, socket, select, os, time
|
||||
from Cookie import SimpleCookie
|
||||
from contextlib import closing
|
||||
from urlparse import parse_qs
|
||||
@ -508,3 +508,12 @@ def get_use_roman():
|
||||
from calibre.gui2 import config
|
||||
_use_roman = config['use_roman_numerals_for_series_number']
|
||||
return _use_roman
|
||||
|
||||
|
||||
if iswindows:
|
||||
def fast_now_strftime(fmt):
|
||||
fmt = fmt.encode('mbcs')
|
||||
return time.strftime(fmt).decode('mbcs', 'replace')
|
||||
else:
|
||||
def fast_now_strftime(fmt):
|
||||
return time.strftime(fmt).decode('utf-8', 'replace')
|
||||
|
Loading…
x
Reference in New Issue
Block a user