diff --git a/flamenco_worker/cli.py b/flamenco_worker/cli.py index d86f77349be7ba1ba937e2f72dadbdc74023e1d6..85ebef54b8da463cab6074db520a9a5cccf8e628 100644 --- a/flamenco_worker/cli.py +++ b/flamenco_worker/cli.py @@ -27,6 +27,10 @@ def main(): help="Enables debug logging for Flamenco Worker's own log entries. " "Edit the logging config in flamenco-worker.cfg " "for more powerful options.") + parser.add_argument('-t', '--test', action='store_true', + help="Starts up in testing mode, in which only a handful of " + "test-specific task types are accepted. This overrides the task_types " + "in the configuration file.") args = parser.parse_args() if args.version: @@ -36,12 +40,16 @@ def main(): # Load configuration from . import config - confparser = config.load_config(args.config, args.verbose) + confparser = config.load_config(args.config, args.verbose, args.test) config.configure_logging(confparser, enable_debug=args.debug) log = logging.getLogger(__name__) log.debug('Starting, pid=%d', os.getpid()) + if args.test: + log.warning('Test mode enabled, overriding task_types=%r', + confparser.value('task_types')) + if args.reregister: log.warning('Erasing worker_id and worker_secret so we can attempt re-registration.') confparser.erase('worker_id') diff --git a/flamenco_worker/config.py b/flamenco_worker/config.py index bb809f560d3f449a58b29726af8d8ced7418fa80..0638771166d0b9381fd8007f5d2f8c4d3b393423 100644 --- a/flamenco_worker/config.py +++ b/flamenco_worker/config.py @@ -28,6 +28,9 @@ DEFAULT_CONFIG = { ]) } +# Will be assigned to the config key 'task_types' when started with --test CLI arg. +TESTING_TASK_TYPES = 'test-blender-render' + log = logging.getLogger(__name__) @@ -74,7 +77,8 @@ def merge_with_home_config(new_conf: dict): def load_config(config_file: pathlib.Path = None, - show_effective_config: bool = False) -> ConfigParser: + show_effective_config: bool = False, + enable_test_mode=False) -> ConfigParser: """Loads one or more configuration files.""" # Logging and the default interpolation of configparser both use the @@ -102,6 +106,9 @@ def load_config(config_file: pathlib.Path = None, log.info('Succesfully loaded: %s', loaded) + if enable_test_mode: + confparser.setvalue('task_types', TESTING_TASK_TYPES) + if show_effective_config: import sys log.info('Effective configuration:')