Exemple #1
0
    def configure_options(cls, **options):
        """Call the method to set up some arguments, all optional.

        You can set keyword arguments as follow:
         - host: Ip address. Default to `0.0.0.0`.
         - port: port, which server will listen. Default to 6881.
         - node_size: max size is 2**160, that's capacity of DHT
         network. Default to 2**160.
         - thread_num: Thread numbers, thread pool required. Default
         to 8.
         - q_size: Thread worker queue size, thread pool required.
         Default to 200.
         - log_level: Which level message you want to see. It can be
         "debug", "info", "warning", "error". Default to "info".
         - log_file_prefix: Log file name. Default to None.
         - log_file_max_size: Bytes, the capacity of log file. Default
         to 0, disallow the file to rollover at a predetermined size.
         - log_file_num_backups: If it is non-zero, the argument
         `log_file_max_size` must non-zero. If `log_file_max_size` is
         about to be exceeded, the file is closed and new log file is
         silently opened for output, file name like `log.1`, `log.2`.
         Default to 0, just like `log_file_max_size`.
        """
        cls._options = dict()
        cls._options.update(options)

        log_level = options.get('log_level', "info")
        log_file_prefix = options.get('log_file_prefix', None)
        log_file_options = None
        if log_file_prefix:
            log_file_options = {
                'log_file_prefix': log_file_prefix,
                'log_file_max_size': options.get('log_file_max_size', 0),
                'log_file_num_backups': options.get('log_file_num_backups', 0),
            }
        enable_pretty_logging(log_level, log_file_options)
import collections
import copy
import functools
import itertools
import json
import time
from sentinels import NOTHING
from .filtering import filter_applies, resolve_key_value
from . import ObjectId, OperationFailure, DuplicateKeyError
from .helpers import basestring, mimic_async
import logging
import log as log_helpers

log = logging.getLogger(__name__)
log_helpers.enable_pretty_logging("INFO", log)

try:
    # Optional requirements for providing Map-Reduce functionality
    import execjs
except ImportError:
    execjs = None

try:
    from bson import json_util, SON
except ImportError:
    json_utils = SON = None

from six import string_types, text_type, iteritems, itervalues, iterkeys


class Collection(object):
Exemple #3
0
# Author: Binux<*****@*****.**>
#         http://binux.me
# Created on 2013-01-26 13:27:42

import time
import logging
import itertools

import log
import utils
import ingress as _ingress
import database
import gen_path

import logging;logging.getLogger().setLevel(logging.INFO)
log.enable_pretty_logging()

COOLDOWN_MSG = {u'gameBasket': {u'deletedEntityGuids': [],
                  u'gameEntities': [],
                  u'inventory': []},
                  u'result': {u'addedGuids': []}}

_continue = True
_debug = True

_collect_xm = True
_hack = True
_hack_log = True
_auto_drop = True
_pickup = False
_install_mod = False
Exemple #4
0
#         http://binux.me
# Created on 2013-01-26 13:27:42

import time
import logging
import itertools

import log
import utils
import ingress as _ingress
import database
import gen_path

import logging
logging.getLogger().setLevel(logging.INFO)
log.enable_pretty_logging()

COOLDOWN_MSG = {
    u'gameBasket': {
        u'deletedEntityGuids': [],
        u'gameEntities': [],
        u'inventory': []
    },
    u'result': {
        u'addedGuids': []
    }
}

_continue = True
_debug = True
Exemple #5
0
from functools import wraps
import re

try:
    from bson import (ObjectId, RE_TYPE)
except ImportError:
    from mongomock.object_id import ObjectId
    RE_TYPE = type(re.compile(''))

import logging
log = logging.getLogger(__name__)
import log as log_helpers

log_helpers.enable_pretty_logging('INFO', log)

#for Python 3 compatibility
try:
  unicode = unicode
  from __builtin__ import basestring
except NameError:
  unicode = str
  basestring = (str, bytes)

def _fields_list_to_dict(fields):
    """Takes a list of field names and returns a matching dictionary.

    ["a", "b"] becomes {"a": 1, "b": 1}

    and

    ["a.b.c", "d", "a.c"] becomes {"a.b.c": 1, "d": 1, "a.c": 1}