cleanup logging
This commit is contained in:
parent
013090893d
commit
16a24fa5cc
3 changed files with 11 additions and 8 deletions
|
@ -21,7 +21,11 @@ def get(vk):
|
|||
headers = {
|
||||
'User-Agent': settings.USER_AGENT
|
||||
}
|
||||
r = requests.get(url, headers=headers)
|
||||
try:
|
||||
r = requests.get(url, headers=headers)
|
||||
except:
|
||||
logger.info('get failed %s', url)
|
||||
return None
|
||||
sig = r.headers.get('X-Ed25519-Signature')
|
||||
data = r.content
|
||||
if sig and data:
|
||||
|
@ -47,8 +51,6 @@ def put(sk, data):
|
|||
try:
|
||||
r = requests.put(url, data, headers=headers, timeout=2)
|
||||
except:
|
||||
import traceback
|
||||
logger.info('directory.put failed: %s', data)
|
||||
traceback.print_exc()
|
||||
logger.info('put failed: %s', data)
|
||||
return False
|
||||
return r.status_code == 200
|
||||
|
|
|
@ -201,7 +201,6 @@ class Node(Thread):
|
|||
try:
|
||||
url = self.url
|
||||
if url:
|
||||
logger.debug('try to connect to %s', url)
|
||||
headers = {
|
||||
'User-Agent': settings.USER_AGENT,
|
||||
'X-Node-Protocol': settings.NODE_PROTOCOL,
|
||||
|
@ -215,20 +214,20 @@ class Node(Thread):
|
|||
logger.debug('version does not match local: %s remote %s', settings.NODE_PROTOCOL, version)
|
||||
return False
|
||||
c = r.read()
|
||||
logger.debug('ok')
|
||||
logger.debug('can connect to: %s (%s)', url, self.user.nickname)
|
||||
return True
|
||||
except:
|
||||
logger.debug('can not connect to: %s (%s)', url, self.user.nickname)
|
||||
pass
|
||||
return False
|
||||
|
||||
def _go_online(self):
|
||||
self.resolve()
|
||||
u = self.user
|
||||
logger.debug('go_online peer=%s queued=%s (%s)', u.peered, u.queued, u.id)
|
||||
if (u.peered or u.queued) and self.host:
|
||||
logger.debug('go_online peered=%s queued=%s %s [%s]:%s (%s)', u.peered, u.queued, u.id, self.host, self.port, u.nickname)
|
||||
try:
|
||||
self.online = False
|
||||
logger.debug('try to connect to %s at [%s]:%s', self.user_id, self.host, self.port)
|
||||
if self.can_connect():
|
||||
logger.debug('connected to [%s]:%s', self.host, self.port)
|
||||
self.online = True
|
||||
|
|
|
@ -49,6 +49,8 @@ class FingerprintHTTPSConnection(http.client.HTTPSConnection):
|
|||
self._fingerprint, len(self._fingerprint))
|
||||
return False
|
||||
logger.debug('ssl fingerprint: %s (match: %s)', fingerprint, fingerprint == self._fingerprint)
|
||||
if fingerprint != self._fingerprint:
|
||||
logger.debug('expected fingerprint: %s', self._fingerprint)
|
||||
return fingerprint == self._fingerprint
|
||||
|
||||
def connect(self):
|
||||
|
|
Loading…
Reference in a new issue