def kfc(ctx, home, log_level, name): if not home: osname = platform.system() user_home = os.path.expanduser('~') if osname == 'Linux': xdg_config_home = os.getenv('XDG_CONFIG_HOME') home = xdg_config_home if xdg_config_home else os.path.join( user_home, '.config') if osname == 'Darwin': home = os.path.join(user_home, 'Library', 'Application Support') if osname == 'Windows': home = os.getenv('APPDATA') home = os.path.join(home, 'kungfu', 'app') os.environ['KF_HOME'] = ctx.home = home os.environ['KF_LOG_LEVEL'] = ctx.log_level = log_level # have to keep locator alive from python side # https://github.com/pybind/pybind11/issues/1546 ctx.locator = kfj.Locator(home) ctx.system_config_location = pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM, 'etc', 'kungfu', ctx.locator) if ctx.invoked_subcommand is None: click.echo(kfc.get_help(ctx)) else: ctx.name = name if name else ctx.invoked_subcommand pass
def kfc(ctx, home, log_level, name): os.environ['KF_HOME'] = ctx.home = home os.environ['KF_LOG_LEVEL'] = ctx.log_level = log_level # have to keep locator alive from python side # https://github.com/pybind/pybind11/issues/1546 ctx.locator = kfj.Locator(home) if ctx.invoked_subcommand is None: click.echo(kfc.get_help(ctx)) else: ctx.name = name if name else ctx.invoked_subcommand pass
def kfc(ctx, home, log_level, name): os.environ['KF_HOME'] = ctx.home = home os.environ['KF_LOG_LEVEL'] = ctx.log_level = log_level # have to keep locator alive from python side # https://github.com/pybind/pybind11/issues/1546 ctx.locator = kfj.Locator(home) ctx.system_config_location = pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM, 'etc', 'kungfu', ctx.locator) if ctx.invoked_subcommand is None: click.echo(kfc.get_help(ctx)) else: ctx.name = name if name else ctx.invoked_subcommand pass
def kfc(ctx, home, log_level, name): if not home: osname = platform.system() user_home = os.path.expanduser('~') if osname == 'Linux': xdg_config_home = os.getenv('XDG_CONFIG_HOME') home = xdg_config_home if xdg_config_home else os.path.join( user_home, '.config') if osname == 'Darwin': home = os.path.join(user_home, 'Library', 'Application Support') if osname == 'Windows': home = os.getenv('APPDATA') home = os.path.join(home, 'kungfu', 'app') os.environ['KF_HOME'] = ctx.home = home os.environ['KF_LOG_LEVEL'] = ctx.log_level = log_level bundle_dir = get_bundle_dir() package_path = os.path.join(bundle_dir, "site-packages") sys.path.append(package_path) settings_path = os.path.join(home, 'settings.json') if not os.path.exists(settings_path): default_settings_file = open(settings_path, 'w+') default_settings_file.write('{}') default_settings_file.close() with open(settings_path) as settings_file: ctx.settings = json.load(settings_file) settings_file.close() # have to keep locator alive from python side # https://github.com/pybind/pybind11/issues/1546 ctx.locator = kfj.Locator(home) ctx.system_config_location = pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM, 'etc', 'kungfu', ctx.locator) ctx.bundle_dir = bundle_dir ctx.package_path = package_path if ctx.invoked_subcommand is None: click.echo(kfc.get_help(ctx)) else: ctx.name = name if name else ctx.invoked_subcommand pass
def test(ctx, home, log_level): if not home: osname = platform.system() user_home = os.path.expanduser('~') if osname == 'Linux': xdg_config_home = os.getenv('XDG_CONFIG_HOME') home = xdg_config_home if xdg_config_home else os.path.join( user_home, '.config') if osname == 'Darwin': home = os.path.join(user_home, 'Library', 'Application Support') if osname == 'Windows': home = os.getenv('APPDATA') home = os.path.join(home, 'kungfu', 'app') os.environ['KF_HOME'] = ctx.home = home os.environ['KF_LOG_LEVEL'] = ctx.log_level = log_level ctx.locator = kfj.Locator(home) if ctx.invoked_subcommand is None: click.echo(test.get_help(ctx)) pass
import sys import traceback import pkgutil import pyyjj import kungfu.yijinjing.journal as kfj from kungfu.yijinjing.log import create_logger kf_home = os.getenv('KF_HOME') kfext_log_level = os.getenv('KF_LOG_LEVEL') if not kfext_log_level: kfext_log_level = 'error' kfext_logger = None if kf_home: kfext_log_locator = kfj.Locator(kf_home) kfext_log_location = pyyjj.location(pyyjj.mode.LIVE, pyyjj.category.SYSTEM, 'extensions', 'extensions', kfext_log_locator) kfext_logger = create_logger('extensions', kfext_log_level, kfext_log_location) else: kfext_logger = create_logger('extensions', kfext_log_level, None) class ExtensionRegistry: def __init__(self, ext_type): self._registry = {} self.ext_type = ext_type def register_extension(self, name, extension):