Example #1
0
    def __set_debugger_features(self):
        with settings.open_group('project/' + projects.active()):
            max_depth = settings.value('debugger/max_depth')
            max_children = settings.value('debugger/max_children')
            max_data = settings.value('debugger/max_data')

        command = 'feature_set -i %d -n max_depth -v %d' % (
            self.__get_transaction_id(),
            max_depth
        )
        self.__send_command(command)

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

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

        return True
Example #2
0
    def load_data(self):
        with settings.open_group('project'):
            self.projects = list(filter(lambda s: s.lower() != 'default',
                                        settings.child_groups()))
            self.projects.sort(key=str.lower)
            self.projects.insert(0, 'default')

        self.emit_data_changed()
Example #3
0
 def __cut_filename(self, filename):
     with settings.open_group('project/' + projects.active()):
         path_map = settings.value('path/path_mapping')
         if len(path_map) > 0:
             path_map = path_map.rstrip('/')
             if filename.startswith(path_map):
                 return '~' + filename[len(path_map):]
         else:
             root = settings.value('path/project_root')
             root = root.rstrip('/')
             if filename.startswith(root):
                 return '~' + filename[len(root):]
         return filename
Example #4
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.
        """
        with settings.open_group('project/' + projects.active()):
            host = settings.value('debugger/host')
            port_number = settings.value('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()
Example #5
0
    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
        """
        with settings.open_group('project/' + projects.active()):
            root_path = settings.value('path/project_root')
            path_map = settings.value('path/path_mapping')

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

        return path
Example #6
0
    def update(self, old_name, new_name, new_settings):
        if old_name and old_name != new_name:
            settings.remove('project/' + old_name)

        with settings.open_group('project/' + new_name):
            for k, v in new_settings.items():
                settings.set_value(k, v)

        if not old_name:
            self.load_data()
            self.set_active(new_name)
        elif old_name != new_name:
            self.load_data()
            if old_name == self.active:
                self.set_active(new_name)
        elif old_name == self.active:
            self.active_project_changed.emit()
Example #7
0
    def show(self):
        title = 'Edit Project' if self.project_name else 'New Project'
        self.setWindowTitle(title)

        self.project_name_input.setText(self.project_name)
        if self.project_name != 'default':
            self.project_name_input.setDisabled(False)
            self.project_name_input.setFocus(Qt.OtherFocusReason)
        else:
            self.project_name_input.setDisabled(True)
            self.project_root_input.setFocus(Qt.OtherFocusReason)

        group = 'project/' + (self.project_name or 'default')
        with settings.open_group(group):
            if self.project_name:
                self.project_root_input.setText(
                    settings.value('path/project_root'))

                self.path_mapping_input.setText(
                    settings.value('path/path_mapping'))
            else:
                self.project_root_input.setText('')
                self.path_mapping_input.setText('')

            self.host_input.setText(
                settings.value('debugger/host'))

            self.port_number_input.setValue(
                settings.value('debugger/port_number'))

            self.idekey_input.setText(
                settings.value('debugger/idekey'))

            self.break_at_first_line_input.setChecked(
                settings.value('debugger/break_at_first_line'))

            self.max_depth_input.setValue(
                settings.value('debugger/max_depth'))

            self.max_children_input.setValue(
                settings.value('debugger/max_children'))

            self.max_data_input.setValue(
                settings.value('debugger/max_data'))

        super().show()
Example #8
0
    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
        """
        with settings.open_group('project/' + projects.active()):
            root_path = settings.value('path/project_root')
            path_map = settings.value('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" % (root_path, path)

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

        return path