Exemple #1
0
 def __init__(self,  parent, builder, gui_helper):
     self.parent = parent
     self.run_window = builder.get_object("runWindow")
     self.run_tree_view = builder.get_object("runTreeView")
     self.debug_btn = builder.get_object("debugBtn")
     self.info_box = builder.get_object("infoBox")
     self.scrolled_window = builder.get_object("scrolledWindow")
     self.back_btn = builder.get_object("backBtn")
     self.main_btn = builder.get_object("mainBtn")
     self.tlh = RunLoggingHandler(self, self.run_tree_view)
     self.gui_helper = gui_helper
     logger.addHandler(self.tlh)
     FORMAT = "%(levelname)s %(message)s"
     self.tlh.setFormatter(logging.Formatter(FORMAT))
     logger.setLevel(logging.DEBUG)
     self.store = Gtk.TreeStore(str)
     renderer = Gtk.CellRendererText()
     column = Gtk.TreeViewColumn("Log from current process", renderer, text=0)
     self.run_tree_view.append_column(column)
     self.run_tree_view.set_model(self.store)
     self.stop = threading.Event()
     self.pr = None
     self.link = self.gui_helper.create_button()
     self.info_label = gui_helper.create_label('<span color="#FFA500">In progress...</span>')
     self.info_box.pack_start(self.info_label, False, False, 12)
     self.project_canceled = False
     self.kwargs = {}
     self.current_main_assistant = None
     self.top_assistant = None
     self.close_win = False
     sigint_handler.override()
Exemple #2
0
    def run(cls):
        """Runs the whole cli:

        1. Registers console logging handler
        2. Creates argparser from all assistants and actions
        3. Parses args and decides what to run
        4. Runs a proper assistant or action
        """
        sigint_handler.override()
        # set current_run.USE_CACHE before constructing parser, since constructing
        # parser requires loaded assistants
        current_run.USE_CACHE = False if '--no-cache' in sys.argv else True
        cls.register_console_logging_handler(logger.logger)
        cls.inform_of_short_bin_name(sys.argv[0])
        top_assistant = bin.TopAssistant()
        tree = top_assistant.get_subassistant_tree()
        argparser = argparse_generator.ArgparseGenerator.\
            generate_argument_parser(tree, actions=actions.actions)
        parsed_args = vars(argparser.parse_args())
        if parsed_args.get('da_debug'):
            cls.change_logging_level(logging.DEBUG)
        if actions.is_action_run(**parsed_args):
            to_run = actions.get_action_to_run(**parsed_args)
        else:
            parsed_args = cls.transform_executable_assistant_alias(parsed_args)
            path = top_assistant.get_selected_subassistant_path(**parsed_args)
            to_run = path_runner.PathRunner(path, parsed_args)
        try:
            to_run.run(**parsed_args)
        except exceptions.ExecutionException:
            # error is already logged, just catch it and silently exit here
            sys.exit(1)
Exemple #3
0
    def run(cls):
        """Runs the whole cli:

        1. Registers console logging handler
        2. Creates argparser from all assistants and actions
        3. Parses args and decides what to run
        4. Runs a proper assistant or action
        """
        sigint_handler.override()
        # set current_run.USE_CACHE before constructing parser, since constructing
        # parser requires loaded assistants
        current_run.USE_CACHE = False if '--no-cache' in sys.argv else True
        cls.register_console_logging_handler(logger.logger)
        cls.inform_of_short_bin_name(sys.argv[0])
        top_assistant = bin.TopAssistant()
        tree = top_assistant.get_subassistant_tree()
        argparser = argparse_generator.ArgparseGenerator.\
            generate_argument_parser(tree, actions=actions.actions)
        parsed_args = vars(argparser.parse_args())
        if parsed_args.get('da_debug'):
            cls.change_logging_level(logging.DEBUG)
        if actions.is_action_run(**parsed_args):
            to_run = actions.get_action_to_run(**parsed_args)
        else:
            parsed_args = cls.transform_executable_assistant_alias(parsed_args)
            path = top_assistant.get_selected_subassistant_path(**parsed_args)
            to_run = path_runner.PathRunner(path, parsed_args)
        try:
            to_run.run(**parsed_args)
        except exceptions.ExecutionException:
            # error is already logged, just catch it and silently exit here
            sys.exit(1)
Exemple #4
0
    def run(cls):
        """Runs the whole cli:

        1. Registers console logging handler
        2. Creates argparser from all assistants and actions
        3. Parses args and decides what to run
        4. Runs a proper assistant or action
        """
        sigint_handler.override()
        # set settings.USE_CACHE before constructing parser, since constructing
        # parser requires loaded assistants
        settings.USE_CACHE = False if '--no-cache' in sys.argv else True
        cls.register_console_logging_handler(logger.logger)
        is_log_file = logger.add_log_file_handler(settings.LOG_FILE)
        if not is_log_file:
            logger.logger.warning("Could not create log file '{0}'.".format(
                settings.LOG_FILE))
        cls.inform_of_short_bin_name(sys.argv[0])
        top_assistant = bin.TopAssistant()
        tree = top_assistant.get_subassistant_tree()
        argparser = argparse_generator.ArgparseGenerator.\
            generate_argument_parser(tree, actions=actions.actions)
        parsed_args = vars(argparser.parse_args())

        parsed_args_decoded = dict()
        for k, v in parsed_args.items():
            parsed_args_decoded[k] = \
                v.decode(utils.defenc) if not six.PY3 and isinstance(v, str) else v
        parsed_args_decoded['__ui__'] = 'cli'

        if parsed_args.get('da_debug'):
            cls.change_logging_level(logging.DEBUG)

        # Prepare Action/PathRunner
        if actions.is_action_run(**parsed_args_decoded):
            to_run = actions.get_action_to_run(**parsed_args_decoded)(
                **parsed_args_decoded)
        else:
            parsed_args = cls.transform_executable_assistant_alias(
                parsed_args_decoded)
            path = top_assistant.get_selected_subassistant_path(
                **parsed_args_decoded)
            to_run = path_runner.PathRunner(path, parsed_args_decoded)

        try:
            to_run.run()
        except exceptions.ExecutionException:
            # error is already logged, just catch it and silently exit here
            sys.exit(1)
Exemple #5
0
 def __init__(self, parent, builder, gui_helper):
     self.parent = parent
     self.run_window = builder.get_object("runWindow")
     self.run_list_view = builder.get_object("runTreeView")
     self.debug_btn = builder.get_object("debugBtn")
     self.info_box = builder.get_object("infoBox")
     self.scrolled_window = builder.get_object("scrolledWindow")
     self.back_btn = builder.get_object("backBtn")
     self.main_btn = builder.get_object("mainBtn")
     self.tlh = RunLoggingHandler(self, self.run_list_view)
     self.gui_helper = gui_helper
     logger.addHandler(self.tlh)
     format_msg = "%(levelname)s %(message)s"
     self.tlh.setFormatter(logging.Formatter(format_msg))
     logger.setLevel(logging.DEBUG)
     is_log_file = add_log_file_handler(settings.LOG_FILE)
     if not is_log_file:
         logger_gui.warning("Could not create log file '{0}'.".format(
             settings.LOG_FILE))
     self.store = Gtk.ListStore(str)
     renderer = Gtk.CellRendererText()
     renderer.set_property('font', 'Liberation Mono')
     renderer.set_property('wrap_width', 750)
     renderer.set_property('wrap_mode', Gtk.WrapMode.WORD)
     column = Gtk.TreeViewColumn("Log from current process",
                                 renderer,
                                 markup=0)
     self.run_list_view.append_column(column)
     self.run_list_view.set_model(self.store)
     self.run_list_view.connect('row-activated', self.list_view_row_clicked)
     self.stop = threading.Event()
     self.dev_assistant_runner = None
     self.debug_logs = dict()
     self.debug_logs['logs'] = []
     self.link = None
     self.info_label = gui_helper.create_label(
         '<span color="#FFA500">In progress...</span>')
     self.info_box.pack_start(self.info_label, False, False, 12)
     self.project_canceled = False
     self.kwargs = {}
     self.current_main_assistant = None
     self.top_assistant = None
     self.close_win = False
     self.debugging = False
     self.thread = None
     sigint_handler.override()
    def run(cls):
        """Runs the whole cli:

        1. Registers console logging handler
        2. Creates argparser from all assistants and actions
        3. Parses args and decides what to run
        4. Runs a proper assistant or action
        """
        sigint_handler.override()
        # set settings.USE_CACHE before constructing parser, since constructing
        # parser requires loaded assistants
        settings.USE_CACHE = False if '--no-cache' in sys.argv else True
        cls.register_console_logging_handler(logger.logger)
        is_log_file = logger.add_log_file_handler(settings.LOG_FILE)
        if not is_log_file:
            logger.logger.warning("Could not create log file '{0}'.".format(settings.LOG_FILE))
        cls.inform_of_short_bin_name(sys.argv[0])
        top_assistant = bin.TopAssistant()
        tree = top_assistant.get_subassistant_tree()
        argparser = argparse_generator.ArgparseGenerator.\
            generate_argument_parser(tree, actions=actions.actions)
        parsed_args = vars(argparser.parse_args())

        parsed_args_decoded = dict()
        for k, v in parsed_args.items():
            parsed_args_decoded[k] = \
                v.decode(utils.defenc) if not six.PY3 and isinstance(v, str) else v
        parsed_args_decoded['__ui__'] = 'cli'

        if parsed_args.get('da_debug'):
            cls.change_logging_level(logging.DEBUG)

        # Prepare Action/PathRunner
        if actions.is_action_run(**parsed_args_decoded):
            to_run = actions.get_action_to_run(**parsed_args_decoded)(**parsed_args_decoded)
        else:
            parsed_args = cls.transform_executable_assistant_alias(parsed_args_decoded)
            path = top_assistant.get_selected_subassistant_path(**parsed_args_decoded)
            to_run = path_runner.PathRunner(path, parsed_args_decoded)

        try:
            to_run.run()
        except exceptions.ExecutionException:
            # error is already logged, just catch it and silently exit here
            sys.exit(1)
Exemple #7
0
 def __init__(self, parent, builder, gui_helper):
     self.parent = parent
     self.run_window = builder.get_object("runWindow")
     self.run_list_view = builder.get_object("runTreeView")
     self.debug_btn = builder.get_object("debugBtn")
     self.info_box = builder.get_object("infoBox")
     self.scrolled_window = builder.get_object("scrolledWindow")
     self.back_btn = builder.get_object("backBtn")
     self.main_btn = builder.get_object("mainBtn")
     self.tlh = RunLoggingHandler(self, self.run_list_view)
     self.gui_helper = gui_helper
     logger.addHandler(self.tlh)
     format_msg = "%(levelname)s %(message)s"
     self.tlh.setFormatter(logging.Formatter(format_msg))
     logger.setLevel(logging.DEBUG)
     is_log_file = add_log_file_handler(settings.LOG_FILE)
     if not is_log_file:
         logger_gui.warning("Could not create log file '{0}'.".format(settings.LOG_FILE))
     self.store = Gtk.ListStore(str)
     renderer = Gtk.CellRendererText()
     renderer.set_property('font', 'Liberation Mono')
     renderer.set_property('wrap_width', 750)
     renderer.set_property('wrap_mode', Gtk.WrapMode.WORD)
     column = Gtk.TreeViewColumn("Log from current process", renderer, markup=0)
     self.run_list_view.append_column(column)
     self.run_list_view.set_model(self.store)
     self.run_list_view.connect('row-activated', self.list_view_row_clicked)
     self.stop = threading.Event()
     self.dev_assistant_runner = None
     self.debug_logs = dict()
     self.debug_logs['logs'] = []
     self.link = None
     self.info_label = gui_helper.create_label('<span color="#FFA500">In progress...</span>')
     self.info_box.pack_start(self.info_label, False, False, 12)
     self.project_canceled = False
     self.kwargs = {}
     self.current_main_assistant = None
     self.top_assistant = None
     self.close_win = False
     self.debugging = False
     self.thread = None
     sigint_handler.override()