def main(): """Main function.""" parser = argparse.ArgumentParser() parser.add_argument("path", type=str, help="Path to telemetry data.", nargs="+") parser.add_argument("-l", "--limit", type=int, help="Limit the number of files examined.") parser.add_argument("-p", "--profile", action='store_true', help="Use a profiler.") parser.add_argument("-v", "--verbose", action='store_true', help="Be verbose.") parser.add_argument("-q", "--quiet", action='store_true', help="Be verbose.") parser.add_argument("-f", "--force", action="store_true", help="Force write new files.") opt = parser.parse_args() if opt.quiet: opt.verbose = False if opt.profile: pr = cProfile.Profile() pr.enable() if opt.verbose: lumberjack.setup_logging(mode='stream', level=1) else: lumberjack.setup_logging(mode='stream', level=logging.INFO) upgrade(opt.path, os.getcwd(), quiet=opt.quiet, verbose=opt.verbose, force=opt.force, limit=opt.limit) if opt.profile: pr.disable() sortby = 'cumulative' ps = pstats.Stats(pr).sort_stats(sortby) ps.print_stats()
def _setup_logging(verbose): """Try to use lumberjack to enable logging when in a subprocess.""" try: import lumberjack lumberjack.setup_logging("DFW.Broker", mode="stream", level=30 - 10 * verbose) lumberjack.setup_warnings_logger("DFW.Broker") except: pass
def pytest_configure(config): """Activate log capturing if appropriate.""" if (not _pytest_get_option(config, 'capturelog', default=True)) or (_pytest_get_option(config, 'capture', default="no") == "no"): try: import lumberjack lumberjack.setup_logging("", mode='stream', level=1) lumberjack.setup_warnings_logger("") except: pass else: try: import lumberjack lumberjack.setup_logging("", mode='none', level=1) lumberjack.setup_warnings_logger("") except: pass
def pytest_configure(config): """Activate log capturing if appropriate.""" if (not _pytest_get_option(config, 'capturelog', default=True)) or ( _pytest_get_option(config, 'capture', default="no") == "no"): try: import lumberjack lumberjack.setup_logging("", mode='stream', level=1) lumberjack.setup_warnings_logger("") except: pass else: try: import lumberjack lumberjack.setup_logging("", mode='none', level=1) lumberjack.setup_warnings_logger("") except: pass
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Demonstrate REDIS read-write ability. """ import time from lumberjack import setup_logging, setup_warnings_logger from logging import getLogger setup_logging(mode='stream', level=5) setup_warnings_logger("") log = getLogger("example.zmq") # Get ready! from Cauldron.api import use use("zmq") from Cauldron import DFW def setup(service): """Setup the service.""" kwd = DFW.Keyword.Keyword("TEST", service) print("Service setup") disp = DFW.Service("testsvc", setup=setup, config=None) dtest = disp["TEST"] log.info("Dispatcher Keyword {0!r}".format(dtest)) VALUE = "SOMEVALUE"
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Demonstrate REDIS read-write ability. """ import time from lumberjack import setup_logging setup_logging(mode='stream') from logging import getLogger from Cauldron.conftest import clear_registry log = getLogger("example.redis") # Start up! from Cauldron.redis.common import configure_pool, REDIS_SERVICES_REGISTRY configure_pool(host='localhost', port=6379, db=0) clear_registry() # Get ready! from Cauldron.api import use use("redis") from Cauldron import DFW disp = DFW.Service("testsvc", config=None) dtest = disp["TEST"] log.info(dtest) from Cauldron import ktl svc = ktl.Service("testsvc") test = svc["TEST"] log.info("Writing") test.write("SOMEVALUE") log.info(test.read())
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Demonstrate REDIS read-write ability. """ import time from lumberjack import setup_logging, setup_warnings_logger from logging import getLogger setup_logging(mode='stream', level=5) setup_warnings_logger("") log = getLogger("example.zmq") # Get ready! from Cauldron.api import use use("zmq") from Cauldron import DFW def setup(service): """Setup the service.""" kwd = DFW.Keyword.Keyword("TEST", service) print("Service setup") disp = DFW.Service("testsvc", setup = setup, config=None) dtest = disp["TEST"] log.info("Dispatcher Keyword {0!r}".format(dtest)) VALUE = "SOMEVALUE" time.sleep(1.0) log.info("Starting KTL client...")
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Demonstrate REDIS read-write ability. """ import time from lumberjack import setup_logging, setup_warnings_logger from logging import getLogger setup_logging(mode="stream", level=10) setup_warnings_logger("") log = getLogger("example.zmq") # Get ready! from Cauldron.api import use use("zmq") from Cauldron import DFW disp = DFW.Service("testsvc", config=None) dtest = disp["TEST"] log.info(dtest) VALUE = "SOMEVALUE" from Cauldron import ktl svc = ktl.Service("testsvc", populate=True) log.info(svc) log.info(svc.populated())