From 16a24fa5cc2bea0ce9d395900abecdd99a9979d2 Mon Sep 17 00:00:00 2001 From: j Date: Fri, 27 Feb 2015 16:19:56 +0530 Subject: [PATCH] cleanup logging --- oml/directory.py | 10 ++++++---- oml/nodes.py | 7 +++---- oml/ssl_request.py | 2 ++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/oml/directory.py b/oml/directory.py index c0b384f..9ea6ef8 100644 --- a/oml/directory.py +++ b/oml/directory.py @@ -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 diff --git a/oml/nodes.py b/oml/nodes.py index d87e66e..74ef91b 100644 --- a/oml/nodes.py +++ b/oml/nodes.py @@ -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 diff --git a/oml/ssl_request.py b/oml/ssl_request.py index 7442534..0bb2a06 100644 --- a/oml/ssl_request.py +++ b/oml/ssl_request.py @@ -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):