Esempio n. 1
0
    def __init__(self):
        QFrame.__init__(self)
        SingleLinkableSetting.__init__(self, "api_key")

        # lazy loaded, see self#library
        self._library = None

        self.print_results_signal.connect(self.print_results)
        self.write_to_terminal_signal.connect(self.write)

        self.q = Queue()
        # `AnalysisResult`s get put here when we get a url scheme event, we need
        # to create the visualizer from the main thread so we use a queue to
        # kick back the work to the main thread. This is checked at the same
        # time `self.q` is
        self.url_analysis_q = Queue()
        # reset at the beginning of every run, used to print something after
        # every run only if a cheat wasn't found
        self.show_no_cheat_found = True
        self.print_results_event = threading.Event()
        self.cg_q = Queue()
        self.helper_thread_running = False
        self.runs = [] # Run objects for cancelling runs
        self.run_id = 0
        self.visualizer = None

        terminal = QTextEdit(self)
        terminal.setFocusPolicy(Qt.ClickFocus)
        terminal.setReadOnly(True)
        terminal.ensureCursorVisible()
        self.terminal = terminal

        self.run_button = RunButton()
        self.run_button.setFixedHeight(30)
        self.run_button.setText("Run")
        font = self.run_button.font()
        font.setPointSize(15)
        self.run_button.setFont(font)
        self.run_button.clicked.connect(self.add_circleguard_run)
        # disable button if no api_key is stored
        self.on_setting_changed("api_key", get_setting("api_key"))

        investigate_label = QLabel("Investigate For:")
        investigate_label.setFixedWidth(130)
        investigate_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        self.investigation_checkboxes = InvestigationCheckboxes()
        investigations = WidgetCombiner(investigate_label, self.investigation_checkboxes, self)
        investigations.setFixedHeight(25)

        self.loadable_creation = LoadableCreation()

        self.investigation_checkboxes.similarity_cb.checkbox.stateChanged.connect(self.loadable_creation.similarity_cb_state_changed)

        layout = QGridLayout()
        layout.addWidget(investigations, 0, 0, 1, 16)
        layout.addWidget(self.loadable_creation, 1, 0, 4, 16)
        layout.addWidget(self.terminal, 5, 0, 2, 16)
        layout.addWidget(self.run_button, 7, 0, 1, 16)

        self.setLayout(layout)
Esempio n. 2
0
    def __init__(self):
        QFrame.__init__(self)
        SingleLinkableSetting.__init__(self, "api_key")

        # lazy loaded, see self#library
        self._library = None

        self.print_results_signal.connect(self.print_results)
        self.write_to_terminal_signal.connect(self.write)

        self.q = Queue()
        # `AnalysisResult`s get put here when we get a url scheme event, we need
        # to create the visualizer from the main thread so we use a queue to
        # kick back the work to the main thread. This is checked at the same
        # time `self.q` is
        self.url_analysis_q = Queue()
        # reset at the beginning of every run, used to print something after
        # every run only if a cheat wasn't found
        self.show_no_cheat_found = True
        self.print_results_event = threading.Event()
        self.cg_q = Queue()
        self.helper_thread_running = False
        # all run objects - finished, running, and queued. Kept for cancelling
        # runs and maybe a few other things like reordering runs.
        self.runs = []
        self.run_id = 0
        self.visualizer = None

        # okay this is definitely a hack, let me explain. We pass runs to our
        # helper thread via a queue, where we add items to the queue in the
        # order the runs are added to the queue. However, we allow users to
        # change the order of runs in the queue, which means their order in the
        # queue need to change so they got processed in the right order.
        # Queues don't offer any way to modify order of items in the queue, so
        # instead we have this hack: the helper thread takes all runs out from
        # the queue every time it checks the queue, and stores them in this
        # list. Then it checks against the priorities dictionary
        # ``run_priorities`` to see which run should be processed first. It
        # processes that run and removes it from the list.
        # A few notes: the runs list is ONLY for the helper thread and is never
        # touched by the main thread. The priorities dict is read-only from the
        # helper thread - only the main thread writes to it.
        self.helper_thread_runs = []
        # mapping of run_id to run priority (int to int)
        self.run_priorities = {}

        terminal = QTextBrowser(self)
        terminal.setFocusPolicy(Qt.ClickFocus)
        terminal.setReadOnly(True)
        terminal.ensureCursorVisible()
        terminal.setOpenExternalLinks(True)
        self.terminal = terminal

        self.run_button = RunButton()
        self.run_button.setFixedHeight(30)
        self.run_button.setText("Run")
        font = self.run_button.font()
        font.setPointSize(15)
        self.run_button.setFont(font)
        self.run_button.clicked.connect(self.add_circleguard_run)
        # disable button if no api_key is stored
        self.on_setting_changed("api_key", get_setting("api_key"))

        investigate_label = QLabel("Investigate For:")
        investigate_label.setFixedWidth(130)
        investigate_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)

        self.investigation_checkboxes = InvestigationCheckboxes()
        investigations = WidgetCombiner(investigate_label,
                                        self.investigation_checkboxes, self)
        investigations.setFixedHeight(25)

        self.loadable_creation = LoadableCreation()

        self.investigation_checkboxes.similarity_cb.checkbox.stateChanged.connect(
            self.loadable_creation.similarity_cb_state_changed)

        layout = QGridLayout()
        layout.addWidget(investigations, 0, 0, 1, 16)
        layout.addWidget(self.loadable_creation, 1, 0, 4, 16)
        layout.addWidget(self.terminal, 5, 0, 2, 16)
        layout.addWidget(self.run_button, 7, 0, 1, 16)

        self.setLayout(layout)