当前位置: 首页>>代码示例>>Python>>正文


Python logger.getLogger函数代码示例

本文整理汇总了Python中pymor.core.logger.getLogger函数的典型用法代码示例。如果您正苦于以下问题:Python getLogger函数的具体用法?Python getLogger怎么用?Python getLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getLogger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set

 def set(self, key, value):
     if key in self._cache:
         getLogger('pymor.core.cache.MemoryRegion').warn('Key already present in cache region, ignoring.')
         return
     if len(self._cache) == self.max_keys:
         self._cache.popitem(last=False)
     self._cache[key] = value
开发者ID:renemilk,项目名称:pyMor,代码行数:7,代码来源:cache.py

示例2: set

 def set(self, key, value):
     key = base64.b64encode(key)
     now = datetime.datetime.now()
     filename = now.isoformat() + '.dat'
     file_path = os.path.join(self.path, filename)
     while os.path.exists(file_path):
         now = now + datetime.timedelta(microseconds=1)
         filename = now().isoformat()
         file_path = os.path.join(self.path, filename)
     fd = os.open(file_path, os.O_WRONLY | os.O_EXCL | os.O_CREAT)
     try:
         f = os.fdopen(fd, 'w')
         dump(value, f)
         file_size = f.tell()
     finally:
         f.close()
     conn = self.conn
     c = conn.cursor()
     try:
         c.execute("INSERT INTO entries(key, filename, size) VALUES ('{}', '{}', {})".format(key, filename, file_size))
         conn.commit()
     except sqlite3.IntegrityError:
         conn.commit()
         from pymor.core.logger import getLogger
         getLogger('pymor.core.cache.SQLiteRegion').warn('Key already present in cache region, ignoring.')
         os.unlink(file_path)
     self.bytes_written += file_size
     if self.bytes_written >= 0.1 * self.max_size:
         self.housekeeping()
开发者ID:ftalbrecht,项目名称:pymor,代码行数:29,代码来源:cache.py

示例3: housekeeping

    def housekeeping(self):
        self.bytes_written = 0
        conn = self.conn
        c = conn.cursor()
        c.execute('SELECT SUM(size) FROM entries')
        size = c.fetchone()
        # size[0] can apparently also be None
        try:
            size = int(size[0]) if size is not None else 0
        except TypeError:
            size = 0
        if size > self.max_size:
            bytes_to_delete = size - self.max_size + 0.75 * self.max_size
            deleted = 0
            ids_to_delete = []
            files_to_delete = []
            c.execute('SELECT id, filename, size FROM entries ORDER BY id ASC')
            while deleted < bytes_to_delete:
                id_, filename, file_size = c.fetchone()
                ids_to_delete.append(id_)
                files_to_delete.append(filename)
                deleted += file_size
            c.execute('DELETE FROM entries WHERE id in ({})'.format(','.join(map(str, ids_to_delete))))
            conn.commit()
            path = self.path
            for filename in files_to_delete:
                try:
                    os.unlink(os.path.join(path, filename))
                except OSError:
                    from pymor.core.logger import getLogger
                    getLogger('pymor.core.cache.SQLiteRegion').warn('Cannot delete cache entry ' + filename)

            from pymor.core.logger import getLogger
            getLogger('pymor.core.cache.SQLiteRegion').info('Removed {} old cache entries'.format(len(ids_to_delete)))
开发者ID:renemilk,项目名称:pyMor,代码行数:34,代码来源:cache.py

示例4: set

 def set(self, key, value):
     key = base64.b64encode(key)
     response = self.server.set(self.secret, key)
     assert len(response) == 2 and isinstance(response[0], bool) and isinstance(response[1], str)
     if response[0]:
         with open(response[1], 'w') as f:
             dump(value, f)
             file_size = f.tell()
         response = self.server.set_finished(self.secret, key, file_size)
         assert isinstance(response, bool) and response
     else:
         from pymor.core.logger import getLogger
         getLogger('pymor.core.network_cache.NetworkFilesystemRegion')\
             .warn('Key already present in cache region, ignoring.')
开发者ID:lucas-ca,项目名称:pymor,代码行数:14,代码来源:network_cache.py

示例5: _setup

def _setup(name='pymor'):
    root_logger = logger.getLogger(name)
    root_logger.setLevel(logging.ERROR)
    test_logger = logger.getLogger(name)
    test_logger.setLevel(logging.DEBUG)  # config_files.append(os.path.join(os.path.dirname(pymor.__file__), '../../setup.cfg'))
    # config defaults to no plugins -> specify defaults...
    manager = nose.plugins.manager.DefaultPluginManager()
    config_files = nose.config.all_config_files()
    config = nose.config.Config(files=config_files, plugins=manager)
    config.exclude = []
    selector = PymorTestSelector(config=config)
    loader = nose.loader.defaultTestLoader(config=config, selector=selector)
    cli = [__file__, '-vv', '-d']
    return cli, loader, config
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:14,代码来源:base.py

示例6: _call_pymess_dense_nm_gmpare

    def _call_pymess_dense_nm_gmpare(A, E, B, C, R, S, trans=False, options=None, plus=False):
        """Return the solution from pymess.dense_nm_gmpare solver."""
        A = to_matrix(A, format='dense')
        E = to_matrix(E, format='dense') if E else None
        B = B.to_numpy().T
        C = C.to_numpy()
        S = S.to_numpy().T if S else None

        Q = B.dot(B.T) if not trans else C.T.dot(C)
        pymess_trans = pymess.MESS_OP_NONE if not trans else pymess.MESS_OP_TRANSPOSE
        if not trans:
            RinvC = spla.solve(R, C) if R is not None else C
            G = C.T.dot(RinvC)
            if S is not None:
                RinvST = spla.solve(R, S.T) if R is not None else S.T
                if not plus:
                    A -= S.dot(RinvC)
                    Q -= S.dot(RinvST)
                else:
                    A += S.dot(RinvC)
                    Q += S.dot(RinvST)
        else:
            RinvBT = spla.solve(R, B.T) if R is not None else B.T
            G = B.dot(RinvBT)
            if S is not None:
                RinvST = spla.solve(R, S.T) if R is not None else S.T
                if not plus:
                    A -= RinvBT.T.dot(S.T)
                    Q -= S.dot(RinvST)
                else:
                    A += RinvBT.T.dot(S.T)
                    Q += S.dot(RinvST)
        X, absres, relres = pymess.dense_nm_gmpare(None,
                                                   A, E, Q, G,
                                                   plus=plus, trans=pymess_trans,
                                                   linesearch=options['linesearch'],
                                                   maxit=options['maxit'],
                                                   absres_tol=options['absres_tol'],
                                                   relres_tol=options['relres_tol'],
                                                   nrm=options['nrm'])
        if absres > options['absres_tol']:
            logger = getLogger('pymess.dense_nm_gmpcare')
            logger.warning(f'Desired absolute residual tolerance was not achieved '
                           f'({absres:e} > {options["absres_tol"]:e}).')
        if relres > options['relres_tol']:
            logger = getLogger('pymess.dense_nm_gmpcare')
            logger.warning(f'Desired relative residual tolerance was not achieved '
                           f'({relres:e} > {options["relres_tol"]:e}).')

        return X
开发者ID:pymor,项目名称:pymor,代码行数:50,代码来源:pymess.py

示例7: _load_all

def _load_all():
    import pymor
    ignore_playground = True
    fails = []
    for _, module_name, _ in pkgutil.walk_packages(pymor.__path__, pymor.__name__ + '.',
                                                   lambda n: fails.append((n, ''))):
        if ignore_playground and 'playground' in module_name:
            continue
        try:
            __import__(module_name, level=0)
        except (TypeError, ImportError) as t:
            fails.append((module_name, t))
    if len(fails) > 0:
        logger.getLogger(__name__).fatal('Failed imports: {}'.format(pprint.pformat(fails)))
        raise ImportError(__name__)
开发者ID:BarbaraV,项目名称:pymor,代码行数:15,代码来源:base.py

示例8: load_matrix

def load_matrix(path, key=None):

    logger = getLogger('pymor.tools.io.load_matrix')
    logger.info('Loading matrix from file ' + path)

    path_parts = path.split('.')
    if len(path_parts[-1]) == 3:
        extension = path_parts[-1].lower()
    elif path_parts[-1].lower() == 'gz' and len(path_parts) >= 2 and len(path_parts[-2]) == 3:
        extension = '.'.join(path_parts[-2:]).lower()
    else:
        extension = None

    file_format_map = {'mat': ('MATLAB', _loadmat),
                       'mtx': ('Matrix Market', _mmread),
                       'mtz.gz': ('Matrix Market', _mmread),
                       'npy': ('NPY/NPZ', _load),
                       'npz': ('NPY/NPZ', _load),
                       'txt': ('Text', _loadtxt)}

    if extension in file_format_map:
        file_type, loader = file_format_map[extension]
        logger.info(file_type + ' file detected.')
        return loader(path, key)

    logger.warning('Could not detect file format. Trying all loaders ...')

    loaders = [_loadmat, _mmread, _loadtxt, _load]
    for loader in loaders:
        try:
            return loader(path, key)
        except IOError:
            pass

    raise IOError(f'Could not load file {path} (key = {key})')
开发者ID:pymor,项目名称:pymor,代码行数:35,代码来源:io.py

示例9: __init__

    def __init__(cls, name, bases, namespace):
        '''I copy my class docstring if deriving class has none. I tell base classes when I derive
        a new class from them. I publish a new contract type for each new class I create.
        '''
        doc = namespace.get("__doc__", None)
        if not doc:
            for base in cls.__mro__[1:]:
                if base.__doc__:
                    doc = base.__doc__
                    break
        cls.__doc__ = doc

        # monkey a new contract into the decorator module so checking for that type at runtime can work
        dname = (cls.__module__ + '.' + name).replace('__main__.', 'main.').replace('.', '_')
        if not dname in decorators.__dict__:
            decorators.__dict__[dname] = contracts.new_contract(dname, lambda x: isinstance(x, cls))

        # all bases except object get the derived class' name appended
        for base in [b for b in bases if b != object]:
            derived = cls
            # mangle the name to the base scope
            attribute = '_%s__implementors' % base.__name__
            if hasattr(base, attribute):
                getattr(base, attribute).append(derived)
            else:
                setattr(base, attribute, [derived])
        cls.logger = logger.getLogger('{}.{}'.format(cls.__module__.replace('__main__', 'pymor'), name))
        abc.ABCMeta.__init__(cls, name, bases, namespace)
开发者ID:NikolaiGraeber,项目名称:pyMor,代码行数:28,代码来源:interfaces.py

示例10: add_class

 def add_class(self, cls, wrapped_cls):
     self.wrapped_classes[cls] = wrapped_cls
     if hasattr(cls, 'type_this'):
         try:
             self.wrapped_classes_by_type_this[cls.type_this()] = wrapped_cls
         except TypeError:
             logger = getLogger('dune.pymor.core')
             logger.warn('Could not call type_this on {}. (Not a static method?)'.format(cls.__name__))
开发者ID:ftalbrecht,项目名称:dune-pymor,代码行数:8,代码来源:wrapper.py

示例11: clear

 def clear(self):
     # Try to safely delete all cache entries, even if another process
     # accesses the same region.
     self.bytes_written = 0
     conn = self.conn
     c = conn.cursor()
     c.execute('SELECT id, filename FROM entries ORDER BY id ASC')
     entries = c.fetchall()
     if entries:
         ids_to_delete, files_to_delete = zip(*entries)
         c.execute('DELETE FROM entries WHERE id in ({})'.format(','.join(map(str, ids_to_delete))))
         conn.commit()
         path = self.path
         for filename in files_to_delete:
             try:
                 os.unlink(os.path.join(path, filename))
             except OSError:
                 from pymor.core.logger import getLogger
                 getLogger('pymor.core.cache.SQLiteRegion').warn('Cannot delete cache entry ' + filename)
开发者ID:renemilk,项目名称:pyMor,代码行数:19,代码来源:cache.py

示例12: update

 def update(self, defaults, type='user'):
     assert type in ('user', 'file')
     import pymor.core.interfaces
     if pymor.core.interfaces.ImmutableMeta.sids_created:
         from pymor.core.logger import getLogger
         getLogger('pymor.core.defaults').warn(
             'Changing defaults after calculation of the first state id. '
             + '(see pymor.core.defaults for more information.)')
     for k, v in defaults.iteritems():
         self._data[k][type] = v
         func = self._data[k].get('func', None)
         if func:
             argname = k.split('.')[-1]
             func._defaultsdict[argname] = v
             argspec = inspect.getargspec(func)
             argind = argspec.args.index(argname) - len(argspec.args)
             defaults = list(argspec.defaults)
             defaults[argind] = v
             func.__defaults__ = tuple(defaults)
     self._calc_sid()
开发者ID:andreasbuhr,项目名称:pymor,代码行数:20,代码来源:defaults.py

示例13: colormap_texture

 def colormap_texture(name='viridis'):
     resolution = min(gl.GL_MAX_TEXTURE_SIZE, 1024)
     colormap_id = gl.glGenTextures(1)
     gl.glBindTexture(gl.GL_TEXTURE_1D, colormap_id)
     gl.glTexParameteri(gl.GL_TEXTURE_1D, gl.GL_TEXTURE_MAG_FILTER, gl.GL_NEAREST)
     gl.glTexParameteri(gl.GL_TEXTURE_1D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
     gl.glTexParameteri(gl.GL_TEXTURE_1D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
     colormap = np.empty((resolution, 4), dtype='f4')
     from matplotlib.pyplot import get_cmap
     try:
         cmap = get_cmap(name)
     except ValueError:
         from pymor.core.logger import getLogger
         # this is our default which might not exist for older matplotlib so a warning would be annoying
         if name != 'viridis':
             getLogger('pymor.gui.gl.colormap_texture').warn('Unknown colormap {}, using default colormap'.format(name))
         cmap = get_cmap()
     colormap[:] = cmap(np.linspace(0., 1., resolution))
     gl.glTexImage1D(gl.GL_TEXTURE_1D, 0, gl.GL_RGBA, resolution, 0, gl.GL_RGBA, gl.GL_FLOAT, colormap)
     gl.glBindTexture(gl.GL_TEXTURE_1D, 0)
     return colormap_id
开发者ID:renemilk,项目名称:pyMor,代码行数:21,代码来源:gl.py

示例14: __new__

 def __new__(cls, classname, bases, classdict):
     c = UberMeta.__new__(cls, classname, bases, classdict)
     init_arguments = c._init_arguments
     try:
         for a in c.sid_ignore:
             if a not in init_arguments and a not in ImmutableMeta.init_arguments_never_warn:
                 raise ValueError(a)
     except ValueError as e:
         # The _logger attribute of our new class has not been initialized yet, so create
         # our own logger.
         l = logger.getLogger('{}.{}'.format(c.__module__.replace('__main__', 'pymor'), classname))
         l.warn('sid_ignore contains "{}" which is not an __init__ argument!'.format(e))
     return c
开发者ID:ftalbrecht,项目名称:pymor,代码行数:13,代码来源:interfaces.py

示例15: _import_all

def _import_all(package_name='pymor'):

    package = __import__(package_name)

    if hasattr(package, '__path__'):
        def onerror(name):
            from pymor.core.logger import getLogger
            logger = getLogger('pymor.core.defaults._import_all')
            logger.warn('Failed to import ' + name)

        for p in pkgutil.walk_packages(package.__path__, package_name + '.', onerror=onerror):
            try:
                __import__(p[1])
            except ImportError:
                from pymor.core.logger import getLogger
                logger = getLogger('pymor.core.defaults._import_all')
                logger.warn('Failed to import ' + p[1])
开发者ID:sdrave,项目名称:pymor,代码行数:17,代码来源:defaults.py


注:本文中的pymor.core.logger.getLogger函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。