use logging.getLogger(__name__)

This commit is contained in:
j 2015-11-29 15:56:38 +01:00
parent 8756e51090
commit d497e89b2b
36 changed files with 47 additions and 39 deletions

View file

@ -11,7 +11,7 @@ import tor_request
import settings import settings
logger = logging.getLogger('oml.directory') logger = logging.getLogger(__name__)
base = settings.server['directory_service'] base = settings.server['directory_service']
base = 'http://hpjats6xixrleoqg.onion:25519' base = 'http://hpjats6xixrleoqg.onion:25519'

View file

@ -13,7 +13,7 @@ import update
from websocket import trigger_event from websocket import trigger_event
import logging import logging
logger = logging.getLogger('oml.downloads') logger = logging.getLogger(__name__)
class Downloads(Thread): class Downloads(Thread):

View file

@ -21,7 +21,7 @@ from . import person_api
from . import title_api from . import title_api
import logging import logging
logger = logging.getLogger('oml.item.api') logger = logging.getLogger(__name__)
def find(data): def find(data):

View file

@ -24,7 +24,7 @@ from oxtornado import json_dumps, json_response
from media import get_id from media import get_id
import logging import logging
logger = logging.getLogger('item.handlers') logger = logging.getLogger(__name__)
class OMLHandler(tornado.web.RequestHandler): class OMLHandler(tornado.web.RequestHandler):

View file

@ -17,7 +17,7 @@ from utils import resize_image
import db import db
import logging import logging
logger = logging.getLogger('oml.item.icons') logger = logging.getLogger(__name__)
class Icons(dict): class Icons(dict):

View file

@ -29,7 +29,7 @@ import state
import utils import utils
import logging import logging
logger = logging.getLogger('oml.item.model') logger = logging.getLogger(__name__)
user_items = sa.Table('useritem', db.metadata, user_items = sa.Table('useritem', db.metadata,
sa.Column('user_id', sa.String(43), sa.ForeignKey('user.id')), sa.Column('user_id', sa.String(43), sa.ForeignKey('user.id')),

View file

@ -8,7 +8,7 @@ from .person import Person
import logging import logging
logger = logging.getLogger('oml.item.person_api') logger = logging.getLogger(__name__)
def parse(data, model): def parse(data, model):

View file

@ -20,7 +20,7 @@ import settings
import state import state
import logging import logging
logger = logging.getLogger('oml.item.scan') logger = logging.getLogger(__name__)
extensions = ['epub', 'pdf', 'txt', 'cbr', 'cbz'] extensions = ['epub', 'pdf', 'txt', 'cbr', 'cbz']

View file

@ -7,7 +7,7 @@ from . import query
import logging import logging
logger = logging.getLogger('oml.item.title_api') logger = logging.getLogger(__name__)
def editTitle(data): def editTitle(data):

View file

@ -18,7 +18,7 @@ from tor_request import get_opener
import settings import settings
import logging import logging
logger = logging.getLogger('oml.localnodes') logger = logging.getLogger(__name__)
def can_connect(data): def can_connect(data):
try: try:
@ -248,6 +248,11 @@ class LocalNodes(object):
if self._active: if self._active:
for id in list(self._nodes.keys()): for id in list(self._nodes.keys()):
if not can_connect(self._nodes[id]): if not can_connect(self._nodes[id]):
with db.session():
u = user.models.User.get(id)
if u and 'local' in u.info:
del u.info['local']
u.save()
del self._nodes[id] del self._nodes[id]
if not self._active: if not self._active:
break break

View file

@ -15,7 +15,7 @@ import stdnum.isbn
from utils import normalize_isbn, find_isbns from utils import normalize_isbn, find_isbns
import logging import logging
logger = logging.getLogger('oml.media.epub') logger = logging.getLogger(__name__)
def cover(path): def cover(path):
logger.debug('cover %s', path) logger.debug('cover %s', path)

View file

@ -16,7 +16,7 @@ import settings
from utils import normalize_isbn, find_isbns from utils import normalize_isbn, find_isbns
import logging import logging
logger = logging.getLogger('oml.meta.pdf') logger = logging.getLogger(__name__)
def cover(pdf): def cover(pdf):
if sys.platform == 'darwin': if sys.platform == 'darwin':

View file

@ -14,7 +14,7 @@ from . import google
from . import duckduckgo from . import duckduckgo
import logging import logging
logger = logging.getLogger('meta') logger = logging.getLogger(__name__)
providers = [ providers = [

View file

@ -8,7 +8,7 @@ from ox.cache import read_url
import lxml.html import lxml.html
import logging import logging
logger = logging.getLogger('meta.abebooks') logger = logging.getLogger(__name__)
base = 'http://www.abebooks.com' base = 'http://www.abebooks.com'

View file

@ -8,7 +8,7 @@ import stdnum.isbn
from .utils import find_isbns from .utils import find_isbns
import logging import logging
logger = logging.getLogger('meta.duckduckgo') logger = logging.getLogger(__name__)
def find(query): def find(query):

View file

@ -8,7 +8,7 @@ import stdnum.isbn
from .utils import find_isbns from .utils import find_isbns
import logging import logging
logger = logging.getLogger('meta.google') logger = logging.getLogger(__name__)
def find(query): def find(query):

View file

@ -12,7 +12,7 @@ from .marc_countries import COUNTRIES
from .utils import normalize_isbn from .utils import normalize_isbn
import logging import logging
logger = logging.getLogger('meta.loc') logger = logging.getLogger(__name__)
def get_ids(key, value): def get_ids(key, value):

View file

@ -11,7 +11,7 @@ import stdnum.isbn
from .utils import find_isbns from .utils import find_isbns
import logging import logging
logger = logging.getLogger('meta.lookupbyisbn') logger = logging.getLogger(__name__)
base = 'http://www.lookupbyisbn.com' base = 'http://www.lookupbyisbn.com'

View file

@ -13,7 +13,7 @@ from .marc_countries import COUNTRIES
from .utils import normalize_isbn from .utils import normalize_isbn
import logging import logging
logger = logging.getLogger('meta.openlibrary') logger = logging.getLogger(__name__)
KEYS = { KEYS = {

View file

@ -12,7 +12,7 @@ import stdnum.isbn
from .utils import normalize_isbn from .utils import normalize_isbn
import logging import logging
logger = logging.getLogger('meta.worldcat') logger = logging.getLogger(__name__)
base_url = 'http://www.worldcat.org' base_url = 'http://www.worldcat.org'

View file

@ -8,7 +8,7 @@ from urllib.parse import urlencode
from ox.cache import read_url from ox.cache import read_url
import logging import logging
logger = logging.getLogger('metaremote') logger = logging.getLogger(__name__)
def request(action, data): def request(action, data):
data = urlencode({ data = urlencode({

View file

@ -13,7 +13,7 @@ import meta
import utils import utils
import logging import logging
logger = logging.getLogger('metaoml') logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
def findMetadata(data): def findMetadata(data):

View file

@ -9,7 +9,7 @@ import settings
import state import state
import logging import logging
logger = logging.getLogger('oml.node.nodeapi') logger = logging.getLogger(__name__)
def api_pullChanges(remote_id, user_id=None, from_=None, to=None): def api_pullChanges(remote_id, user_id=None, from_=None, to=None):
if user_id and not from_ and not to: if user_id and not from_ and not to:

View file

@ -29,7 +29,7 @@ from . import nodeapi
from .sslsocket import fileobject from .sslsocket import fileobject
import logging import logging
logger = logging.getLogger('oml.node.server') logger = logging.getLogger(__name__)
def get_service_id(key): def get_service_id(key):

View file

@ -29,7 +29,7 @@ import state
import db import db
import logging import logging
logger = logging.getLogger('oml.nodes') logger = logging.getLogger(__name__)
ENCODING='base64' ENCODING='base64'

View file

@ -16,7 +16,7 @@ from threading import Thread
from functools import wraps from functools import wraps
import logging import logging
logger = logging.getLogger('oxtornado') logger = logging.getLogger(__name__)
def json_response(data=None, status=200, text='ok'): def json_response(data=None, status=200, text='ok'):

View file

@ -9,7 +9,7 @@ import utils
import settings import settings
import logging import logging
logger = logging.getLogger('queryparser') logger = logging.getLogger(__name__)
def get_operator(op, type='str'): def get_operator(op, type='str'):
return { return {

View file

@ -26,7 +26,7 @@ import websocket
import logging import logging
logger = logging.getLogger('oml') logger = logging.getLogger(__name__)
class MainHandler(OMLHandler): class MainHandler(OMLHandler):
@ -51,7 +51,7 @@ def run():
else: else:
logging.basicConfig(level=logging.DEBUG, logging.basicConfig(level=logging.DEBUG,
filename=settings.log_path, filemode='w', filename=settings.log_path, filemode='w',
format='%(asctime)s %(levelname)s %(message)s') format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
options = { options = {
'debug': False, 'debug': False,
'gzip': True 'gzip': True
@ -108,6 +108,9 @@ def run():
else: else:
with db.session(): with db.session():
for u in user.models.User.query.filter_by(peered=True): for u in user.models.User.query.filter_by(peered=True):
if 'local' in u.info:
del u.info['local']
u.save()
state.nodes.queue('add', u.id) state.nodes.queue('add', u.id)
for u in user.models.User.query.filter_by(queued=True): for u in user.models.User.query.filter_by(queued=True):
logger.debug('adding queued node... %s', u.id) logger.debug('adding queued node... %s', u.id)

View file

@ -9,7 +9,7 @@ import logging
import base64 import base64
from OpenSSL import crypto from OpenSSL import crypto
logger = logging.getLogger('oml.ssl_request') logger = logging.getLogger(__name__)
def get_service_id(cert): def get_service_id(cert):
# compute sha1 of public key and encode first half in base32 # compute sha1 of public key and encode first half in base32

View file

@ -9,7 +9,7 @@ from websocket import trigger_event
import logging import logging
logger = logging.getLogger('oml.tasks') logger = logging.getLogger(__name__)
class Tasks(Thread): class Tasks(Thread):

View file

@ -7,11 +7,10 @@ import stem
from stem.control import Controller from stem.control import Controller
import settings import settings
import logging
import state import state
import time
logger = logging.getLogger('oml.tor') import logging
logger = logging.getLogger(__name__)
class TorDaemon(Thread): class TorDaemon(Thread):
def __init__(self): def __init__(self):
@ -75,6 +74,7 @@ DirReqStatistics 0
self.p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True) self.p = subprocess.Popen(cmd, stdout=subprocess.PIPE, bufsize=1, universal_newlines=True)
for line in self.p.stdout: for line in self.p.stdout:
self._status.append(line) self._status.append(line)
logger.debug(line)
self.p = None self.p = None
def shutdown(self): def shutdown(self):

View file

@ -13,7 +13,7 @@ import settings
import state import state
from utils import get_service_id, get_local_ipv4 from utils import get_service_id, get_local_ipv4
logger = logging.getLogger('oml.tor_request') logger = logging.getLogger(__name__)
class InvalidCertificateException(http.client.HTTPException, urllib.error.URLError): class InvalidCertificateException(http.client.HTTPException, urllib.error.URLError):
def __init__(self, service_id, cert, reason): def __init__(self, service_id, cert, reason):

View file

@ -16,7 +16,7 @@ import settings
import state import state
import logging import logging
logger = logging.getLogger('oml.user.api') logger = logging.getLogger(__name__)
def init(data): def init(data):

View file

@ -14,7 +14,7 @@ import settings
import state import state
import logging import logging
logger = logging.getLogger('oml.user.models') logger = logging.getLogger(__name__)
class User(db.Model): class User(db.Model):
__tablename__ = 'user' __tablename__ = 'user'

View file

@ -32,7 +32,7 @@ from Crypto.Util.asn1 import DerSequence
from meta.utils import normalize_isbn, find_isbns from meta.utils import normalize_isbn, find_isbns
import logging import logging
logger = logging.getLogger('oml.utils') logger = logging.getLogger(__name__)
ENCODING='base64' ENCODING='base64'

View file

@ -11,7 +11,7 @@ from oxtornado import json_dumps
import state import state
import logging import logging
logger = logging.getLogger('oml.websocket') logger = logging.getLogger(__name__)
class Handler(WebSocketHandler): class Handler(WebSocketHandler):