def fill(self, container): combined_entry = container.get_entry( 'cmdargs', lambda entry: entry.section == 'global') new_cmd_line = self._cmd_line_args if combined_entry: new_cmd_line = combined_entry.value.split() + self._cmd_line_args (opts, _) = _parse_cmd_line(new_cmd_line) if opts.debug_console: handle_debug_interrupt() if opts.debug_trace: debug_trace_kwargs = {} for key_value in opts.debug_trace: debug_trace_kwargs[key_value.split('=')[0]] = key_value.split( '=')[1] DebugInterface().set_trace(**debug_trace_kwargs) def _set_config_from_opt(section, option, value): if value is not None: self._add_entry(container, section, option, str(value), '<cmdline>') # pylint:disable=no-member cmd_line_config_map = { 'state!': { '#init': opts.init, '#resync': opts.resync, '#display config': opts.help_conf, '#display minimal config': opts.help_confmin }, 'action': { 'delete': opts.delete, 'cancel': opts.cancel, 'reset': opts.reset }, 'global': { 'gui': opts.gui, 'submission': opts.submission }, 'jobs': { 'jobs': opts.jobs, 'max retry': opts.max_retry, 'selected': opts.job_selector }, 'logging': { 'debug mode': opts.debug }, } for section in cmd_line_config_map: for (option, value) in cmd_line_config_map[section].items(): _set_config_from_opt(section, option, value) for (logger_name, logger_level) in parse_logging_args(opts.logging): _set_config_from_opt('logging', logger_name + ' level', logger_level) if opts.action is not None: _set_config_from_opt('workflow', 'action', opts.action.replace(',', ' ')) if opts.continuous: _set_config_from_opt('workflow', 'duration', -1) if opts.override: Plugin.create_instance('StringConfigFiller', opts.override).fill(container)
def handle_debug_interrupt(sig=None, frame=None): buffer = StringBuffer() GCStreamHandler.push_std_stream(buffer, buffer) DebugInterface(frame, interrupt_fun=_trigger_debug_signal).start_console( env_dict={'output': buffer.getvalue}) GCStreamHandler.pop_std_stream()
def _check_write_stack_log(): if os.path.exists('gc_debug_stack.log'): with_file( SafeFile('gc_debug_stack.log', 'w'), lambda fp: DebugInterface( stream=fp).show_stack(thread_id='all'))