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
|
import logging
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
ENCODING='base64'
|
DEBUG_NODES=False
|
||||||
|
|
||||||
class Node(Thread):
|
class Node(Thread):
|
||||||
host = None
|
host = None
|
||||||
|
@ -185,9 +185,11 @@ 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()
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('can connect to: %s', url)
|
logger.debug('can connect to: %s', url)
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('can not connect to: %s', url)
|
logger.debug('can not connect to: %s', url)
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
@ -202,12 +204,15 @@ class Node(Thread):
|
||||||
with db.session():
|
with db.session():
|
||||||
u = user.models.User.get_or_create(self.user_id)
|
u = user.models.User.get_or_create(self.user_id)
|
||||||
if u.peered or u.queued:
|
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)
|
logger.debug('go online peered=%s queued=%s %s (%s)', u.peered, u.queued, u.id, u.nickname)
|
||||||
try:
|
try:
|
||||||
self.online = self.can_connect()
|
self.online = self.can_connect()
|
||||||
if self.online:
|
if self.online:
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('connected to %s', self.url)
|
logger.debug('connected to %s', self.url)
|
||||||
if u.queued:
|
if u.queued:
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('queued peering event pending=%s peered=%s', u.pending, u.peered)
|
logger.debug('queued peering event pending=%s peered=%s', u.pending, u.peered)
|
||||||
if u.pending == 'sent':
|
if u.pending == 'sent':
|
||||||
self.peering('requestPeering')
|
self.peering('requestPeering')
|
||||||
|
@ -217,6 +222,7 @@ class Node(Thread):
|
||||||
#fixme, what about cancel/reject peering here?
|
#fixme, what about cancel/reject peering here?
|
||||||
self.peering('removePeering')
|
self.peering('removePeering')
|
||||||
except:
|
except:
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('failed to connect to %s', self.user_id)
|
logger.debug('failed to connect to %s', self.user_id)
|
||||||
self.online = False
|
self.online = False
|
||||||
|
|
||||||
|
@ -238,6 +244,7 @@ class Node(Thread):
|
||||||
changes = self.request('pullChanges', from_revision)
|
changes = self.request('pullChanges', from_revision)
|
||||||
except:
|
except:
|
||||||
self.online = False
|
self.online = False
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('%s went offline', u.name, exc_info=True)
|
logger.debug('%s went offline', u.name, exc_info=True)
|
||||||
return False
|
return False
|
||||||
if not changes:
|
if not changes:
|
||||||
|
@ -275,6 +282,7 @@ class Node(Thread):
|
||||||
self.resolve()
|
self.resolve()
|
||||||
url = '%s/get/%s' % (self.url, item.id)
|
url = '%s/get/%s' % (self.url, item.id)
|
||||||
t1 = datetime.utcnow()
|
t1 = datetime.utcnow()
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('download %s', url)
|
logger.debug('download %s', url)
|
||||||
self._opener.addheaders = list(zip(self.headers.keys(), self.headers.values()))
|
self._opener.addheaders = list(zip(self.headers.keys(), self.headers.values()))
|
||||||
try:
|
try:
|
||||||
|
@ -340,6 +348,7 @@ class Node(Thread):
|
||||||
def download_preview(self, item_id):
|
def download_preview(self, item_id):
|
||||||
from item.icons import icons
|
from item.icons import icons
|
||||||
self.resolve()
|
self.resolve()
|
||||||
|
if DEBUG_NODES:
|
||||||
logger.debug('download preview for %s from %s', item_id, self.url)
|
logger.debug('download preview for %s from %s', item_id, self.url)
|
||||||
url = '%s/preview/%s' % (self.url, item_id)
|
url = '%s/preview/%s' % (self.url, item_id)
|
||||||
self._opener.addheaders = list(zip(self.headers.keys(), self.headers.values()))
|
self._opener.addheaders = list(zip(self.headers.keys(), self.headers.values()))
|
||||||
|
|
Loading…
Reference in a new issue