Although I passed "%a %b %d %H:%M:%S %Z %Y"
as the format string in time.strptime()
, it is operating on '%a %b %d %H:%M:%S %Y'
and therefore causing error. Any idea on what might be causing it?
The same thing runs perfectly in python console but not in the actual code.
Exception in thread Thread-7:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/usr/lib/python2.7/threading.py", line 754, in run
self.__target(*self.__args, **self.__kwargs)
File "proxy.py", line 137, in listenThread
response = self.fetchRequest(raw_request, request)
File "proxy.py", line 114, in fetchRequest
if request['type'] == "GET" and self.is_cachable(request, response_headers):
File "proxy.py", line 100, in is_cachable
requestTime = time.mktime(time.strptime(self.request_log[request['url']][len(self.request_log[request['url']])-3]), "%a %b %d %H:%M:%S %Z %Y")
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 'Mon Apr 10 22:52:38 IST 2017' does not match format '%a %b %d %H:%M:%S %Y'