Esempio n. 1
0
    def createDefault():
        logging.info("Create a default configuration file")
        defaultConfig = ConfigParser.RawConfigParser()
        defaultConfig.add_section('clustering')
        defaultConfig.add_section('projects')
        defaultConfig.add_section('automata')
        defaultConfig.add_section('logging')
        defaultConfig.add_section('import')

        defaultConfig.set('clustering', 'equivalence_threshold', '60')
        defaultConfig.set('clustering', 'orphan_reduction', '0')
        defaultConfig.set('clustering', 'nbiteration', '100')
        defaultConfig.set('clustering', 'do_internal_slick', '0')
        defaultConfig.set('clustering', 'protocol_type', '1')

        defaultTraceDirectory = os.path.join(ResourcesConfiguration.getWorkspaceFile(), "projects")
        defaultConfig.set('projects', 'path', defaultTraceDirectory)

        defaultAutomatonDirectory = os.path.join(ResourcesConfiguration.getWorkspaceFile(), "automaton")
        defaultConfig.set('automata', 'path', defaultAutomatonDirectory)

        defaultConfig.set('logging', 'path', '')

        #defaultConfig.set('import', 'repository_prototypes', 'resources/prototypes/repository.xml')
        defaultConfig.set('import', 'repository_prototypes', '')

        return defaultConfig
Esempio n. 2
0
    def createWorkspace(name, path):
        tracesPath = "traces"
        projectsPath = "projects"
        prototypesPath = "prototypes"
        loggingPath = "logging"
        pathOfLogging = "logging/logging.conf"

        # we create a "traces" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, tracesPath)):
            os.mkdir(os.path.join(path, tracesPath))

        # we create a "projects" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, projectsPath)):
            os.mkdir(os.path.join(path, projectsPath))

        # we create the "prototypes" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, prototypesPath)):
            os.mkdir(os.path.join(path, prototypesPath))
            # we upload in it the default repository file
            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            staticRepositoryPath = os.path.join(os.path.join(ResourcesConfiguration.getStaticResources(), "defaults"), "repository.xml.default")
            shutil.copy(staticRepositoryPath, os.path.join(os.path.join(path, prototypesPath), "repository.xml"))

        # we create the "logging" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, loggingPath)):
            os.mkdir(os.path.join(path, loggingPath))
            # we upload in it the default repository file
            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            staticLoggingPath = os.path.join(os.path.join(ResourcesConfiguration.getStaticResources(), "defaults"), "logging.conf.default")
            shutil.copy(staticLoggingPath, os.path.join(os.path.join(path, loggingPath), "logging.conf"))

        workspace = Workspace(name, datetime.datetime.now(), path, tracesPath, pathOfLogging, prototypesPath)
        workspace.saveConfigFile()

        return workspace
    def applyButton_clicked_cb(self, widget):
        """Callback executed when the user clicks on the apply button"""
        workspacePath = self.getSelectedWorkspace()
        # We verify the workspace can be loaded.
        # if it can, we stop the current GTK
        if workspacePath is None or len(workspacePath) == 0:
            self.setError(_("No workspace provided."))
        else:
            logging.debug("Create the requested workspace")
            try:
                ResourcesConfiguration.createWorkspace(workspacePath)
            except OSError as e:
                self.log.warning(
                    "Impossible to create a workspace : {0}".format(e))
                self.setError("Impossible to create a workspace here.")

                return

            (workspace,
             error) = (Workspace.loadWorkspace(self._selectedWorkspace))
            if workspace is not None:
                # If we managed to load the given workspace, we save it and stop the GTK
                ResourcesConfiguration.generateUserFile(
                    self._selectedWorkspace)
                self.loadedWorkspace = workspace
                self.stop()
            else:
                self.setError(error)
    def applyButton_clicked_cb(self, widget):
        """Callback executed when the user clicks on the apply button"""
        workspacePath = self.getSelectedWorkspace()
        # We verify the workspace can be loaded.
        # if it can, we stop the current GTK
        if workspacePath is None or len(workspacePath) == 0:
            self.setError(_("No workspace provided."))
        else:
            logging.debug("Create the requested workspace")
            try:
                ResourcesConfiguration.createWorkspace(workspacePath)
            except OSError as e:
                self.log.warning("Impossible to create a workspace : {0}".format(e))
                self.setError("Impossible to create a workspace here.")

                return

            (workspace, error) = (Workspace.loadWorkspace(self._selectedWorkspace))
            if workspace is not None:
                # If we managed to load the given workspace, we save it and stop the GTK
                ResourcesConfiguration.generateUserFile(self._selectedWorkspace)
                self.loadedWorkspace = workspace
                self.stop()
            else:
                self.setError(error)
Esempio n. 5
0
    def __init__(self):
        self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
        self.window.set_title(_("Netzob"))
        self.window.set_position(Gtk.WindowPosition.CENTER)
        self.window.set_decorated(False)
        self.window.set_default_size(268, 501)
        self.window.set_events(Gdk.EventMask.ALL_EVENTS_MASK)

        # Retrieve static resources
        staticPath = ResourcesConfiguration.getStaticResources()
        logoPath = os.path.abspath(os.path.join(staticPath, "logo.png"))

        hbox = Gtk.HBox()
        hbox.show()
        self.window.add(hbox)

        self.image = Gtk.Image()
        self.image.set_from_file(logoPath)
        self.image.show()

        main_vbox = Gtk.VBox(False, 1)

#        main_vbox.pack_start(self.image, True, True)

        workspace = ResourcesConfiguration.getWorkspace()
        if workspace is not None:
            self.lbl = Gtk.Label(label=_("Current workspace: {0}".format(workspace)))
        else:
            self.lbl = Gtk.Label(label=_("Current workspace: NO WORKSPACE COMPUTED!"))
        self.lbl.set_alignment(0, 0.5)

        main_vbox.pack_start(self.image, True, True, 2)

        self.window.add(main_vbox)
        self.window.show_all()
    def advancedBugreportingEntry_focus_out_event_cb(self, entry, data):
        """Called on "focus-out" of the API key entry. If its value
        was changed, we can save the new value."""

        if self.keyUpdated:
            apiKey = entry.get_text()
            self.log.info("Saving the new API key: {0}".format(apiKey))
            ResourcesConfiguration.saveAPIKey(apiKey)
            self.keyUpdated = False
    def __init__(self, controller, parent=None):
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                                "ui",
                                                "workspaceConfigurationDialog.glade"))
        self._getObjects(self.builder,
                         ["workspaceConfigurationDialog",
                          "advancedLoggingCombobox",
                          "advancedBugreportingEntry",
                          "advancedBugreportingCheckbox",
                          "advancedBugreportingTestkey",
                          "advancedBugreportingTestkeySpinner",
                          "projectsTreestore1",
                          "projectCurrentName",
                          "projectCurrentDate",
                          "projectCurrentSymbolsCount",
                          "projectCurrentMessagesCount",
                          "projectsDuplicateButton",
                          "projectsDeleteButton",
                          "projectsExportButton",
                          "projectsTreeviewSelection",
                          "projectsConfigureButton",
                          "workspaceConfigurationActionGroup",
                          ])

        self.controller = controller
        self.workspaceConfigurationDialog.set_transient_for(parent)

        # Set combobox to the configured log level
        model = self.advancedLoggingCombobox.get_model()
        treeIter = model.get_iter_first()
        while treeIter is not None:
            if model[treeIter][0] == self.controller._loggingConfiguration.getLoggingLevel():
                self.advancedLoggingCombobox.set_active_iter(treeIter)
                break
            treeIter = model.iter_next(treeIter)

        # Update API key
        key = ResourcesConfiguration.extractAPIKeyDefinitionFromLocalFile()
        self.advancedBugreportingEntry.set_text(key or "")

        # Set the 'enable bug reporting' toggle
        enableBugReporting = controller.workspace.enableBugReporting
        self.advancedBugreportingCheckbox.set_active(enableBugReporting)
        self.refreshEnableBugReporting(enableBugReporting)

        # Updating the "Defined projects" list
        self.refreshProjectList()

        # Getting the popup menu
        self.uiManager = Gtk.UIManager()
        self.uiManager.insert_action_group(self.workspaceConfigurationActionGroup)
        self.uiManager.add_ui_from_file(os.path.join(ResourcesConfiguration.getStaticResources(), "ui", "workspaceConfigurationPopupMenu.ui"))
        self.popup = self.uiManager.get_widget("/PopupMenu")

        # Finally, connect signals to the controller
        self.builder.connect_signals(self.controller)
Esempio n. 8
0
    def _findUiResource(self, resource):
        r = os.path.join(ResourcesConfiguration.getStaticResources(), "ui", resource)
        if os.path.isfile(r):
            return r

        r = os.path.join(ResourcesConfiguration.getPluginsStaticResources(), "ui", resource)
        if os.path.isfile(r):
            return r

        raise NetzobAbstractViewException(_("Requested file ({0}) was not found.").format(resource))
Esempio n. 9
0
    def currentWorkspaceHasChanged(self):
        """currentWorkspaceHasChanged:
        Execute the operations which must be done when
        the current workspace has changed :
        - Update the view,
        - Save the new workspace."""
        if self.controller.getCurrentWorkspace() is not None:
            ResourcesConfiguration.generateUserFile(self.controller.getCurrentWorkspace().getPath(), ResourcesConfiguration.extractAPIKeyDefinitionFromLocalFile())

        self.currentProjectHasChanged()
        self.updateSwitchProjectMenu(self.controller.getCurrentWorkspace().getNameOfProjects())
Esempio n. 10
0
    def _findUiResource(self, resource):
        r = os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         resource)
        if os.path.isfile(r):
            return r

        r = os.path.join(ResourcesConfiguration.getPluginsStaticResources(),
                         "ui", resource)
        if os.path.isfile(r):
            return r

        raise NetzobAbstractViewException(
            _("Requested file ({0}) was not found.").format(resource))
Esempio n. 11
0
    def currentWorkspaceHasChanged(self):
        """currentWorkspaceHasChanged:
        Execute the operations which must be done when
        the current workspace has changed :
        - Update the view,
        - Save the new workspace."""
        if self.controller.getCurrentWorkspace() is not None:
            ResourcesConfiguration.generateUserFile(
                self.controller.getCurrentWorkspace().getPath(),
                ResourcesConfiguration.extractAPIKeyDefinitionFromLocalFile())

        self.currentProjectHasChanged()
        self.updateSwitchProjectMenu(
            self.controller.getCurrentWorkspace().getNameOfProjects())
Esempio n. 12
0
 def _loadActionGroupUIDefinition(self):
     """Loads the action group and the UI definition of menu items
     . This method should only be called in the constructor"""
     # Load actions
     actionsBuilder = Gtk.Builder()
     actionsBuilder.add_from_file(
         os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                      "grammar", "grammarActions.glade"))
     self._actionGroup = actionsBuilder.get_object("grammarActionGroup")
     actionsBuilder.connect_signals(self.controller)
     uiDefinitionFilePath = os.path.join(
         ResourcesConfiguration.getStaticResources(), "ui", "grammar",
         "grammarMenuToolbar.ui")
     with open(uiDefinitionFilePath, "r") as uiDefinitionFile:
         self._uiDefinition = uiDefinitionFile.read()
Esempio n. 13
0
    def loadWorkspace(workspacePath):
        workspaceFile = os.path.join(workspacePath, Workspace.CONFIGURATION_FILENAME)

        # verify we can open and read the file
        if workspaceFile == None:
            logging.warn("The workspace's configuration file can't be find (No workspace path given).")
            return None
        # is the workspaceFile is a file
        if not os.path.isfile(workspaceFile):
            logging.warn("The specified workspace's configuration file (" + str(workspaceFile) + ") is not valid : its not a file.")
            return None
        # is it readable
        if not os.access(workspaceFile, os.R_OK):
            logging.warn("The specified workspace's configuration file (" + str(workspaceFile) + ") is not readable.")
            return None

        # We validate the file given the schemas
        for xmlSchemaFile in Workspace.WORKSPACE_SCHEMAS.keys():
            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            xmlSchemaPath = os.path.join(ResourcesConfiguration.getStaticResources(), xmlSchemaFile)
            # If we find a version which validates the XML, we parse with the associated function
            if Workspace.isSchemaValidateXML(xmlSchemaPath, workspaceFile):
                logging.debug("The file " + str(xmlSchemaPath) + " validates the workspace configuration file.")
                parsingFunc = Workspace.WORKSPACE_SCHEMAS[xmlSchemaFile]
                workspace = parsingFunc(workspacePath, workspaceFile)
                if workspace != None:
                    return workspace
            else:
                logging.fatal("The specified Workspace file is not valid according to the XSD found in %s." % (xmlSchemaPath))

        return None
Esempio n. 14
0
    def __init__(self, controller, idActor):
        '''
        Constructor
        '''
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                                "ui", "simulator",
                                                "createNetworkActor.glade"))
        self._getObjects(self.builder, ["createNetworkActorDialog",
                                        "createButton",
                                        "idEntry",
                                        "nameEntry",
                                        "initiatorCheckButton",
                                        "typeComboBoxText",
                                        "l4ProtocolComboBoxText",
                                        "bindIPEntry",
                                        "bindPortEntry",
                                        "targetIPEntry",
                                        "targetPortEntry",
                                        "errorImage", "errorLabel"])
        self.controller = controller
        self.builder.connect_signals(self.controller)

        self.idEntry.set_text(str(idActor))
        self.idEntry.set_sensitive(False)
Esempio n. 15
0
    def retrieveMessagesFromFiles(self):
        # We read each file and create one message for each file
        self.messages = []
        self.lineView.get_model().clear()

        for file in self.filesToBeImported:

            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            xmlSchemaPath = os.path.join(ResourcesConfiguration.getStaticResources(), "xsds/0.1/common.xsd")
            # If we find a version which validates the XML, we parse with the associated function
            if not Workspace.isSchemaValidateXML(xmlSchemaPath, file):
                logging.error(_("The specified XML file {0} is not valid according to the XSD ({1}).").format(str(file), str(xmlSchemaPath)))
            else:
                logging.debug(_("XML file valid according to the XSD schema"))

                # Parse the XML Document as 0.1 version
                tree = ElementTree()
                tree.parse(file)
                xmlFile = tree.getroot()

                for xmlMessage in xmlFile.findall("{" + Project.COMMON_NAMESPACE + "}message"):
                    message = AbstractMessageFactory.loadFromXML(xmlMessage, Project.COMMON_NAMESPACE, "0.1")
                    logging.debug(_("XML String data: {0}").format(message.getStringData()))
                    self.messages.append(message)
                    self.lineView.get_model().append(None, [str(message.getID()), message.getType(), message.getStringData()])
 def __init__(self, controller):
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(
             ResourcesConfiguration.getStaticResources(),
             "ui",
             "vocabulary",
             "customTransformationFunctionDialog.glade",
         )
     )
     self._getObjects(
         self.builder,
         [
             "customTransformationFunctionDialog",
             "imageError",
             "imageValid",
             "cancelButton",
             "applyButton",
             "nameOfFunctionEntry",
             "labelMessage",
             "functionReverseTextView",
             "sourceCodeIsTheSameForReverseCheckButton",
             "functionTextView",
             "messagesListStore",
             "scrolledwindow3",
         ],
     )
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 17
0
    def renameLayer_cb(self, widget):
        builder2 = Gtk.Builder()
        builder2.add_from_file(
            os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         "dialogbox.glade"))

        dialog = builder2.get_object("renamelayer")
        dialog.set_title(
            _("Rename the layer {0}").format(self.layers[0].getName()))

        applybutton = builder2.get_object("button10")
        entry = builder2.get_object("entry3")
        entry.connect("changed", self.entry_disableButtonIfEmpty_cb,
                      applybutton)

        result = dialog.run()

        if (result == 0):
            newLayerName = entry.get_text()
            self.log.debug("Renamed layer {0} to {1}".format(
                self.layers[0].getName(), newLayerName))
            currentProject = self.vocabularyController.netzob.getCurrentProject(
            )
            currentProject.getVocabulary().getFieldByID(
                self.layers[0].getID()).setName(newLayerName)
            self.vocabularyController.view.updateLeftPanel()
            self.vocabularyController.view.updateSelectedMessageTable()
            dialog.destroy()

        dialog.destroy()
Esempio n. 18
0
    def loadProject(workspace, projectDirectory):
        projectFile = os.path.join(os.path.join(workspace.getPath(), projectDirectory), Project.CONFIGURATION_FILENAME)

        # verify we can open and read the file
        if projectFile == None:
            return None
        # is the projectFile is a file
        if not os.path.isfile(projectFile):
            logging.warn("The specified project's configuration file (" + str(projectFile) + ") is not valid : its not a file.")
            return None
        # is it readable
        if not os.access(projectFile, os.R_OK):
            logging.warn("The specified project's configuration file (" + str(projectFile) + ") is not readable.")
            return None

        # We validate the file given the schemas
        for xmlSchemaFile in Project.PROJECT_SCHEMAS.keys():
            xmlSchemaPath = os.path.join(ResourcesConfiguration.getStaticResources(), xmlSchemaFile)
            # If we find a version which validates the XML, we parse with the associated function
            if Project.isSchemaValidateXML(xmlSchemaPath, projectFile):
                logging.debug("The file " + str(projectFile) + " validates the project configuration file.")
                parsingFunc = Project.PROJECT_SCHEMAS[xmlSchemaFile]
                project = parsingFunc(projectFile)
                if project != None:
                    logging.info("Loading project '" + str(project.getName()) + "' from workspace.")
                    return project
            else:
                logging.warn("The project declared in file (" + projectFile + ") is not valid")
        return None
Esempio n. 19
0
    def getNameOfProject(workspace, projectDirectory):
        projectFile = os.path.join(os.path.join(workspace.getPath(), projectDirectory), Project.CONFIGURATION_FILENAME)

        # verify we can open and read the file
        if projectFile == None:
            return None
        # is the projectFile is a file
        if not os.path.isfile(projectFile):
            logging.warn("The specified project's configuration file (" + str(projectFile) + ") is not valid : its not a file.")
            return None
        # is it readable
        if not os.access(projectFile, os.R_OK):
            logging.warn("The specified project's configuration file (" + str(projectFile) + ") is not readable.")
            return None

        # We validate the file given the schemas
        for xmlSchemaFile in Project.PROJECT_SCHEMAS.keys():
            xmlSchemaPath = os.path.join(ResourcesConfiguration.getStaticResources(), xmlSchemaFile)
            # If we find a version which validates the XML, we parse with the associated function
            if Project.isSchemaValidateXML(xmlSchemaPath, projectFile):
                logging.debug("The file " + str(projectFile) + " validates the project configuration file.")
                tree = ElementTree()
                tree.parse(projectFile)
                xmlProject = tree.getroot()
                # Register the namespace
                etree.register_namespace('netzob', PROJECT_NAMESPACE)
                etree.register_namespace('netzob-common', COMMON_NAMESPACE)

                projectName = xmlProject.get('name', 'none')

                if projectName != None and projectName != 'none':
                    return projectName
            else:
                logging.warn("The project declared in file (" + projectFile + ") is not valid")
        return None
    def __init__(self, controller):
        '''
        Constructor
        '''
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                                "ui", "vocabulary",
                                                "environmentDependenciesSearcherView.glade"))
        self._getObjects(self.builder, ["envDepsSearcherDialog",
                                        "cancelButton",
                                        "executeButton",
                                        "searchProgressBar",
                                        "envDependenciesListstore"
                                        ])
        self.controller = controller
        self.builder.connect_signals(self.controller)
        self.cancelButton.set_sensitive(True)

        # Update the list store of env. dependencies
        currentProject = self.controller.vocabularyController.getCurrentProject()
        envDeps = []
        if currentProject is not None:
            envDeps.extend(currentProject.getEnvironmentDependencies())

        # Search in the same time all the applicative data in the project
        appData = currentProject.getApplicativeData()
        for data in appData:
            envDeps.append(Property(data.getName(), data.getType(), data.getValue()))

        for envDep in envDeps:
            i = self.envDependenciesListstore.append()
            self.envDependenciesListstore.set(i, 0, str(envDep.getCurrentValue()))
            self.envDependenciesListstore.set(i, 1, str(envDep.getName()))
            self.envDependenciesListstore.set(i, 2, str(envDep.getFormat()))
    def __init__(self, controller, idTransition):
        '''
        Constructor
        '''
        self.builder = Gtk.Builder()
        self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                                "ui", "grammar",
                                                "createCloseChannelTransition.glade"))
        self._getObjects(self.builder, ["createCloseChannelTransitionDialog",
                                        "createButton", "cancelButton",
                                        "idEntry", "nameEntry", "timeEntry",
                                        "startStateComboBox", "endStateComboBox",
                                        "stateListStore",
                                        "errorImage", "errorLabel"])
        self.controller = controller
        self.builder.connect_signals(self.controller)

        self.idEntry.set_text(str(idTransition))
        self.idEntry.set_sensitive(False)

        currentProject = self.controller.grammarController.getCurrentProject()

        # Retrieve the states and symbols of the current project
        states = []
        if currentProject is not None:
            automata = currentProject.getGrammar().getAutomata()
            if automata is not None:
                states.extend(automata.getStates())

        self.stateListStore.clear()
        # Configure the list of states
        for state in states:
            i = self.stateListStore.append()
            self.stateListStore.set(i, 0, str(state.getID()))
            self.stateListStore.set(i, 1, state.getName())
Esempio n. 22
0
 def __init__(self, controller):
     """
     Constructor
     """
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(
             ResourcesConfiguration.getStaticResources(),
             "ui",
             "vocabulary",
             "partitioning",
             "forcePartitioning.glade",
         )
     )
     self._getObjects(
         self.builder,
         [
             "forceDialog",
             "force_execute",
             "force_stop",
             "force_cancel",
             "force_entry",
             "force_radiobutton_hexa",
             "force_radiobutton_string",
             "force_progressbar",
         ],
     )
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 23
0
    def __init__(self, controller, gladeFileName):

        self.controller = controller
        self.builderWidget = Gtk.Builder()
        gladePath = os.path.join(ResourcesConfiguration.getStaticResources(), "ui", "Variables", gladeFileName)
        self.builderWidget.add_from_file(gladePath)
        self.widgDict = dict()
    def renameLayer_cb(self, widget):
        builder2 = Gtk.Builder()
        builder2.add_from_file(os.path.join(
            ResourcesConfiguration.getStaticResources(),
            "ui",
            "dialogbox.glade"))

        dialog = builder2.get_object("renamelayer")
        dialog.set_title(_("Rename the layer {0}").format(self.layers[0].getName()))

        applybutton = builder2.get_object("button10")
        entry = builder2.get_object("entry3")
        entry.connect("changed", self.entry_disableButtonIfEmpty_cb, applybutton)

        result = dialog.run()

        if (result == 0):
            newLayerName = entry.get_text()
            self.log.debug("Renamed layer {0} to {1}".format(self.layers[0].getName(), newLayerName))
            currentProject = self.vocabularyController.netzob.getCurrentProject()
            currentProject.getVocabulary().getFieldByID(self.layers[0].getID()).setName(newLayerName)
            self.vocabularyController.view.updateLeftPanel()
            self.vocabularyController.view.updateSelectedMessageTable()
            dialog.destroy()

        dialog.destroy()
Esempio n. 25
0
    def loadProjectFromFile(projectFile):
        # verify we can open and read the file
        if projectFile is None:
            return None
        # is the projectFile is a file
        if not os.path.isfile(projectFile):
            logging.warn(
                "The specified project's configuration file ({0}) is not valid: its not a file.".format(projectFile)
            )
            return None
        # is it readable
        if not os.access(projectFile, os.R_OK):
            logging.warn("The specified project's configuration file ({0}) is not readable.".format(projectFile))
            return None

        # We validate the file given the schemas
        for xmlSchemaFile in Project.PROJECT_SCHEMAS.keys():
            xmlSchemaPath = os.path.join(ResourcesConfiguration.getStaticResources(), xmlSchemaFile)
            # If we find a version which validates the XML, we parse with the associated function
            if Project.isSchemaValidateXML(xmlSchemaPath, projectFile):
                parsingFunc = Project.PROJECT_SCHEMAS[xmlSchemaFile]
                project = parsingFunc(projectFile)
                if project is not None:
                    logging.info("Loading project '{0}' from workspace.".format(project.getName()))
                    return project
            else:
                logging.warn("The project declared in file ({0}) is not valid".format(projectFile))
        return None
Esempio n. 26
0
    def createSymbolButton_clicked_cb(self, toolButton):
        if self.getCurrentProject() is None:
            NetzobErrorMessage(_("No project selected."))
            return

        builder2 = Gtk.Builder()
        builder2.add_from_file(
            os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         "dialogbox.glade"))
        dialog = builder2.get_object("createsymbol")
        dialog.set_transient_for(self.netzob.view.mainWindow)

        # Disable apply button if no text
        applybutton = builder2.get_object("button1")
        entry = builder2.get_object("entry1")
        entry.connect("changed", self.entry_disableButtonIfEmpty_cb,
                      applybutton)

        result = dialog.run()

        if (result == 0):
            newSymbolName = entry.get_text()
            newSymbolId = str(uuid.uuid4())
            self.log.debug(
                "A new symbol will be created with the given name: {0}".format(
                    newSymbolName))
            currentProject = self.netzob.getCurrentProject()
            newSymbol = Symbol(newSymbolId, newSymbolName, currentProject)
            currentProject.getVocabulary().addSymbol(newSymbol)
            self.view.updateLeftPanel()
            dialog.destroy()
        if (result == 1):
            dialog.destroy()
Esempio n. 27
0
    def createSymbolButton_clicked_cb(self, toolButton):
        if self.getCurrentProject() is None:
            NetzobErrorMessage(_("No project selected."))
            return

        builder2 = Gtk.Builder()
        builder2.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(), "ui", "dialogbox.glade"))
        dialog = builder2.get_object("createsymbol")
        dialog.set_transient_for(self.netzob.view.mainWindow)

        # Disable apply button if no text
        applybutton = builder2.get_object("button1")
        entry = builder2.get_object("entry1")
        entry.connect("changed", self.entry_disableButtonIfEmpty_cb, applybutton)

        result = dialog.run()

        if (result == 0):
            newSymbolName = entry.get_text()
            newSymbolId = str(uuid.uuid4())
            self.log.debug("A new symbol will be created with the given name: {0}".format(newSymbolName))
            currentProject = self.netzob.getCurrentProject()
            newSymbol = Symbol(newSymbolId, newSymbolName, currentProject)
            currentProject.getVocabulary().addSymbol(newSymbol)
            self.view.updateLeftPanel()
            dialog.destroy()
        if (result == 1):
            dialog.destroy()
Esempio n. 28
0
    def __init__(self, controller, state):
        '''
        Constructor
        '''
        self.builder = Gtk.Builder()
        self.builder.add_from_file(
            os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         "grammar", "createStateDialog.glade"))
        self._getObjects(self.builder, [
            "createStateDialog", "createButton", "cancelButton", "idEntry",
            "nameEntry", "initialStateCheckButton", "errorImage", "errorLabel",
            "titleLabel"
        ])
        self.controller = controller
        self.builder.connect_signals(self.controller)

        self.titleLabel.set_label(_("Edit the state"))

        isInitialState = False
        automata = controller.grammarController.getCurrentProject().getGrammar(
        ).getAutomata()
        initialState = automata.getInitialState()

        if str(initialState.getID()) == str(state.getID()):
            isInitialState = True

        self.idEntry.set_text(str(state.getID()))
        self.idEntry.set_sensitive(False)

        self.nameEntry.set_text(state.getName())
        self.initialStateCheckButton.set_active(isInitialState)
Esempio n. 29
0
    def isFolderAValidWorkspace(workspacePath):
        """Computes if the provided folder
        represents a valid (and loadable) workspace
        @return: None if the workspace is loadable or the error message if not valid
        """
        if workspacePath is None:
            return _("The workspace's path ({0}) is incorrect.".format(workspacePath))
        workspaceFile = os.path.join(workspacePath, Workspace.CONFIGURATION_FILENAME)

        # verify we can open and read the file
        if workspaceFile is None:
            return _("The workspace's configuration file can't be find (No workspace path given).")
        # is the workspaceFile is a file
        if not os.path.isfile(workspaceFile):
            return _("The specified workspace's configuration file ({0}) is not valid: its not a file.".format(workspaceFile))
        # is it readable
        if not os.access(workspaceFile, os.R_OK):
            return _("The specified workspace's configuration file ({0}) is not readable.".format(workspaceFile))

        for xmlSchemaFile in Workspace.WORKSPACE_SCHEMAS.keys():
            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            xmlSchemaPath = os.path.join(ResourcesConfiguration.getStaticResources(), xmlSchemaFile)
            # If we find a version which validates the XML, we parse with the associated function
            if Workspace.isSchemaValidateXML(xmlSchemaPath, workspaceFile):
                return None
        return _("The specified workspace is not valid according to the XSD definitions.")
Esempio n. 30
0
    def loadProjectFromFile(projectFile):
        # verify we can open and read the file
        if projectFile is None:
            return None
        # is the projectFile is a file
        if not os.path.isfile(projectFile):
            logging.warn(
                "The specified project's configuration file ({0}) is not valid: its not a file."
                .format(projectFile))
            return None
        # is it readable
        if not os.access(projectFile, os.R_OK):
            logging.warn(
                "The specified project's configuration file ({0}) is not readable."
                .format(projectFile))
            return None

        # We validate the file given the schemas
        for xmlSchemaFile in Project.PROJECT_SCHEMAS.keys():
            xmlSchemaPath = os.path.join(
                ResourcesConfiguration.getStaticResources(), xmlSchemaFile)
            # If we find a version which validates the XML, we parse with the associated function
            if Project.isSchemaValidateXML(xmlSchemaPath, projectFile):
                parsingFunc = Project.PROJECT_SCHEMAS[xmlSchemaFile]
                project = parsingFunc(projectFile)
                if project is not None:
                    logging.info(
                        "Loading project '{0}' from workspace.".format(
                            project.getName()))
                    return project
            else:
                logging.warn(
                    "The project declared in file ({0}) is not valid".format(
                        projectFile))
        return None
Esempio n. 31
0
    def loadWorkspace(workspacePath):
        """Load the workspace declared in the
        provided directory
        @type workspacePath: str
        @var workspacePath: folder to load as a workspace
        @return a tupple with the workspace or None if not valid and the error message"""

        errorMessage = Workspace.isFolderAValidWorkspace(workspacePath)
        if errorMessage is not None:
            logging.warn(errorMessage)
            return (None, errorMessage)

        workspaceFile = os.path.join(workspacePath, Workspace.CONFIGURATION_FILENAME)
        logging.debug("  Workspace configuration file found: " + str(workspaceFile))
        # We validate the file given the schemas
        for xmlSchemaFile in Workspace.WORKSPACE_SCHEMAS.keys():
            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            xmlSchemaPath = os.path.join(ResourcesConfiguration.getStaticResources(), xmlSchemaFile)
            # If we find a version which validates the XML, we parse with the associated function
            if Workspace.isSchemaValidateXML(xmlSchemaPath, workspaceFile):
                logging.debug("  Workspace configuration file " + str(workspaceFile) + " is valid against XSD scheme " + str(xmlSchemaPath))
                parsingFunc = Workspace.WORKSPACE_SCHEMAS[xmlSchemaFile]
                workspace = parsingFunc(workspacePath, workspaceFile)
                if workspace is not None:
                    return (workspace, None)
            else:
                logging.fatal("The specified Workspace file is not valid according to the XSD found in %s." % (xmlSchemaPath))

        return (None, _("An unknown error prevented to open the workspace."))
    def __init__(self, controller, idTransition):
        '''
        Constructor
        '''
        self.builder = Gtk.Builder()
        self.builder.add_from_file(
            os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         "grammar", "createCloseChannelTransition.glade"))
        self._getObjects(self.builder, [
            "createCloseChannelTransitionDialog", "createButton",
            "cancelButton", "idEntry", "nameEntry", "timeEntry",
            "startStateComboBox", "endStateComboBox", "stateListStore",
            "errorImage", "errorLabel"
        ])
        self.controller = controller
        self.builder.connect_signals(self.controller)

        self.idEntry.set_text(str(idTransition))
        self.idEntry.set_sensitive(False)

        currentProject = self.controller.grammarController.getCurrentProject()

        # Retrieve the states and symbols of the current project
        states = []
        if currentProject is not None:
            automata = currentProject.getGrammar().getAutomata()
            if automata is not None:
                states.extend(automata.getStates())

        self.stateListStore.clear()
        # Configure the list of states
        for state in states:
            i = self.stateListStore.append()
            self.stateListStore.set(i, 0, str(state.getID()))
            self.stateListStore.set(i, 1, state.getName())
Esempio n. 33
0
    def __init__(self, controller, gladeFileName):

        self.controller = controller
        self.builderWidget = Gtk.Builder()
        gladePath = os.path.join(ResourcesConfiguration.getStaticResources(),
                                 "ui", "Variables", gladeFileName)
        self.builderWidget.add_from_file(gladePath)
        self.widgDict = dict()
Esempio n. 34
0
    def _initResourcesAndLocales(self):
        # Initialize resources
        logging.debug("+ Initialize resources...")
        if not ResourcesConfiguration.initializeResources():
            logging.fatal("Error while configuring the resources of Netzob")
            sys.exit()

        # Initialiaze gettext
        gettext.bindtextdomain("netzob", ResourcesConfiguration.getLocaleLocation())
        gettext.textdomain("netzob")
        locale.bindtextdomain("netzob", ResourcesConfiguration.getLocaleLocation())
        locale.textdomain("netzob")
        try:
            locale.getlocale()
        except:
            logging.exception("setlocale failed, resetting to C")
            locale.setlocale(locale.LC_ALL, "C")
Esempio n. 35
0
 def _loadActionGroupUIDefinition(self):
     """Loads the action group and the UI definition of menu items
     . This method should only be called in the constructor"""
     # Load actions
     actionsBuilder = Gtk.Builder()
     actionsBuilder.add_from_file(os.path.join(
         ResourcesConfiguration.getStaticResources(),
         "ui", "grammar",
         "grammarActions.glade"))
     self._actionGroup = actionsBuilder.get_object("grammarActionGroup")
     actionsBuilder.connect_signals(self.controller)
     uiDefinitionFilePath = os.path.join(
         ResourcesConfiguration.getStaticResources(),
         "ui", "grammar",
         "grammarMenuToolbar.ui")
     with open(uiDefinitionFilePath, "r") as uiDefinitionFile:
         self._uiDefinition = uiDefinitionFile.read()
Esempio n. 36
0
    def _initResourcesAndLocales(self):
        # Initialize resources
        logging.debug("+ Initialize resources...")
        if not ResourcesConfiguration.initializeResources():
            logging.fatal("Error while configuring the resources of Netzob")
            sys.exit()

        # Initialiaze gettext
        gettext.bindtextdomain("netzob", ResourcesConfiguration.getLocaleLocation())
        gettext.textdomain("netzob")
        locale.bindtextdomain("netzob", ResourcesConfiguration.getLocaleLocation())
        locale.textdomain("netzob")
        try:
            locale.getlocale()
        except:
            logging.exception("setlocale failed, resetting to C")
            locale.setlocale(locale.LC_ALL, "C")
Esempio n. 37
0
    def createWorkspace(name, path):
        tracesPath = "traces"
        projectsPath = "projects"
        prototypesPath = "prototypes"
        loggingPath = "logging"
        pathOfLogging = "logging/logging.conf"

        # we create a "traces" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, tracesPath)):
            os.mkdir(os.path.join(path, tracesPath))

        # we create a "projects" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, projectsPath)):
            os.mkdir(os.path.join(path, projectsPath))

        # we create the "prototypes" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, prototypesPath)):
            os.mkdir(os.path.join(path, prototypesPath))
            # we upload in it the default repository file
            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            staticRepositoryPath = os.path.join(
                os.path.join(ResourcesConfiguration.getStaticResources(),
                             "defaults"), "repository.xml.default")
            shutil.copy(
                staticRepositoryPath,
                os.path.join(os.path.join(path, prototypesPath),
                             "repository.xml"))

        # we create the "logging" directory if it doesn't yet exist
        if not os.path.isdir(os.path.join(path, loggingPath)):
            os.mkdir(os.path.join(path, loggingPath))
            # we upload in it the default repository file
            from netzob.Common.ResourcesConfiguration import ResourcesConfiguration
            staticLoggingPath = os.path.join(
                os.path.join(ResourcesConfiguration.getStaticResources(),
                             "defaults"), "logging.conf.default")
            shutil.copy(
                staticLoggingPath,
                os.path.join(os.path.join(path, loggingPath), "logging.conf"))

        workspace = Workspace(name, datetime.datetime.now(), path, tracesPath,
                              pathOfLogging, prototypesPath)
        workspace.saveConfigFile()

        return workspace
Esempio n. 38
0
    def __init__(self):
        self.apiKey = ResourcesConfiguration.extractAPIKeyDefinitionFromLocalFile()
        self.disableRemoteCertificateVerification = False

        self.targetBugReport = "{0}/projects/{1}".format(BugReporter.URL_TARGET_BUG_REPORT, BugReporter.PROJECT_NAME_BUG_REPORT)

        self.log = logging.getLogger(__name__)
        self.customFieldSHA2ID = "5"
        self.currentReport = None
Esempio n. 39
0
 def __init__(self, controller):
     self.builder = Gtk.Builder()
     self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                             "ui", "vocabulary", "partitioning",
                                             "resetPartitioning.glade"))
     self._getObjects(self.builder, ["resetDialog",
                                     "reset_execute", "reset_stop", "reset_cancel",
                                     "reset_progressbar"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 40
0
 def addIconToFactory(iconStockID, iconFilename):
     iconSet = Gtk.IconSet()
     iconSource = Gtk.IconSource()
     iconPath = os.path.abspath(
         os.path.join(ResourcesConfiguration.getStaticResources(), "icons",
                      "24x24", iconFilename))
     iconSource.set_filename(iconPath)
     iconSource.set_size(Gtk.IconSize.LARGE_TOOLBAR)
     iconSet.add_source(iconSource)
     netzobIconFactory.add(iconStockID, iconSet)
Esempio n. 41
0
 def __init__(self, controller):
     self.builder = Gtk.Builder()
     self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                             "ui", "vocabulary",
                                             "moveMessageDialog.glade"))
     self._getObjects(self.builder, ["moveMessageDialog",
                                     "moveMessageMoveAndForgetRadioButton", "moveMessageMoveAndReComputeRadioButton",
                                     "moveMessageMoveInTrashRadioButton"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 42
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(os.path.join(
         ResourcesConfiguration.getStaticResources(),
         "ui", "vocabulary", "splitFieldDialog.glade"))
     self._getObjects(self.builder, ["splitFieldDialog", "buffer", "splitPositionAdjustment", "bufferHAdjustment", "scale1"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
 def __init__(self, controller):
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                      "dialogbox.glade"))
     self._getObjects(self.builder, [
         "certificateError", "certificateErrorApplyButton",
         "certificateErrorCancelButton", "certificateErrorTextView"
     ])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 44
0
    def __init__(self):
        self.apiKey = ResourcesConfiguration.extractAPIKeyDefinitionFromLocalFile(
        )
        self.disableRemoteCertificateVerification = False

        self.targetBugReport = "{0}/projects/{1}".format(
            BugReporter.URL_TARGET_BUG_REPORT,
            BugReporter.PROJECT_NAME_BUG_REPORT)

        self.log = logging.getLogger(__name__)
        self.customFieldSHA2ID = "5"
        self.currentReport = None
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(os.path.join(
         ResourcesConfiguration.getStaticResources(),
         "ui", "vocabulary",
         "messageDistributionDialog.glade"))
     self._getObjects(self.builder, ["messageDistributionDialog", "closeButton"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 46
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(os.path.join(
         ResourcesConfiguration.getStaticResources(),
         "ui", "vocabulary",
         "editFieldDialog.glade"))
     self._getObjects(self.builder, ["dialog", "fieldName", "description", "regex"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 47
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(os.path.join(
         ResourcesConfiguration.getStaticResources(),
         "ui", "vocabulary", "filterMessagesBar.glade"))
     self._getObjects(self.builder, ["filterBar", "filter_entry", "numberOfResultLabel",
                                     "filter_close"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 48
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                      "vocabulary", "filterMessagesBar.glade"))
     self._getObjects(self.builder, [
         "filterBar", "filter_entry", "numberOfResultLabel", "filter_close"
     ])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 49
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                      "vocabulary", "fieldAnalysis.glade"))
     self._getObjects(
         self.builder,
         ["dialog", "fieldName", "domainListstore", "typeListstore"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 50
0
    def loadBaseMenuBarAndToolbar(self):
        # Load actions
        mainActionsBuilder = Gtk.Builder()
        mainActionsBuilder.add_from_file(
            os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         "mainActions.glade"))
        mainActionsBuilder.connect_signals(self.controller)
        self.mainActionGroup = mainActionsBuilder.get_object("mainActionGroup")
        # Load menu bar and toolbar UI definitions
        self.uiManager = Gtk.UIManager()
        self.uiManager.insert_action_group(self.mainActionGroup)
        self.uiManager.add_ui_from_file(
            os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                         "mainMenuToolbar.ui"))
        mainToolbar = self.uiManager.get_widget("/mainToolbar")
        mainToolbar.set_icon_size(Gtk.IconSize.LARGE_TOOLBAR)
        self.setPrimaryToolbarStyle(mainToolbar)
        self.setMenuBar(self.uiManager.get_widget("/mainMenuBar"))
        self.setToolbar(mainToolbar)

        # Add accel group to window
        self.mainWindow.add_accel_group(self.uiManager.get_accel_group())
Esempio n. 51
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                      "vocabulary", "splitFieldDialog.glade"))
     self._getObjects(self.builder, [
         "splitFieldDialog", "buffer", "splitPositionAdjustment",
         "bufferHAdjustment", "scale1"
     ])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 52
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                      "vocabulary", "relationsView.glade"))
     self._getObjects(self.builder, [
         "relationsDialog", "relationsViewport", "relationsCancelButton",
         "relationsApplyButton"
     ])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 53
0
    def __init__(self):
        self.window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
        self.window.set_title(_("Netzob"))
        self.window.set_position(Gtk.WindowPosition.CENTER)
        self.window.set_decorated(False)
        self.window.set_default_size(268, 501)
        self.window.set_events(Gdk.EventMask.ALL_EVENTS_MASK)

        # Retrieve static resources
        staticPath = ResourcesConfiguration.getStaticResources()
        logoPath = os.path.abspath(os.path.join(staticPath, "logo.png"))

        hbox = Gtk.HBox()
        hbox.show()
        self.window.add(hbox)

        self.image = Gtk.Image()
        self.image.set_from_file(logoPath)
        self.image.show()

        main_vbox = Gtk.VBox(False, 1)

        #        main_vbox.pack_start(self.image, True, True)

        workspace = ResourcesConfiguration.getWorkspace()
        if workspace is not None:
            self.lbl = Gtk.Label(
                label=_("Current workspace: {0}".format(workspace)))
        else:
            self.lbl = Gtk.Label(
                label=_("Current workspace: NO WORKSPACE COMPUTED!"))
        self.lbl.set_alignment(0, 0.5)

        main_vbox.pack_start(self.image, True, True, 2)

        self.window.add(main_vbox)
        self.window.show_all()
Esempio n. 54
0
    def newProject_activate_cb(self, action):
        """Display the dialog in order to create a new project when
        the user request it through the menu."""

        finish = False
        errorMessage = None

        while not finish:
            # open Dialogbox
            builder2 = Gtk.Builder()
            builder2.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(), "ui", "dialogbox.glade"))
            dialog = builder2.get_object("newProject")
            dialog.set_transient_for(self.view.mainWindow)

            applybutton = builder2.get_object("newProjectApplyButton")
            entry = builder2.get_object("entry4")
            entry.connect("changed", self.entry_disableButtonIfEmpty_cb, applybutton)

            if errorMessage is not None:
                # Display a warning message on the dialog box
                warnLabel = builder2.get_object("NewProjectWarnLabel")
                warnLabel.set_text(errorMessage)
                warnBox = builder2.get_object("newProjectWarnBox")
                warnBox.show_all()

            # Run the dialog window and wait for the result
            result = dialog.run()

            if result == 0:
                newProjectName = entry.get_text()
                dialog.destroy()
                self.log.debug("Verify the uniqueness of project name: {0}".format(newProjectName))
                found = False
                for (projectName, projectPath) in self.currentWorkspace.getNameOfProjects():
                    if projectName == newProjectName:
                        found = True
                        break
                if found:
                    self.log.info("A project with the same name already exists ({0}, {1}), please change it.".format(projectName, projectPath))
                    errorMessage = _("A project with this name exists")
                else:
                    self.log.debug("Create new project {0}".format(newProjectName))
                    newProject = Project.createProject(self.getCurrentWorkspace(), newProjectName)
                    self.switchProject(newProject.getPath())
                    finish = True
                    errorMessage = None
            else:
                dialog.destroy()
                finish = True
Esempio n. 55
0
 def __init__(self, controller):
     '''
     Constructor
     '''
     self.builder = Gtk.Builder()
     self.builder.add_from_file(os.path.join(ResourcesConfiguration.getStaticResources(),
                                             "ui", "vocabulary", "partitioning",
                                             "forcePartitioning.glade"))
     self._getObjects(self.builder, ["forceDialog",
                                     "force_execute", "force_stop", "force_cancel",
                                     "force_entry",
                                     "force_radiobutton_hexa", "force_radiobutton_string",
                                     "force_progressbar"])
     self.controller = controller
     self.builder.connect_signals(self.controller)
Esempio n. 56
0
 def __init__(self, controller, parent=None):
     self.builder = Gtk.Builder()
     self.builder.add_from_file(
         os.path.join(ResourcesConfiguration.getStaticResources(), "ui",
                      "dialogbox.glade"))
     self._getObjects(self.builder, [
         "bugReporter", "bugTrackerEntry", "bugReporterApiKeyEntry",
         "reportTextView", "bugReporterSaveButton",
         "bugReporterCancelButton", "bugReporterMessageBox",
         "bugReporterInfoImg", "bugReporterWarnImg", "bugReporterWarnLabel",
         "bugReporterRememberAPIKeyCheckButton"
     ])
     self.controller = controller
     self.builder.connect_signals(self.controller)
     self.bugReporter.set_transient_for(parent)