mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-18 09:57:40 +03:00
parent
0ee5b72ac6
commit
b73f68b258
14
companion.py
14
companion.py
@ -1,6 +1,7 @@
|
|||||||
import csv
|
import csv
|
||||||
import requests
|
import requests
|
||||||
from cookielib import LWPCookieJar
|
from cookielib import LWPCookieJar
|
||||||
|
from email.utils import parsedate
|
||||||
import hashlib
|
import hashlib
|
||||||
import numbers
|
import numbers
|
||||||
import os
|
import os
|
||||||
@ -8,9 +9,7 @@ from os.path import dirname, isfile, join
|
|||||||
import sys
|
import sys
|
||||||
from sys import platform
|
from sys import platform
|
||||||
import time
|
import time
|
||||||
|
from traceback import print_exc
|
||||||
if __debug__:
|
|
||||||
from traceback import print_exc
|
|
||||||
|
|
||||||
from config import config
|
from config import config
|
||||||
|
|
||||||
@ -245,7 +244,7 @@ class Session:
|
|||||||
try:
|
try:
|
||||||
data = r.json()
|
data = r.json()
|
||||||
if 'timestamp' not in data:
|
if 'timestamp' not in data:
|
||||||
data['timestamp'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.strptime(r.headers['Date'].split(',')[1].strip(), "%d %b %Y %H:%M:%S %Z"))
|
data['timestamp'] = time.strftime('%Y-%m-%dT%H:%M:%SZ', parsedate(r.headers['Date']))
|
||||||
except:
|
except:
|
||||||
self.dump(r)
|
self.dump(r)
|
||||||
raise ServerError()
|
raise ServerError()
|
||||||
@ -286,11 +285,8 @@ class Session:
|
|||||||
self.session = None
|
self.session = None
|
||||||
|
|
||||||
def dump(self, r):
|
def dump(self, r):
|
||||||
if __debug__:
|
print_exc()
|
||||||
print 'Status\t%s' % r.status_code
|
print 'cAPI\t' + r.url, r.status_code, r.headers, r.text.encode('utf-8')
|
||||||
print 'URL\t%s' % r.url
|
|
||||||
print 'Headers\t%s' % r.headers
|
|
||||||
print ('Content:\n%s' % r.text).encode('utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
# Returns a shallow copy of the received data suitable for export to older tools - English commodity names and anomalies fixed up
|
# Returns a shallow copy of the received data suitable for export to older tools - English commodity names and anomalies fixed up
|
||||||
|
Loading…
x
Reference in New Issue
Block a user