コード例 #1
0
    def __init__(self):
        super(PugdebugMainWindow, self).__init__()
        self.setObjectName("pugdebug")
        self.setWindowTitle("pugdebug")

        if has_setting("window/geometry"):
            self.restoreGeometry(get_setting("window/geometry"))

        self.file_browser = PugdebugFileBrowser()
        self.projects_browser = PugdebugProjectsBrowser()
        self.settings_window = PugdebugSettingsWindow(self)
        self.new_project_window = PugdebugNewProjectWindow(self)
        self.document_viewer = PugdebugDocumentViewer()
        self.variable_viewer = PugdebugVariableViewer()
        self.breakpoint_viewer = PugdebugBreakpointViewer()
        self.stacktrace_viewer = PugdebugStacktraceViewer()
        self.expression_viewer = PugdebugExpressionViewer()
        self.file_search_window = PugdebugFileSearchWindow(self)

        self.setCentralWidget(self.document_viewer)

        self.setup_gui_elements()

        if has_setting("window/state"):
            self.restoreState(get_setting("window/state"))

        if has_setting("current_project"):
            self.set_window_title(get_setting("current_project"))

        self.projects_browser.project_deleted_signal.connect(
            self.handle_project_deleted)
コード例 #2
0
ファイル: main_window.py プロジェクト: mbarbon/pugdebug
    def __init__(self):
        super(PugdebugMainWindow, self).__init__()
        self.setObjectName("pugdebug")
        self.setWindowTitle("pugdebug")

        if has_setting("window/geometry"):
            self.restoreGeometry(get_setting("window/geometry"))

        self.file_browser = PugdebugFileBrowser()
        self.projects_browser = PugdebugProjectsBrowser()
        self.settings_window = PugdebugSettingsWindow(self)
        self.new_project_window = PugdebugNewProjectWindow(self)
        self.document_viewer = PugdebugDocumentViewer()
        self.variable_viewer = PugdebugVariableViewer()
        self.breakpoint_viewer = PugdebugBreakpointViewer()
        self.stacktrace_viewer = PugdebugStacktraceViewer()
        self.expression_viewer = PugdebugExpressionViewer()

        self.setCentralWidget(self.document_viewer)

        self.setup_gui_elements()

        if has_setting("window/state"):
            self.restoreState(get_setting("window/state"))

        if has_setting("current_project"):
            self.set_window_title(get_setting("current_project"))

        self.projects_browser.project_deleted_signal.connect(self.handle_project_deleted)
コード例 #3
0
 def __cut_filename(self, filename):
     path_map = get_setting('path/path_mapping')
     if len(path_map) > 0:
         filename = filename[len(path_map):]
     else:
         root = get_setting('path/project_root')
         filename = filename[len(root):]
     return "~%s" % filename
コード例 #4
0
ファイル: stacktraces.py プロジェクト: Hailong/pugdebug
 def __cut_filename(self, filename):
     path_map = get_setting('path/path_mapping')
     if len(path_map) > 0:
         filename = filename[len(path_map):]
     else:
         root = get_setting('path/project_root')
         filename = filename[len(root):]
     return "~%s" % filename
コード例 #5
0
    def __listen(self, socket_server):
        """Listen to new incomming connections

        For every accepted connection, see if it is valid and emit a signal
        with that new connection.

        Otherwise silently disregard that connection.
        """
        host = get_setting('debugger/host')
        port_number = int(get_setting('debugger/port_number'))

        try:
            socket_server.bind((host, port_number))
            socket_server.listen(5)

            while self.wait_for_accept:
                try:
                    sock, address = socket_server.accept()
                    sock.settimeout(None)

                    if sock is not None:
                        connection = PugdebugServerConnection(sock)

                        try:
                            is_valid = connection.init_connection()
                        except OSError as e:
                            # in case the debugged program closes
                            # the connection
                            is_valid = False
                            self.server_error_signal.emit(
                                '%s (during connection initialization)' %
                                e.strerror)

                        if is_valid and self.wait_for_accept:
                            self.new_connection_established_signal.emit(
                                connection)
                        else:
                            connection.disconnect()
                except socket.timeout:
                    pass

        except OSError as e:
            self.server_error_signal.emit(e.strerror)
        finally:
            socket_server.close()

        if not self.wait_for_accept:
            self.server_stopped_signal.emit()
コード例 #6
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def start_listening(self):
        """Start listening to new incomming connections

        Clear the variable viewer.

        Clear the stacktrace viewer.

        Remove all line highlights.

        Start a debugging session.
        """
        break_at_first_line = int(get_setting('debugger/break_at_first_line'))

        start_debugging = True

        if break_at_first_line == 0 and len(self.breakpoints) == 0:
            messageBox = QMessageBox()
            messageBox.setText("There are no breakpoints set and the break at"
                               " first line setting is turned off.")
            messageBox.setInformativeText("Are you sure you want to start"
                                          " debugging?")
            messageBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            answer = messageBox.exec_()

            if answer == QMessageBox.No:
                start_debugging = False

        if start_debugging:
            self.variable_viewer.clear()
            self.stacktrace_viewer.clear()

            self.document_viewer.remove_line_highlights()

            self.debugger.start_listening()
            self.main_window.set_debugging_status(1)
コード例 #7
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def handle_settings_changed(self, changed_settings):
        """Handle when settings have changed.

        Given argument is a set of settings's names which have been changed.
        """

        if has_setting('current_project'):
            project_name = get_setting('current_project')

            project = self.projects_browser.load_project_by_name(project_name)

            if project is not None:
                project.set_settings(changed_settings)

        changed_setting_keys = changed_settings.keys()

        if 'path/project_root' in changed_setting_keys:
            self.handle_project_root_changed()

        features = [
            'debugger/max_depth', 'debugger/max_children', 'debugger/max_data'
        ]

        if any(True for feature in features
               if feature in changed_setting_keys):
            self.handle_debugger_features_changed()
コード例 #8
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def start_listening(self):
        """Start listening to new incomming connections

        Clear the variable viewer.

        Clear the stacktrace viewer.

        Remove all line highlights.

        Start a debugging session.
        """
        break_at_first_line = int(get_setting('debugger/break_at_first_line'))

        start_debugging = True

        if break_at_first_line == 0 and len(self.breakpoints) == 0:
            messageBox = QMessageBox()
            messageBox.setText("There are no breakpoints set and the break at"
                               " first line setting is turned off.")
            messageBox.setInformativeText("Are you sure you want to start"
                                          " debugging?")
            messageBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
            answer = messageBox.exec_()

            if answer == QMessageBox.No:
                start_debugging = False

        if start_debugging:
            self.variable_viewer.clear()
            self.stacktrace_viewer.clear()

            self.document_viewer.remove_line_highlights()

            self.debugger.start_listening()
            self.main_window.set_debugging_status(1)
コード例 #9
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def handle_settings_changed(self, changed_settings):
        """Handle when settings have changed.

        Given argument is a set of settings's names which have been changed.
        """

        if has_setting('current_project'):
            project_name = get_setting('current_project')

            project = self.projects_browser.load_project_by_name(project_name)

            if project is not None:
                project.set_settings(changed_settings)

        changed_setting_keys = changed_settings.keys()

        if 'path/project_root' in changed_setting_keys:
            self.handle_project_root_changed()

        features = ['debugger/max_depth',
                    'debugger/max_children',
                    'debugger/max_data']

        if any(True for feature in features
               if feature in changed_setting_keys):
            self.handle_debugger_features_changed()
コード例 #10
0
ファイル: projects.py プロジェクト: yashodhank/pugdebug
    def is_project_current(self):
        if has_setting('current_project'):
            current_project = get_setting('current_project')

            if current_project == self.get_project_name():
                return True

        return False
コード例 #11
0
ファイル: server.py プロジェクト: ejwilhelm/pugdebug
    def __listen(self, socket_server):
        """Listen to new incomming connections

        For every accepted connection, see if it is valid and emit a signal
        with that new connection.

        Otherwise silently disregard that connection.
        """
        host = get_setting('debugger/host')
        port_number = int(get_setting('debugger/port_number'))

        try:
            socket_server.bind((host, port_number))
            socket_server.listen(5)

            while self.wait_for_accept:
                try:
                    sock, address = socket_server.accept()
                    sock.settimeout(None)

                    if sock is not None:
                        connection = PugdebugServerConnection(sock)

                        try:
                            is_valid = connection.init_connection()
                        except OSError as e:
                            # in case the debugged program closes the connection
                            is_valid = False
                            self.server_error_signal.emit('%s (during connection initialization)' % e.strerror)

                        if is_valid and self.wait_for_accept:
                            self.new_connection_established_signal.emit(
                                connection
                            )
                        else:
                            connection.disconnect()
                except socket.timeout:
                    pass

        except OSError as e:
            self.server_error_signal.emit(e.strerror)
        finally:
            socket_server.close()

        if not self.wait_for_accept:
            self.server_stopped_signal.emit()
コード例 #12
0
ファイル: projects.py プロジェクト: mbarbon/pugdebug
    def is_project_current(self):
        if has_setting("current_project"):
            current_project = get_setting("current_project")

            if current_project == self.get_project_name():
                return True

        return False
コード例 #13
0
    def __set_debugger_features(self):
        max_depth = int(get_setting('debugger/max_depth'))
        command = 'feature_set -i %d -n max_depth -v %d' % (
            self.__get_transaction_id(), max_depth)
        self.__send_command(command)

        max_children = int(get_setting('debugger/max_children'))
        command = 'feature_set -i %d -n max_children -v %d' % (
            self.__get_transaction_id(), max_children)
        self.__send_command(command)

        max_data = int(get_setting('debugger/max_data'))
        command = 'feature_set -i %d -n max_data -v %d' % (
            self.__get_transaction_id(), max_data)
        self.__send_command(command)

        return True
コード例 #14
0
ファイル: expressions.py プロジェクト: Hailong/pugdebug
    def restore_state(self):
        """Load expressions from settings"""
        expressions = []

        if has_setting('expressions_viewer/expressions'):
            expressions = get_setting('expressions_viewer/expressions')

        if expressions is not None:
            for expression in expressions:
                self.add_expression(expression)
コード例 #15
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def handle_debugging_post_start(self):
        """Handle post start debugging

        If the code should not break at first line, run the debugger.
        """
        break_at_first_line = int(get_setting('debugger/break_at_first_line'))
        if break_at_first_line == 0:
            self.run_debug()
        else:
            self.step_into()
コード例 #16
0
ファイル: pugdebug.py プロジェクト: andreym333/pugdebug
    def handle_project_root_changed(self):
        """Handle when the project root is changed

        Update the file browser's model to the new root.
        """
        project_root = get_setting('path/project_root')

        logging.debug("Project root changed: %s" % project_root)

        self.file_browser.set_path(project_root)
コード例 #17
0
    def restore_state(self):
        """Load expressions from settings"""
        expressions = []

        if has_setting('expressions_viewer/expressions'):
            expressions = get_setting('expressions_viewer/expressions')

        if expressions is not None:
            for expression in expressions:
                self.add_expression(expression)
コード例 #18
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def handle_debugging_post_start(self):
        """Handle post start debugging

        If the code should not break at first line, run the debugger.
        """
        break_at_first_line = int(get_setting('debugger/break_at_first_line'))
        if break_at_first_line == 0:
            self.run_debug()
        else:
            self.step_into()
コード例 #19
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def handle_project_root_changed(self):
        """Handle when the project root is changed

        Update the file browser's model to the new root.
        """
        project_root = get_setting('path/project_root')

        model = self.file_browser.model()
        model.set_path(project_root)
        self.file_browser.setModel(model)
        self.file_browser.setRootIndex(model.start_index)
コード例 #20
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def handle_project_root_changed(self):
        """Handle when the project root is changed

        Update the file browser's model to the new root.
        """
        project_root = get_setting('path/project_root')

        model = self.file_browser.model()
        model.set_path(project_root)
        self.file_browser.setModel(model)
        self.file_browser.setRootIndex(model.start_index)
コード例 #21
0
ファイル: pugdebug.py プロジェクト: andreym333/pugdebug
    def setup_file_browser(self):
        """Setup the file browser

        Sets the model on the file browser and hides the
        not needed columns.
        """

        project_root = get_setting('path/project_root')
        model = PugdebugFileBrowser(self)

        self.file_browser.setModel(model)
        self.file_browser.set_path(project_root)
コード例 #22
0
ファイル: pugdebug.py プロジェクト: mbarbon/pugdebug
    def __get_path_mapped_to_remote(self, path):
        """Get a path mapped to remote

        Turns a path like /home/user/local/path to /var/www
        """
        path_map = get_setting('path/path_mapping')
        root_path = self.file_browser.model().rootPath()

        if len(path_map) > 0 and path.find(root_path) == 0:
            path = path[len(root_path):]
            path = "%s%s" % (path_map, path)

        return path
コード例 #23
0
ファイル: pugdebug.py プロジェクト: Hailong/pugdebug
    def __get_path_mapped_to_remote(self, path):
        """Get a path mapped to remote

        Turns a path like /home/user/local/path to /var/www
        """
        path_map = get_setting('path/path_mapping')
        root_path = self.file_browser.model().rootPath()

        if len(path_map) > 0 and path.find(root_path) == 0:
            path = path[len(root_path):]
            path = "%s%s" % (path_map, path)

        return path
コード例 #24
0
ファイル: server.py プロジェクト: mbarbon/pugdebug
    def __set_debugger_features(self):
        max_depth = int(get_setting('debugger/max_depth'))
        command = 'feature_set -i %d -n max_depth -v %d' % (
            self.__get_transaction_id(),
            max_depth
        )
        response = self.__send_command(command)

        max_children = int(get_setting('debugger/max_children'))
        command = 'feature_set -i %d -n max_children -v %d' % (
            self.__get_transaction_id(),
            max_children
        )
        response = self.__send_command(command)

        max_data = int(get_setting('debugger/max_data'))
        command = 'feature_set -i %d -n max_data -v %d' % (
            self.__get_transaction_id(),
            max_data
        )
        response = self.__send_command(command)

        return True
コード例 #25
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def setup_file_browser(self):
        """Setup the file browser

        Sets the model on the file browser and hides the
        not needed columns.
        """

        project_root = get_setting('path/project_root')
        model = PugdebugFileBrowser(self)
        model.set_path(project_root)

        self.file_browser.setModel(model)
        self.file_browser.setRootIndex(model.start_index)
        self.file_browser.hide_columns()
コード例 #26
0
ファイル: pugdebug.py プロジェクト: andreym333/pugdebug
    def handle_debugging_post_start(self):
        """Handle post start debugging

        If the code should not break at first line, run the debugger.
        """
        logging.debug("Post start")
        break_at_first_line = int(get_setting('debugger/break_at_first_line'))

        logging.debug("Break at first line: %s" %
                      ('Yes' if break_at_first_line != 0 else 'No'))

        if break_at_first_line == 0:
            self.run_debug()
        else:
            self.step_into()
コード例 #27
0
ファイル: pugdebug.py プロジェクト: ejwilhelm/pugdebug
    def __get_path_mapped_to_local(self, path, map_paths=True):
        """Get a path mapped to local

        Turns a path like /var/www into /home/user/local/path
        """
        path_map = get_setting('path/path_mapping')
        if (len(path_map) > 0 and map_paths is True
                and path.find(path_map) == 0):
            path_map = path_map.rstrip('/')
            path = path[len(path_map):]
            path = "%s%s" % (self.file_browser.model().rootPath(), path)

            if not os.path.isfile(path):
                return False

        return path
コード例 #28
0
ファイル: pugdebug.py プロジェクト: Hailong/pugdebug
    def __get_path_mapped_to_local(self, path, map_paths=True):
        """Get a path mapped to local

        Turns a path like /var/www into /home/user/local/path
        """
        path_map = get_setting('path/path_mapping')
        if (len(path_map) > 0 and
                map_paths is True and
                path.find(path_map) == 0):
            path = path[len(path_map):]
            path = "%s%s" % (self.file_browser.model().rootPath(), path)

            if not os.path.isfile(path):
                return False

        return path
コード例 #29
0
ファイル: server.py プロジェクト: mbarbon/pugdebug
    def init_connection(self):
        """Init a new connection

        Read in the init message from xdebug and decide based on the
        idekey should this connection be accepted or not.

        Do note that it is not needed to call it from a new thread, as
        it is already called from a thread separate from the main application
        thread and thus should not block the main thread.
        """
        idekey = get_setting('debugger/idekey')

        response = self.__receive_message()

        init_message = self.parser.parse_init_message(response)

        # See if the init message from xdebug is meant for us
        if idekey != '' and init_message['idekey'] != idekey:
            return False

        self.init_message = init_message

        return True
コード例 #30
0
    def init_connection(self):
        """Init a new connection

        Read in the init message from xdebug and decide based on the
        idekey should this connection be accepted or not.

        Do note that it is not needed to call it from a new thread, as
        it is already called from a thread separate from the main application
        thread and thus should not block the main thread.
        """
        idekey = get_setting('debugger/idekey')

        response = self.__receive_message()

        init_message = self.parser.parse_init_message(response)

        # See if the init message from xdebug is meant for us
        if idekey != '' and init_message['idekey'] != idekey:
            return False

        self.init_message = init_message

        return True
コード例 #31
0
 def set_font_size(self):
     font = QFont()
     font.setPixelSize(int(get_setting('editor/font_size')))
     self.setFont(font)
コード例 #32
0
 def load_settings(self):
     """Loads all settings from QSettings into the form"""
     for name, widget in self.form.widgets.items():
         value = get_setting(name) if has_setting(name) \
             else get_default_setting(name)
         self.form.set_widget_value(widget, value)
コード例 #33
0
ファイル: search.py プロジェクト: yashodhank/pugdebug
 def exec(self):
     self.project_root = get_setting('path/project_root')
     self.file_search = PugdebugFileSearch(self, self.project_root)
     super(PugdebugFileSearchWindow, self).exec()
コード例 #34
0
    def set_editor_features(self):
        self.setTabStopWidth(int(get_setting('editor/tab_width')))

        font = QFont('mono')
        font.setPixelSize(int(get_setting('editor/font_size')))
        self.setFont(font)