log less
This commit is contained in:
parent
edcd933f2b
commit
3a419b12c2
1 changed files with 19 additions and 10 deletions
11
oml/nodes.py
11
oml/nodes.py
|
@ -31,7 +31,7 @@ import library
|
|||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
ENCODING='base64'
|
||||
DEBUG_NODES=False
|
||||
|
||||
class Node(Thread):
|
||||
host = None
|
||||
|
@ -185,9 +185,11 @@ class Node(Thread):
|
|||
logger.debug('version does not match local: %s remote %s', settings.NODE_PROTOCOL, version)
|
||||
return False
|
||||
c = r.read()
|
||||
if DEBUG_NODES:
|
||||
logger.debug('can connect to: %s', url)
|
||||
return True
|
||||
except:
|
||||
if DEBUG_NODES:
|
||||
logger.debug('can not connect to: %s', url)
|
||||
pass
|
||||
return False
|
||||
|
@ -202,12 +204,15 @@ class Node(Thread):
|
|||
with db.session():
|
||||
u = user.models.User.get_or_create(self.user_id)
|
||||
if u.peered or u.queued:
|
||||
if DEBUG_NODES:
|
||||
logger.debug('go online peered=%s queued=%s %s (%s)', u.peered, u.queued, u.id, u.nickname)
|
||||
try:
|
||||
self.online = self.can_connect()
|
||||
if self.online:
|
||||
if DEBUG_NODES:
|
||||
logger.debug('connected to %s', self.url)
|
||||
if u.queued:
|
||||
if DEBUG_NODES:
|
||||
logger.debug('queued peering event pending=%s peered=%s', u.pending, u.peered)
|
||||
if u.pending == 'sent':
|
||||
self.peering('requestPeering')
|
||||
|
@ -217,6 +222,7 @@ class Node(Thread):
|
|||
#fixme, what about cancel/reject peering here?
|
||||
self.peering('removePeering')
|
||||
except:
|
||||
if DEBUG_NODES:
|
||||
logger.debug('failed to connect to %s', self.user_id)
|
||||
self.online = False
|
||||
|
||||
|
@ -238,6 +244,7 @@ class Node(Thread):
|
|||
changes = self.request('pullChanges', from_revision)
|
||||
except:
|
||||
self.online = False
|
||||
if DEBUG_NODES:
|
||||
logger.debug('%s went offline', u.name, exc_info=True)
|
||||
return False
|
||||
if not changes:
|
||||
|
@ -275,6 +282,7 @@ class Node(Thread):
|
|||
self.resolve()
|
||||
url = '%s/get/%s' % (self.url, item.id)
|
||||
t1 = datetime.utcnow()
|
||||
if DEBUG_NODES:
|
||||
logger.debug('download %s', url)
|
||||
self._opener.addheaders = list(zip(self.headers.keys(), self.headers.values()))
|
||||
try:
|
||||
|
@ -340,6 +348,7 @@ class Node(Thread):
|
|||
def download_preview(self, item_id):
|
||||
from item.icons import icons
|
||||
self.resolve()
|
||||
if DEBUG_NODES:
|
||||
logger.debug('download preview for %s from %s', item_id, self.url)
|
||||
url = '%s/preview/%s' % (self.url, item_id)
|
||||
self._opener.addheaders = list(zip(self.headers.keys(), self.headers.values()))
|
||||
|
|
Loading…
Reference in a new issue