コード例 #1
0
ファイル: helpers.py プロジェクト: eurodude/PyCIRCLean
    def __init__(self, root_src, root_dst, debug=False):
        """Initialized with path to source and dest directories."""
        self.src_root_dir = root_src
        self.dst_root_dir = root_dst
        self.log_root_dir = os.path.join(self.dst_root_dir, 'logs')
        self._safe_rmtree(self.log_root_dir)
        self._safe_mkdir(self.log_root_dir)
        self.log_processing = os.path.join(self.log_root_dir, 'processing.log')
        self.log_content = os.path.join(self.log_root_dir, 'content.log')
        self.tree(self.src_root_dir)

        quick_setup(file=self.log_processing)
        self.log_name = log.name('files')
        self.resources_path = os.path.join(
            os.path.abspath(os.path.dirname(__file__)), 'data')
        os.environ["PATH"] += os.pathsep + self.resources_path

        self.cur_file = None

        self.debug = debug
        if self.debug:
            self.log_debug_err = os.path.join(self.log_root_dir,
                                              'debug_stderr.log')
            self.log_debug_out = os.path.join(self.log_root_dir,
                                              'debug_stdout.log')
        else:
            self.log_debug_err = os.devnull
            self.log_debug_out = os.devnull
コード例 #2
0
ファイル: helpers.py プロジェクト: lcpdn/PyCIRCLean
    def __init__(self, root_src, root_dst, debug=False):
        '''
            Setup the base options of the copy/convert setup
        '''
        self.src_root_dir = root_src
        self.dst_root_dir = root_dst
        self.log_root_dir = os.path.join(self.dst_root_dir, 'logs')
        self._safe_rmtree(self.log_root_dir)
        self._safe_mkdir(self.log_root_dir)
        self.log_processing = os.path.join(self.log_root_dir, 'processing.log')

        quick_setup(file=self.log_processing)
        self.log_name = log.name('files')
        self.ressources_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'data')
        os.environ["PATH"] += os.pathsep + self.ressources_path

        self.cur_file = None

        self.debug = debug
        if self.debug:
            self.log_debug_err = os.path.join(self.log_root_dir, 'debug_stderr.log')
            self.log_debug_out = os.path.join(self.log_root_dir, 'debug_stdout.log')
        else:
            self.log_debug_err = os.devnull
            self.log_debug_out = os.devnull
コード例 #3
0
ファイル: test_globals.py プロジェクト: svetlyak40wt/twiggy
 def test_quick_setup_stdout(self):
     twiggy.quick_setup(file=sys.stdout)
     assert len(twiggy.emitters) == 1
     e = twiggy.emitters['*']
     assert isinstance(e, twiggy.filters.Emitter)
     assert isinstance(e._output, twiggy.outputs.StreamOutput)
     assert e._output.stream is sys.stdout
コード例 #4
0
 def test_quick_setup_stdout(self):
     twiggy.quick_setup(file=sys.stdout)
     assert len(twiggy.emitters) == 1
     e = twiggy.emitters['*']
     assert isinstance(e, twiggy.filters.Emitter)
     assert isinstance(e._output, twiggy.outputs.StreamOutput)
     assert e._output.stream is sys.stdout
コード例 #5
0
def main():

    quick_setup()
    lines = open(filename, "r").readlines()
    cases = int(lines[0].strip())
    lg = l.name("main")
    lg.fields(cases=cases).info("init")
    getData(cases, lines[1:])
コード例 #6
0
def main():
    global DATA

    quick_setup()
    lines=open(filename, "r").readlines()
    cases=int(lines[0].strip())
    for g in range(cases): DATA.append(lines[g+1].strip())
    lg=l.name("main")
    lg.fields(cases=cases).info("init")
    getData(cases)
コード例 #7
0
def test_quick_setup_file(tmp_dir):
    print(tmp_dir)

    logfile = os.path.join(tmp_dir, 'log')
    twiggy.quick_setup(file=logfile)

    assert len(twiggy.emitters) == 1
    e = twiggy.emitters['*']
    assert isinstance(e, twiggy.filters.Emitter)
    assert isinstance(e._output, twiggy.outputs.FileOutput)
    assert os.path.exists(logfile)
コード例 #8
0
ファイル: test_globals.py プロジェクト: wearpants/twiggy
def test_quick_setup_file(tmp_dir):
    print(tmp_dir)

    logfile = os.path.join(tmp_dir, 'log')
    twiggy.quick_setup(file=logfile)

    assert len(twiggy.emitters) == 1
    e = twiggy.emitters['*']
    assert isinstance(e, twiggy.filters.Emitter)
    assert isinstance(e._output, twiggy.outputs.FileOutput)
    assert os.path.exists(logfile)
コード例 #9
0
ファイル: test_globals.py プロジェクト: svetlyak40wt/twiggy
    def test_quick_setup_file(self):

        fname = tempfile.mktemp()
        print fname
        
        @self.addCleanup      
        def cleanup():
            os.remove(fname)

        twiggy.quick_setup(file=fname)
        assert len(twiggy.emitters) == 1
        e = twiggy.emitters['*']
        assert isinstance(e, twiggy.filters.Emitter)
        assert isinstance(e._output, twiggy.outputs.FileOutput)
        assert os.path.exists(fname)
コード例 #10
0
    def test_quick_setup_file(self):

        fname = tempfile.mktemp()
        print fname

        @self.addCleanup
        def cleanup():
            os.remove(fname)

        twiggy.quick_setup(file=fname)
        assert len(twiggy.emitters) == 1
        e = twiggy.emitters['*']
        assert isinstance(e, twiggy.filters.Emitter)
        assert isinstance(e._output, twiggy.outputs.FileOutput)
        assert os.path.exists(fname)
コード例 #11
0
ファイル: logging.py プロジェクト: dmsimard/antsibull
def initialize_app_logging():
    """
    Change log settings to make sense for an application.

    Merely importing the :mod:`antsibull.logging` module sets up the logger for use as part of
    a library.  Calling this function will initialize the logger for use in an application.
    """
    # We want to see logs from the antsibull library, so the very first thing we do is turn the log
    # level up to DEBUG.  That way individual emitters will be able to control the log level.
    log.min_level = twiggy.levels.DEBUG

    # Temporarily setup logging with defaults until we can get configuration from the user.
    _level = twiggy.levels.WARNING
    if os.environ.get('ANTSIBULL_EARLY_DEBUG', False):
        _level = twiggy.levels.DEBUG
    twiggy.quick_setup(min_level=_level)
コード例 #12
0
 def __init__(self, root_dir_path, debug=False):
     self.root_dir = root_dir_path
     self.log_dir_path = os.path.join(root_dir_path, 'logs')
     if os.path.exists(self.log_dir_path):
         shutil.rmtree(self.log_dir_path)
     os.makedirs(self.log_dir_path)
     self.log_processing = os.path.join(self.log_dir_path, 'processing.log')
     self.log_content = os.path.join(self.log_dir_path, 'content.log')
     twiggy.quick_setup(file=self.log_processing)
     self.log = twiggy.log.name('files')
     if debug:
         self.log_debug_err = os.path.join(self.log_dir_path,
                                           'debug_stderr.log')
         self.log_debug_out = os.path.join(self.log_dir_path,
                                           'debug_stdout.log')
     else:
         self.log_debug_err = os.devnull
         self.log_debug_out = os.devnull
コード例 #13
0
        flog.debug('Enter')

        self._x = initialize_x()
        self._y = initialize_y()

        self.position = self.calculate_position(self._x, self._y)

        flog.debug('Leave')

For information on which level you should log a message at, or more general information about
logging, see the :mod:`antsibull.logging` module documentation.
"""

import os

import twiggy
import twiggy.levels

# We want to see logs from the antsibull library, so the very first thing we do is
# turn the log level up to DEBUG.  That way individual emitters will be able to control the log
# level.
from .logging import log

log.min_level = twiggy.levels.DEBUG

# Temporarily setup logging with defaults until we can get real configuration.
_level = twiggy.levels.WARNING
if os.environ.get('ANTSIBULL_EARLY_DEBUG', False):
    _level = twiggy.levels.DEBUG
twiggy.quick_setup(min_level=_level)
コード例 #14
0
ファイル: logging.py プロジェクト: abadger/stellarmagnate
# Copyright (C) 2019 Toshio Kuratomi <*****@*****.**>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
"""
:mod:`logging` holds a twiggy Logger object which controls logging for the application
"""

import twiggy

# Temporarily setup twiggy logging with defaults until we can get real configuration.
twiggy.quick_setup()

#: The magnate log.  For the stellar magnate client, the name of the logger is #:
#: `stellarmagnate.magnate`.  For those used to the idiom of using the module's __name__ field as
#: the name, the module name is in the `mod` field.
log = twiggy.log.name('stellarmagnate.magnate')

mlog = log.fields(mod=__name__)
mlog.debug('logging loaded')
コード例 #15
0
ファイル: __init__.py プロジェクト: ScorpJD/QMCTorch
# -*- coding: utf-8 -*-
"""Documentation about QMCTorch"""

from .__version__ import __version__

__author__ = "Nicolas Renaud"
__email__ = '*****@*****.**'

import twiggy
import sys
twiggy.quick_setup(file=sys.stdout)
log = twiggy.log.name('QMCTorch')
log.min_level = twiggy.levels.INFO

log.info(r"  ____    __  ______________             _")
log.info(r" / __ \  /  |/  / ___/_  __/__  ________/ /  ")
log.info(r"/ /_/ / / /|_/ / /__  / / / _ \/ __/ __/ _ \ ")
log.info(r"\___\_\/_/  /_/\___/ /_/  \___/_/  \__/_//_/ ")
コード例 #16
0
ファイル: logger.py プロジェクト: Esiravegna/domus
import twiggy
twiggy.quick_setup()
master_log = twiggy.log