本文整理汇总了Python中echomesh.util.Log类的典型用法代码示例。如果您正苦于以下问题:Python Log类的具体用法?Python Log怎么用?Python Log使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Log类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save
def save(self):
saved_files = []
for f, settings in self.file_settings:
if len(settings) > 2 and settings[2]:
saved_files.append(f)
settings[1] = Merge.merge(*settings[1:])
while len(settings) > 2:
settings.pop()
if os.path.exists(f):
with open(f, 'r') as fo:
data = fo.read().split(Yaml.SEPARATOR)[0]
else:
data = ''
parent = os.path.dirname(f)
if not os.path.exists(parent):
from echomesh.util import Log
Log.logger(__name__).info('Creating directory %s.', parent)
os.makedirs(parent)
with open(f, 'wb') as fw:
if data:
fw.write(data)
fw.write(Yaml.SEPARATOR)
fw.write(Yaml.encode_one(settings[1]))
self.arg_settings = Merge.difference_strict(
self.arg_settings, self.changed)
self.recalculate()
return saved_files
示例2: main
def main():
import sys
times = []
def p(msg=''):
"""Print progress messages while echomesh loads."""
print(msg, end='\n' if msg else '')
global COUNT
dot = str(COUNT % 10) if USE_DIGITS_FOR_PROGRESS_BAR else '.'
print(dot, end='')
COUNT += 1
sys.stdout.flush()
import time
times.append(time.time())
p('Loading echomesh ')
from echomesh.base import Path
p()
Path.fix_sys_path()
p()
from echomesh.base import Args
p()
Args.set_arguments(sys.argv)
p()
from echomesh.base import Config
p()
Config.recalculate()
p()
if Config.get('autostart') and not Config.get('permission', 'autostart'):
print()
from echomesh.util import Log
Log.logger(__name__).info("Not autostarting because autostart=False")
exit(0)
p()
from echomesh import Instance
print()
if Config.get('diagnostics', 'startup_times'):
print()
for i in range(len(times) - 1):
print(i, ':', int(1000 * (times[i + 1] - times[i])))
print()
Instance.main()
if Config.get('diagnostics', 'unused_configs'):
import yaml
print(yaml.safe_dump(Config.get_unvisited()))
示例3: _load_library
def _load_library(name):
"""Try to load a shared library, report an error on failure."""
try:
import ctypes
return ctypes.CDLL('lib%s.so' % name)
except:
from echomesh.util import Log
Log.logger(__name__).error("Couldn't load library %s" % name)
示例4: _help
from __future__ import absolute_import, division, print_function, unicode_literals
from echomesh.command import Registry
from echomesh.command import Show
from echomesh.util import Log
LOGGER = Log.logger(__name__)
HELP = """
echomesh has the following help topics:
%s
Type "help TOPIC" for more information - for example, "help quit" or "help run".
"""
def _help(_, *parts):
if not parts:
LOGGER.info(HELP, Registry.registry().join_keys(command_only=False))
else:
cmd, parts = parts[0], parts[1:]
if not parts:
help_text = Registry.registry().get_help(cmd)
LOGGER.info(help_text or ('No help text available for "%s"' % cmd))
elif cmd == 'show':
sub = parts[0]
help_text = Show.SHOW_REGISTRY.get_help(sub)
LOGGER.info('\nshow %s:', sub)
LOGGER.info(help_text or
('No help text available for "show %s"' % sub))
示例5: _main
def _main():
import sys
times = []
def p(msg=''):
"""Print progress messages while echomesh loads."""
print(msg, end='\n' if msg else '')
global COUNT
dot = str(COUNT % 10) if USE_DIGITS_FOR_PROGRESS_BAR else '.'
print(dot, end='')
COUNT += 1
sys.stdout.flush()
import time
times.append(time.time())
p('Loading echomesh ')
from echomesh.base import Version
if Version.TOO_NEW:
print(Version.ERROR)
from echomesh.base import Path
if not Path.project_path():
return
p()
Path.fix_home_directory_environment_variable()
p()
Path.fix_sys_path()
p()
from echomesh.base import Settings
p()
Settings.read_settings(sys.argv[1:])
p()
if Settings.get('execution', 'autostart') and not Settings.get(
'permission', 'autostart'):
print()
from echomesh.util import Log
Log.logger(__name__).info('No permission to autostart')
return
p()
from echomesh.base import Quit
p()
Quit.register_atexit(Settings.save)
p()
from echomesh.Instance import Instance
p()
instance = Instance()
print()
p()
if Settings.get('diagnostics', 'startup_times'):
print()
for i in range(len(times) - 1):
print(i, ':', int(1000 * (times[i + 1] - times[i])))
print()
instance.main()