예제 #1
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
예제 #2
0
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)
예제 #3
0
def initGC():
	import os, sys
	basePath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
	sys.path.insert(1, basePath) # packages bundled with grid-control have priority
	os.environ['GC_PACKAGES_PATH'] = basePath # Store grid-control base path in enviroment variable
	from hpfwk import init_hpf_plugins
	from grid_control.logging_setup import logging_defaults
	init_hpf_plugins(basePath)
	logging_defaults()
예제 #4
0
def initGC():
	import os, sys
	basePath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
	sys.path.insert(1, basePath) # packages bundled with grid-control have priority
	os.environ['GC_PACKAGES_PATH'] = basePath # Store grid-control base path in enviroment variable
	from hpfwk import init_hpf_plugins
	from grid_control.logging_setup import logging_defaults
	init_hpf_plugins(basePath)
	logging_defaults()
예제 #5
0
def _init_grid_control():
	if not _init_grid_control.flag:
		_init_grid_control.flag = True
		import os, sys
		packages_base_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
		sys.path.insert(1, packages_base_path)  # packages bundled with grid-control have priority
		os.environ['GC_PACKAGES_PATH'] = packages_base_path  # Store grid-control base path

		from hpfwk import init_hpf_plugins
		package_name_list = os.listdir(packages_base_path)
		package_name_list.sort()
		for package_name in package_name_list:
			init_hpf_plugins(os.path.join(packages_base_path, package_name))

		from grid_control.logging_setup import logging_defaults
		logging_defaults()
예제 #6
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
예제 #7
0
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)
예제 #8
0
def _init_grid_control():
    if not _init_grid_control.flag:
        _init_grid_control.flag = True
        import os, sys
        packages_base_path = os.path.dirname(
            os.path.dirname(os.path.abspath(__file__)))
        sys.path.insert(1, packages_base_path
                        )  # packages bundled with grid-control have priority
        os.environ[
            'GC_PACKAGES_PATH'] = packages_base_path  # Store grid-control base path

        from hpfwk import init_hpf_plugins
        package_name_list = os.listdir(packages_base_path)
        package_name_list.sort()
        for package_name in package_name_list:
            init_hpf_plugins(os.path.join(packages_base_path, package_name))

        from grid_control.logging_setup import logging_defaults
        logging_defaults()