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 = {
|
headers = {
|
||||||
'User-Agent': settings.USER_AGENT
|
'User-Agent': settings.USER_AGENT
|
||||||
}
|
}
|
||||||
|
try:
|
||||||
r = requests.get(url, headers=headers)
|
r = requests.get(url, headers=headers)
|
||||||
|
except:
|
||||||
|
logger.info('get failed %s', url)
|
||||||
|
return None
|
||||||
sig = r.headers.get('X-Ed25519-Signature')
|
sig = r.headers.get('X-Ed25519-Signature')
|
||||||
data = r.content
|
data = r.content
|
||||||
if sig and data:
|
if sig and data:
|
||||||
|
@ -47,8 +51,6 @@ def put(sk, data):
|
||||||
try:
|
try:
|
||||||
r = requests.put(url, data, headers=headers, timeout=2)
|
r = requests.put(url, data, headers=headers, timeout=2)
|
||||||
except:
|
except:
|
||||||
import traceback
|
logger.info('put failed: %s', data)
|
||||||
logger.info('directory.put failed: %s', data)
|
|
||||||
traceback.print_exc()
|
|
||||||
return False
|
return False
|
||||||
return r.status_code == 200
|
return r.status_code == 200
|
||||||
|
|
|
@ -201,7 +201,6 @@ class Node(Thread):
|
||||||
try:
|
try:
|
||||||
url = self.url
|
url = self.url
|
||||||
if url:
|
if url:
|
||||||
logger.debug('try to connect to %s', url)
|
|
||||||
headers = {
|
headers = {
|
||||||
'User-Agent': settings.USER_AGENT,
|
'User-Agent': settings.USER_AGENT,
|
||||||
'X-Node-Protocol': settings.NODE_PROTOCOL,
|
'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)
|
logger.debug('version does not match local: %s remote %s', settings.NODE_PROTOCOL, version)
|
||||||
return False
|
return False
|
||||||
c = r.read()
|
c = r.read()
|
||||||
logger.debug('ok')
|
logger.debug('can connect to: %s (%s)', url, self.user.nickname)
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
logger.debug('can not connect to: %s (%s)', url, self.user.nickname)
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _go_online(self):
|
def _go_online(self):
|
||||||
self.resolve()
|
self.resolve()
|
||||||
u = self.user
|
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:
|
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:
|
try:
|
||||||
self.online = False
|
self.online = False
|
||||||
logger.debug('try to connect to %s at [%s]:%s', self.user_id, self.host, self.port)
|
|
||||||
if self.can_connect():
|
if self.can_connect():
|
||||||
logger.debug('connected to [%s]:%s', self.host, self.port)
|
logger.debug('connected to [%s]:%s', self.host, self.port)
|
||||||
self.online = True
|
self.online = True
|
||||||
|
|
|
@ -49,6 +49,8 @@ class FingerprintHTTPSConnection(http.client.HTTPSConnection):
|
||||||
self._fingerprint, len(self._fingerprint))
|
self._fingerprint, len(self._fingerprint))
|
||||||
return False
|
return False
|
||||||
logger.debug('ssl fingerprint: %s (match: %s)', fingerprint, fingerprint == self._fingerprint)
|
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
|
return fingerprint == self._fingerprint
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
|
|
Loading…
Reference in a new issue