s/exc_info=1/exc_info=True/g
This commit is contained in:
parent
6b70fa36c7
commit
d70bd8797a
14 changed files with 28 additions and 28 deletions
|
@ -26,7 +26,7 @@ def get(vk):
|
||||||
opener.addheaders = list(zip(headers.keys(), headers.values()))
|
opener.addheaders = list(zip(headers.keys(), headers.values()))
|
||||||
r = opener.open(url)
|
r = opener.open(url)
|
||||||
except:
|
except:
|
||||||
logger.info('get failed %s', url, exc_info=1)
|
logger.info('get failed %s', url, exc_info=True)
|
||||||
return None
|
return None
|
||||||
sig = r.headers.get('X-Ed25519-Signature')
|
sig = r.headers.get('X-Ed25519-Signature')
|
||||||
data = r.read()
|
data = r.read()
|
||||||
|
@ -56,6 +56,6 @@ def put(sk, data):
|
||||||
opener.addheaders = list(zip(headers.keys(), headers.values()))
|
opener.addheaders = list(zip(headers.keys(), headers.values()))
|
||||||
r = opener.open(url, data)
|
r = opener.open(url, data)
|
||||||
except:
|
except:
|
||||||
logger.info('put failed: %s', data, exc_info=1)
|
logger.info('put failed: %s', data, exc_info=True)
|
||||||
return False
|
return False
|
||||||
return r.status == 200
|
return r.status == 200
|
||||||
|
|
|
@ -44,7 +44,7 @@ def can_connect(data):
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
#logger.debug('failed to connect to local node %s', data, exc_info=1)
|
#logger.debug('failed to connect to local node %s', data, exc_info=True)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ class LocalNodesBase(Thread):
|
||||||
self.wait(60)
|
self.wait(60)
|
||||||
except:
|
except:
|
||||||
if self._active:
|
if self._active:
|
||||||
logger.debug('receive failed. restart later', exc_info=1)
|
logger.debug('receive failed. restart later', exc_info=True)
|
||||||
self.wait(60)
|
self.wait(60)
|
||||||
finally:
|
finally:
|
||||||
if self._active:
|
if self._active:
|
||||||
|
@ -188,7 +188,7 @@ class LocalNodes4(LocalNodesBase):
|
||||||
try:
|
try:
|
||||||
s.sendto(packet + b'\0', sockaddr)
|
s.sendto(packet + b'\0', sockaddr)
|
||||||
except:
|
except:
|
||||||
logger.debug('LocalNodes4.send failed', exc_info=1)
|
logger.debug('LocalNodes4.send failed', exc_info=True)
|
||||||
s.close()
|
s.close()
|
||||||
|
|
||||||
def get_socket(self):
|
def get_socket(self):
|
||||||
|
@ -222,7 +222,7 @@ class LocalNodes6(LocalNodesBase):
|
||||||
try:
|
try:
|
||||||
s.sendto(packet + b'\0', sockaddr)
|
s.sendto(packet + b'\0', sockaddr)
|
||||||
except:
|
except:
|
||||||
logger.debug('LocalNodes6.send failed', exc_info=1)
|
logger.debug('LocalNodes6.send failed', exc_info=True)
|
||||||
s.close()
|
s.close()
|
||||||
|
|
||||||
def get_socket(self):
|
def get_socket(self):
|
||||||
|
|
|
@ -44,7 +44,7 @@ def metadata(f, from_=None):
|
||||||
elif ext == 'txt':
|
elif ext == 'txt':
|
||||||
info = txt.info(f)
|
info = txt.info(f)
|
||||||
except:
|
except:
|
||||||
logger.debug('failed to load %s info from %s', ext, f, exc_info=1)
|
logger.debug('failed to load %s info from %s', ext, f, exc_info=True)
|
||||||
info = {}
|
info = {}
|
||||||
|
|
||||||
opf_info = {}
|
opf_info = {}
|
||||||
|
@ -134,6 +134,6 @@ def extract_text(path):
|
||||||
elif ext == 'txt':
|
elif ext == 'txt':
|
||||||
text = txt.extract_text(path)
|
text = txt.extract_text(path)
|
||||||
except:
|
except:
|
||||||
logger.debug('failed to extract text from %s', path, exc_info=1)
|
logger.debug('failed to extract text from %s', path, exc_info=True)
|
||||||
text = ''
|
text = ''
|
||||||
return text
|
return text
|
||||||
|
|
|
@ -17,7 +17,7 @@ def info(opf):
|
||||||
with open(opf, 'rb') as fd:
|
with open(opf, 'rb') as fd:
|
||||||
opf = ET.fromstring(fd.read().decode())
|
opf = ET.fromstring(fd.read().decode())
|
||||||
except:
|
except:
|
||||||
logger.debug('failed to load opf %s', opf, exc_info=1)
|
logger.debug('failed to load opf %s', opf, exc_info=True)
|
||||||
return data
|
return data
|
||||||
ns = '{http://www.idpf.org/2007/opf}'
|
ns = '{http://www.idpf.org/2007/opf}'
|
||||||
metadata = opf.findall(ns + 'metadata')[0]
|
metadata = opf.findall(ns + 'metadata')[0]
|
||||||
|
|
|
@ -164,7 +164,7 @@ def info(pdf):
|
||||||
if value and _key not in data:
|
if value and _key not in data:
|
||||||
data[_key] = value
|
data[_key] = value
|
||||||
except:
|
except:
|
||||||
logger.debug('FAILED TO PARSE %s', pdf, exc_info=1)
|
logger.debug('FAILED TO PARSE %s', pdf, exc_info=True)
|
||||||
|
|
||||||
'''
|
'''
|
||||||
cmd = ['pdfinfo', pdf]
|
cmd = ['pdfinfo', pdf]
|
||||||
|
|
|
@ -48,7 +48,7 @@ def lookup(id):
|
||||||
data = read_url(url, timeout=0).decode('utf-8')
|
data = read_url(url, timeout=0).decode('utf-8')
|
||||||
mods = ET.fromstring(data)
|
mods = ET.fromstring(data)
|
||||||
except:
|
except:
|
||||||
logger.debug('lookup for %s url: %s failed', id, url, exc_info=1)
|
logger.debug('lookup for %s url: %s failed', id, url, exc_info=True)
|
||||||
return info
|
return info
|
||||||
|
|
||||||
title = mods.findall(ns + 'titleInfo')
|
title = mods.findall(ns + 'titleInfo')
|
||||||
|
|
|
@ -21,7 +21,7 @@ def request(action, data):
|
||||||
try:
|
try:
|
||||||
return json.loads(read_url(url, data, timeout=60).decode('utf-8'))['data']
|
return json.loads(read_url(url, data, timeout=60).decode('utf-8'))['data']
|
||||||
except:
|
except:
|
||||||
logger.debug('metadata request failed', exc_info=1)
|
logger.debug('metadata request failed', exc_info=True)
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
def find(query):
|
def find(query):
|
||||||
|
|
|
@ -212,7 +212,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
if self.headers.get('Content-Encoding') == 'gzip':
|
if self.headers.get('Content-Encoding') == 'gzip':
|
||||||
data = self.gunzip_data(data)
|
data = self.gunzip_data(data)
|
||||||
except:
|
except:
|
||||||
logger.debug('invalid request', exc_info=1)
|
logger.debug('invalid request', exc_info=True)
|
||||||
response_status = (500, 'invalid request')
|
response_status = (500, 'invalid request')
|
||||||
self.write_response(response_status, content)
|
self.write_response(response_status, content)
|
||||||
return
|
return
|
||||||
|
@ -229,7 +229,7 @@ class Handler(http.server.SimpleHTTPRequestHandler):
|
||||||
try:
|
try:
|
||||||
action, args = json.loads(data.decode('utf-8'))
|
action, args = json.loads(data.decode('utf-8'))
|
||||||
except:
|
except:
|
||||||
logger.debug('invalid data: %s', data, exc_info=1)
|
logger.debug('invalid data: %s', data, exc_info=True)
|
||||||
response_status = (500, 'invalid request')
|
response_status = (500, 'invalid request')
|
||||||
content = {
|
content = {
|
||||||
'status': 'invalid request'
|
'status': 'invalid request'
|
||||||
|
|
12
oml/nodes.py
12
oml/nodes.py
|
@ -117,7 +117,7 @@ class Node(Thread):
|
||||||
try:
|
try:
|
||||||
r = directory.get(vk)
|
r = directory.get(vk)
|
||||||
except:
|
except:
|
||||||
logger.debug('directory failed', exc_info=1)
|
logger.debug('directory failed', exc_info=True)
|
||||||
r = None
|
r = None
|
||||||
if r and 'id' in r and len(r['id']) == 16:
|
if r and 'id' in r and len(r['id']) == 16:
|
||||||
u = self.user
|
u = self.user
|
||||||
|
@ -169,7 +169,7 @@ class Node(Thread):
|
||||||
self.online = False
|
self.online = False
|
||||||
return None
|
return None
|
||||||
except:
|
except:
|
||||||
logger.debug('unknown url error', exc_info=1)
|
logger.debug('unknown url error', exc_info=True)
|
||||||
self.online = False
|
self.online = False
|
||||||
return None
|
return None
|
||||||
data = r.read()
|
data = r.read()
|
||||||
|
@ -304,7 +304,7 @@ class Node(Thread):
|
||||||
try:
|
try:
|
||||||
r = self._opener.open(url, timeout=self.TIMEOUT*5)
|
r = self._opener.open(url, timeout=self.TIMEOUT*5)
|
||||||
except:
|
except:
|
||||||
logger.debug('openurl failed %s', url, exc_info=1)
|
logger.debug('openurl failed %s', url, exc_info=True)
|
||||||
return False
|
return False
|
||||||
if r.getcode() == 200:
|
if r.getcode() == 200:
|
||||||
try:
|
try:
|
||||||
|
@ -343,7 +343,7 @@ class Node(Thread):
|
||||||
self.download_speed = size / duration
|
self.download_speed = size / duration
|
||||||
return item.save_file(content)
|
return item.save_file(content)
|
||||||
except:
|
except:
|
||||||
logger.debug('download failed %s', url, exc_info=1)
|
logger.debug('download failed %s', url, exc_info=True)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
logger.debug('FAILED %s', url)
|
logger.debug('FAILED %s', url)
|
||||||
|
@ -358,7 +358,7 @@ class Node(Thread):
|
||||||
try:
|
try:
|
||||||
r = self._opener.open(url, timeout=self.TIMEOUT*2)
|
r = self._opener.open(url, timeout=self.TIMEOUT*2)
|
||||||
except:
|
except:
|
||||||
logger.debug('openurl failed %s', url, exc_info=1)
|
logger.debug('openurl failed %s', url, exc_info=True)
|
||||||
return False
|
return False
|
||||||
code = r.getcode()
|
code = r.getcode()
|
||||||
if code == 200:
|
if code == 200:
|
||||||
|
@ -372,7 +372,7 @@ class Node(Thread):
|
||||||
icons.clear(key+':')
|
icons.clear(key+':')
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
logger.debug('preview download failed %s', url, exc_info=1)
|
logger.debug('preview download failed %s', url, exc_info=True)
|
||||||
elif code == 404:
|
elif code == 404:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -96,7 +96,7 @@ def api_task(context, request, callback):
|
||||||
try:
|
try:
|
||||||
response = f(data)
|
response = f(data)
|
||||||
except:
|
except:
|
||||||
logger.debug('FAILED %s %s', action, data, exc_info=1)
|
logger.debug('FAILED %s %s', action, data, exc_info=True)
|
||||||
response = json_response(status=500, text='%s failed' % action)
|
response = json_response(status=500, text='%s failed' % action)
|
||||||
else:
|
else:
|
||||||
response = json_response(status=400, text='Unknown action %s' % action)
|
response = json_response(status=400, text='Unknown action %s' % action)
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Tasks(Thread):
|
||||||
trigger_event('error', {'error': 'unknown action'})
|
trigger_event('error', {'error': 'unknown action'})
|
||||||
logger.debug('%s done', action)
|
logger.debug('%s done', action)
|
||||||
except:
|
except:
|
||||||
logger.debug('task failed', exc_info=1)
|
logger.debug('task failed', exc_info=True)
|
||||||
self.q.task_done()
|
self.q.task_done()
|
||||||
|
|
||||||
def join(self):
|
def join(self):
|
||||||
|
|
|
@ -156,7 +156,7 @@ class Tor(object):
|
||||||
if self.daemon:
|
if self.daemon:
|
||||||
self.daemon.shutdown()
|
self.daemon.shutdown()
|
||||||
except:
|
except:
|
||||||
logger.debug('shutdown exception', exc_info=1)
|
logger.debug('shutdown exception', exc_info=True)
|
||||||
pass
|
pass
|
||||||
self.connected = False
|
self.connected = False
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ class Tor(object):
|
||||||
try:
|
try:
|
||||||
self.controller.remove_hidden_service(self.dir)
|
self.controller.remove_hidden_service(self.dir)
|
||||||
except:
|
except:
|
||||||
logger.debug('self.controller.remove_hidden_service fail', exc_info=1)
|
logger.debug('self.controller.remove_hidden_service fail', exc_info=True)
|
||||||
state.online = False
|
state.online = False
|
||||||
|
|
||||||
def is_online(self):
|
def is_online(self):
|
||||||
|
@ -281,7 +281,7 @@ def install_tor():
|
||||||
subprocess.call([desktop, '--register-app'], cwd=os.path.dirname(desktop))
|
subprocess.call([desktop, '--register-app'], cwd=os.path.dirname(desktop))
|
||||||
os.unlink(tar_file)
|
os.unlink(tar_file)
|
||||||
except:
|
except:
|
||||||
logger.debug('tor installation failed', exc_info=1)
|
logger.debug('tor installation failed', exc_info=True)
|
||||||
elif sys.platform == 'darwin':
|
elif sys.platform == 'darwin':
|
||||||
ox.makedirs(target)
|
ox.makedirs(target)
|
||||||
dmg = os.path.join(target, os.path.basename(url))
|
dmg = os.path.join(target, os.path.basename(url))
|
||||||
|
@ -300,6 +300,6 @@ def install_tor():
|
||||||
subprocess.call(['hdiutil', 'unmount', volume])
|
subprocess.call(['hdiutil', 'unmount', volume])
|
||||||
os.unlink(dmg)
|
os.unlink(dmg)
|
||||||
except:
|
except:
|
||||||
logger.debug('tor installation failed', exc_info=1)
|
logger.debug('tor installation failed', exc_info=True)
|
||||||
else:
|
else:
|
||||||
logger.debug('no way to install TorBrowser on %s so far', sys.platform)
|
logger.debug('no way to install TorBrowser on %s so far', sys.platform)
|
||||||
|
|
|
@ -210,7 +210,7 @@ def upgrade_app():
|
||||||
shutil.rmtree(app)
|
shutil.rmtree(app)
|
||||||
shutil.copytree(bundled_app, app)
|
shutil.copytree(bundled_app, app)
|
||||||
except:
|
except:
|
||||||
logger.debug('Failed to update Application', exc_info=1)
|
logger.debug('Failed to update Application', exc_info=True)
|
||||||
|
|
||||||
def getVersion(data):
|
def getVersion(data):
|
||||||
'''
|
'''
|
||||||
|
|
|
@ -71,4 +71,4 @@ def trigger_event(event, data):
|
||||||
try:
|
try:
|
||||||
ws.post(event, data)
|
ws.post(event, data)
|
||||||
except:
|
except:
|
||||||
logger.debug('failed to send to ws %s %s %s', ws, event, data, exc_info=1)
|
logger.debug('failed to send to ws %s %s %s', ws, event, data, exc_info=True)
|
||||||
|
|
Loading…
Reference in a new issue