Exemple #1
0
	def main():
		configFactory = createConfigFactory(configFile = args[0], additional = [OptsConfigFiller(parser)])
		config = configFactory.getConfig()
		logging_setup(config.changeView(setSections = ['logging']))

		# Check work dir validity (default work directory is the config file name)
		if not os.path.exists(config.getWorkPath()):
			if not config.getState('init'):
				utils.vprint('Will force initialization of %s if continued!' % config.getWorkPath(), -1)
				config.setState(True, 'init')
			if config.getChoiceYesNo('workdir create', True,
					interactive = 'Do you want to create the working directory %s?' % config.getWorkPath()):
				utils.ensureDirExists(config.getWorkPath(), 'work directory')

		# Create workflow and freeze config settings
		globalConfig = config.changeView(setSections = ['global'])
		workflow = globalConfig.getPlugin('workflow', 'Workflow:global', cls = Workflow).getInstance()
		configFactory.freezeConfig(writeConfig = config.getState('init', detail = 'config'))

		# Give config help
		if opts.help_cfg or opts.help_scfg:
			config.write(sys.stdout, printDefault = opts.help_cfg, printUnused = False,
				printMinimal = opts.help_scfg, printSource = opts.help_cfg)
			sys.exit(os.EX_OK)

		# Check if user requested deletion / reset of jobs
		if opts.delete:
			workflow.jobManager.delete(workflow.wms, opts.delete)
			sys.exit(os.EX_OK)
		if opts.reset:
			workflow.jobManager.reset(workflow.wms, opts.reset)
			sys.exit(os.EX_OK)
		# Run the configured workflow
		workflow.run()
Exemple #2
0
def gc_create_workflow(config):
    # set up signal handler for interrupts and debug session requests
    signal.signal(signal.SIGURG, handle_debug_interrupt)
    signal.signal(signal.SIGINT, handle_abort_interrupt)

    # Configure logging settings
    logging_setup(config.changeView(setSections=['logging']))

    global_config = config.changeView(setSections=['global'])
    # Check work dir validity (default work directory is the config file name)
    if not os.path.exists(global_config.getWorkPath()):
        if not global_config.getState('init'):
            logging.getLogger('user').warning('Starting initialization of %s!',
                                              global_config.getWorkPath())
            global_config.setState(True, 'init')
        if global_config.getChoiceYesNo(
                'workdir create',
                True,
                interactive_msg=
                'Do you want to create the working directory %s?' %
                global_config.getWorkPath()):
            utils.ensureDirExists(global_config.getWorkPath(),
                                  'work directory')
    for package_paths in global_config.getPaths('package paths', []):
        init_hpf_plugins(package_paths)

    # Query config settings before config is frozen
    help_cfg = global_config.getState('display', detail='config')
    help_scfg = global_config.getState('display', detail='minimal config')

    action_config = config.changeView(setSections=['action'])
    action_delete = action_config.get('delete', '', onChange=None)
    action_reset = action_config.get('reset', '', onChange=None)

    # Create workflow and freeze config settings
    workflow = global_config.getPlugin('workflow',
                                       'Workflow:global',
                                       cls='Workflow')
    config.factory.freezeConfig(
        writeConfig=config.getState('init', detail='config'))

    # Give config help
    if help_cfg or help_scfg:
        config.write(sys.stdout,
                     printDefault=help_cfg,
                     printUnused=False,
                     printMinimal=help_scfg,
                     printSource=help_cfg)
        sys.exit(os.EX_OK)

    # Check if user requested deletion / reset of jobs
    if action_delete:
        workflow.jobManager.delete(workflow.wms, action_delete)
        sys.exit(os.EX_OK)
    if action_reset:
        workflow.jobManager.reset(workflow.wms, action_reset)
        sys.exit(os.EX_OK)

    return workflow
def _gc_create_workflow(config, do_freeze=True, **kwargs):
    # create workflow from config and do initial processing steps
    # set up signal handler for interrupts and debug session or stack dump requests
    signal.signal(signal.SIGURG, handle_debug_interrupt)
    signal.signal(signal.SIGINT, handle_abort_interrupt)
    start_daemon('debug watchdog', _debug_watchdog)

    # Configure logging settings
    logging_setup(config.change_view(set_sections=['logging']))

    global_config = config.change_view(set_sections=['global'])
    _setup_work_path(global_config)
    for package_paths in global_config.get_dn_list('package paths', [],
                                                   on_change=None):
        init_hpf_plugins(package_paths)

    # Query config settings before config is frozen
    help_cfg = global_config.get_state('display', detail='config')
    help_scfg = global_config.get_state('display', detail='minimal config')

    action_config = config.change_view(set_sections=['action'])
    action_cancel = action_config.get(['delete', 'cancel'], '', on_change=None)
    action_reset = action_config.get('reset', '', on_change=None)

    # Create workflow and freeze config settings
    workflow = global_config.get_plugin('workflow',
                                        'Workflow:global',
                                        cls='Workflow',
                                        pkwargs=kwargs)
    gui = config.get_plugin('gui',
                            'BasicConsoleGUI',
                            cls=GUI,
                            on_change=None,
                            pargs=(workflow, ))
    if do_freeze:
        config.factory.freeze(
            write_config=config.get_state('init', detail='config'))

    # Give config help
    if help_cfg or help_scfg:
        config.write(sys.stdout,
                     print_default=help_cfg,
                     print_unused=False,
                     print_minimal=help_scfg,
                     print_source=help_cfg)
        sys.exit(os.EX_OK)

    # Check if user requested deletion / reset of jobs
    if action_cancel:
        workflow.job_manager.cancel(workflow.task, workflow.backend,
                                    action_cancel)
        sys.exit(os.EX_OK)
    if action_reset:
        workflow.job_manager.reset(workflow.task, workflow.backend,
                                   action_reset)
        sys.exit(os.EX_OK)

    return (workflow, gui)
Exemple #4
0
def gc_create_workflow(config):
	# set up signal handler for interrupts and debug session requests
	signal.signal(signal.SIGURG, handle_debug_interrupt)
	signal.signal(signal.SIGINT, handle_abort_interrupt)

	# Configure logging settings
	logging_setup(config.changeView(setSections = ['logging']))

	global_config = config.changeView(setSections = ['global'])
	# Check work dir validity (default work directory is the config file name)
	if not os.path.exists(global_config.getWorkPath()):
		if not global_config.getState('init'):
			logging.getLogger('user').warning('Starting initialization of %s!', global_config.getWorkPath())
			global_config.setState(True, 'init')
		if global_config.getChoiceYesNo('workdir create', True,
				interactive_msg = 'Do you want to create the working directory %s?' % global_config.getWorkPath()):
			utils.ensureDirExists(global_config.getWorkPath(), 'work directory')
	for package_paths in global_config.getPaths('package paths', []):
		init_hpf_plugins(package_paths)

	# Query config settings before config is frozen
	help_cfg = global_config.getState('display', detail = 'config')
	help_scfg = global_config.getState('display', detail = 'minimal config')

	action_config = config.changeView(setSections = ['action'])
	action_delete = action_config.get('delete', '', onChange = None)
	action_reset = action_config.get('reset', '', onChange = None)

	# Create workflow and freeze config settings
	workflow = global_config.getPlugin('workflow', 'Workflow:global', cls = 'Workflow')
	config.factory.freezeConfig(writeConfig = config.getState('init', detail = 'config'))

	# Give config help
	if help_cfg or help_scfg:
		config.write(sys.stdout, printDefault = help_cfg, printUnused = False,
			printMinimal = help_scfg, printSource = help_cfg)
		sys.exit(os.EX_OK)

	# Check if user requested deletion / reset of jobs
	if action_delete:
		workflow.jobManager.delete(workflow.wms, action_delete)
		sys.exit(os.EX_OK)
	if action_reset:
		workflow.jobManager.reset(workflow.wms, action_reset)
		sys.exit(os.EX_OK)

	return workflow
def _gc_create_workflow(config, do_freeze=True, **kwargs):
	# create workflow from config and do initial processing steps
	# set up signal handler for interrupts and debug session or stack dump requests
	signal.signal(signal.SIGURG, handle_debug_interrupt)
	signal.signal(signal.SIGINT, handle_abort_interrupt)
	start_daemon('debug watchdog', _debug_watchdog)

	# Configure logging settings
	logging_setup(config.change_view(set_sections=['logging']))

	global_config = config.change_view(set_sections=['global'])
	_setup_work_path(global_config)
	for package_paths in global_config.get_dn_list('package paths', [], on_change=None):
		init_hpf_plugins(package_paths)

	# Query config settings before config is frozen
	help_cfg = global_config.get_state('display', detail='config')
	help_scfg = global_config.get_state('display', detail='minimal config')

	action_config = config.change_view(set_sections=['action'])
	action_cancel = action_config.get(['delete', 'cancel'], '', on_change=None)
	action_reset = action_config.get('reset', '', on_change=None)

	# Create workflow and freeze config settings
	workflow = global_config.get_plugin('workflow', 'Workflow:global', cls='Workflow', pkwargs=kwargs)
	gui = config.get_plugin('gui', 'BasicConsoleGUI', cls=GUI, on_change=None, pargs=(workflow,))
	if do_freeze:
		config.factory.freeze(write_config=config.get_state('init', detail='config'))

	# Give config help
	if help_cfg or help_scfg:
		config.write(sys.stdout, print_default=help_cfg, print_unused=False,
			print_minimal=help_scfg, print_source=help_cfg)
		sys.exit(os.EX_OK)

	# Check if user requested deletion / reset of jobs
	if action_cancel:
		workflow.job_manager.cancel(workflow.task, workflow.backend, action_cancel)
		sys.exit(os.EX_OK)
	if action_reset:
		workflow.job_manager.reset(workflow.task, workflow.backend, action_reset)
		sys.exit(os.EX_OK)

	return (workflow, gui)