def config(): with mock.patch("spreads.config.confit.Configuration.read"): cfg = Configuration(appname="spreads_test") cfg["driver"] = u"testdriver" cfg["plugins"] = [u"test_output", u"test_process", u"test_process2"] cfg["capture"]["capture_keys"] = ["b", " "] cfg.load_defaults() yield cfg
def config(): with mock.patch('spreads.config.confit.Configuration.read'): cfg = Configuration(appname='spreads_test') cfg["driver"] = u"testdriver" cfg["plugins"] = [u"test_output", u"test_process", u"test_process2"] cfg["capture"]["capture_keys"] = ["b", " "] cfg.load_defaults() yield cfg
def run(): """ Setup the application and run subcommand""" config = Configuration() parser = setup_parser(config) args = parser.parse_args() config.set_from_args(args) setup_logging(config) args.subcommand(config)
def _load_config(self, value): # Load default configuration config = Configuration() cfg_file = self.path / 'config.yml' if value is None and cfg_file.exists(): # Load workflow-specific configuration from file value = confit.ConfigSource({}, unicode(cfg_file)) if value is not None: # Load configuration from supplied ConfigSource or dictionary config = config.with_overlay(value) return config
def run(): config = Configuration() parser = setup_parser(config) args = parser.parse_args() # Set configuration from parsed arguments config.set_from_args(args) setup_logging(config) # Run subcommand args.subcommand(config)
def run_service_windows(): os.environ['PATH'] += (";" + os.environ['PROGRAMFILES']) config = Configuration() config['core']['loglevel'] = 'debug' if not config['plugins'].get(): config['plugins'] = ['autorotate', 'scantailor', 'tesseract', 'pdfbeads', 'web'] config.load_defaults(overwrite=False) setup_logging(config) from spreadsplug.web import run_windows_service config['web']['mode'] = 'processor' run_windows_service(config)
def main(): # Set to ERROR so we can see errors during plugin loading. logging.basicConfig(loglevel=logging.ERROR) config = Configuration() parser = setup_parser(config) args = parser.parse_args() # Set configuration from parsed arguments config.set_from_args(args) loglevel = config['core']['loglevel'].as_choice({ 'none': logging.NOTSET, 'info': logging.INFO, 'debug': logging.DEBUG, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL, }) # Set up logger logger = logging.getLogger() if logger.handlers: for handler in logger.handlers: logger.removeHandler(handler) stdout_handler = ColourStreamHandler() stdout_handler.setLevel( logging.DEBUG if config['core']['verbose'].get() else logging.WARNING) stdout_handler.setFormatter(logging.Formatter("%(name)s: %(message)s")) logger.addHandler(stdout_handler) logger.addHandler(EventHandler()) if 'logfile' in config.keys(): logfile = Path(config['core']['logfile'].as_filename()) if not logfile.parent.exists(): logfile.parent.mkdir() file_handler = logging.handlers.RotatingFileHandler( filename=unicode(logfile), maxBytes=512 * 1024, backupCount=1) file_handler.setFormatter( logging.Formatter( "%(asctime)s %(message)s [%(name)s] [%(levelname)s]")) file_handler.setLevel(loglevel) logger.addHandler(file_handler) logger.setLevel(logging.DEBUG) args.subcommand(config)
def run_service_windows(): """ Entry point to launch web plugin server on Windows. """ # Needed so that .exe files in Program Files can be launched. os.environ['PATH'] += (";" + os.environ['PROGRAMFILES']) config = Configuration() config['core']['loglevel'] = 'debug' if not config['plugins'].get(): config['plugins'] = ['autorotate', 'scantailor', 'tesseract', 'pdfbeads', 'web'] config.load_defaults(overwrite=False) setup_logging(config) from spreadsplug.web import run_windows_service config['web']['mode'] = 'processor' run_windows_service(config)
def run_service_windows(): """ Entry point to launch web plugin server on Windows. """ # Needed so that .exe files in Program Files can be launched. os.environ['PATH'] += (";" + os.environ['PROGRAMFILES']) config = Configuration() config['core']['loglevel'] = 'debug' if not config['plugins'].get(): config['plugins'] = [ 'autorotate', 'scantailor', 'tesseract', 'pdfbeads', 'web' ] config.load_defaults(overwrite=False) setup_logging(config) from spreadsplug.web import run_windows_service config['web']['mode'] = 'processor' run_windows_service(config)
def config(): with mock.patch('spreads.config.confit.LazyConfig.read'): cfg = Configuration(appname='spreads_test') cfg["driver"] = u"testdriver" cfg["plugins"] = [u"test_output", u"test_process", u"test_process2"] cfg["capture"]["capture_keys"] = ["b", " "] return cfg
def run_service_windows(): os.environ['PATH'] += (";" + os.environ['PROGRAMFILES']) logging.basicConfig(loglevel=logging.ERROR) logger = logging.getLogger() config = Configuration() logger.addHandler(EventHandler()) from spreadsplug.web import run_windows_service run_windows_service(config)
def run_config_windows(): """ Entry point to launch graphical configuration dialog on Windows. """ # Needed so that .exe files in Program Files can be launched. os.environ['PATH'] += (";" + os.environ['PROGRAMFILES']) config = Configuration() setup_logging(config) from spreads.tkconfigure import configure configure(config)
def run_config_windows(): os.environ['PATH'] += (";" + os.environ['PROGRAMFILES']) logging.basicConfig(loglevel=logging.ERROR) logger = logging.getLogger() config = Configuration() logger.addHandler(EventHandler()) from spreads.tkconfigure import configure configure(config)
def main(): # Set to ERROR so we can see errors during plugin loading. logging.basicConfig(loglevel=logging.ERROR) config = Configuration() parser = setup_parser(config) args = parser.parse_args() # Set configuration from parsed arguments config.set_from_args(args) loglevel = config['core']['loglevel'].as_choice({ 'none': logging.NOTSET, 'info': logging.INFO, 'debug': logging.DEBUG, 'warning': logging.WARNING, 'error': logging.ERROR, 'critical': logging.CRITICAL, }) # Set up logger logger = logging.getLogger() if logger.handlers: for handler in logger.handlers: logger.removeHandler(handler) stdout_handler = ColourStreamHandler() stdout_handler.setLevel(logging.DEBUG if config['core']['verbose'].get() else logging.WARNING) stdout_handler.setFormatter(logging.Formatter("%(name)s: %(message)s")) logger.addHandler(stdout_handler) logger.addHandler(EventHandler()) if 'logfile' in config.keys(): logfile = Path(config['core']['logfile'].as_filename()) if not logfile.parent.exists(): logfile.parent.mkdir() file_handler = logging.handlers.RotatingFileHandler( filename=unicode(logfile), maxBytes=512*1024, backupCount=1) file_handler.setFormatter(logging.Formatter( "%(asctime)s %(message)s [%(name)s] [%(levelname)s]")) file_handler.setLevel(loglevel) logger.addHandler(file_handler) logger.setLevel(logging.DEBUG) args.subcommand(config)
def _load_config(self, value): """ Load configuartion from file in bag and optionally overlay it with new values. :param value: Values to overlay over over loaded configuration :type value: dict or :py:class:`confit.ConfigView` :returns: Loaded (and overlaid) configuration :rtype: :py:class:`confit.Configuration` """ # Load default configuration config = Configuration() cfg_file = self.path / 'config.yml' if value is None and cfg_file.exists(): # Load workflow-specific configuration from file value = confit.ConfigSource(confit.load_yaml(unicode(cfg_file)), unicode(cfg_file)) if value is not None: # Load configuration from supplied ConfigSource or dictionary config = config.with_overlay(value) return config