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
logger = logging.getLogger('oml.directory')
logger = logging.getLogger(__name__)
base = settings.server['directory_service']
base = 'http://hpjats6xixrleoqg.onion:25519'

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -18,7 +18,7 @@ from tor_request import get_opener
import settings
import logging
logger = logging.getLogger('oml.localnodes')
logger = logging.getLogger(__name__)
def can_connect(data):
try:
@ -248,6 +248,11 @@ class LocalNodes(object):
if self._active:
for id in list(self._nodes.keys()):
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]
if not self._active:
break

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -26,7 +26,7 @@ import websocket
import logging
logger = logging.getLogger('oml')
logger = logging.getLogger(__name__)
class MainHandler(OMLHandler):
@ -51,7 +51,7 @@ def run():
else:
logging.basicConfig(level=logging.DEBUG,
filename=settings.log_path, filemode='w',
format='%(asctime)s %(levelname)s %(message)s')
format='%(asctime)s - %(levelname)s - %(name)s - %(message)s')
options = {
'debug': False,
'gzip': True
@ -108,6 +108,9 @@ def run():
else:
with db.session():
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)
for u in user.models.User.query.filter_by(queued=True):
logger.debug('adding queued node... %s', u.id)

View file

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

View file

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

View file

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

View file

@ -13,7 +13,7 @@ import settings
import state
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):
def __init__(self, service_id, cert, reason):

View file

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

View file

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

View file

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

View file

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