当前位置: 首页>>代码示例>>Python>>正文


Python ResourcesConfiguration.ResourcesConfiguration类代码示例

本文整理汇总了Python中netzob.Common.ResourcesConfiguration.ResourcesConfiguration的典型用法代码示例。如果您正苦于以下问题:Python ResourcesConfiguration类的具体用法?Python ResourcesConfiguration怎么用?Python ResourcesConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ResourcesConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: createDefault

    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
开发者ID:KurSh,项目名称:netzob,代码行数:27,代码来源:ConfigurationParser.py

示例2: __init__

    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()
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:35,代码来源:SplashScreen.py

示例3: createWorkspace

    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
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:35,代码来源:Workspace.py

示例4: applyButton_clicked_cb

    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)
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:25,代码来源:WorkspaceSelectorController.py

示例5: __init__

    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)
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:57,代码来源:WorkspaceConfigurationView.py

示例6: _findUiResource

    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))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:10,代码来源:NetzobAbstractView.py

示例7: currentWorkspaceHasChanged

    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())
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:11,代码来源:NetzobMainView.py

示例8: __init__

 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)
开发者ID:sangyf,项目名称:netzob,代码行数:29,代码来源:CustomTransformationFunctionView.py

示例9: loadProject

    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
开发者ID:KurSh,项目名称:netzob,代码行数:29,代码来源:Project.py

示例10: getNameOfProject

    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
开发者ID:KurSh,项目名称:netzob,代码行数:35,代码来源:Project.py

示例11: loadWorkspace

    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
开发者ID:KurSh,项目名称:netzob,代码行数:31,代码来源:Workspace.py

示例12: retrieveMessagesFromFiles

    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()])
开发者ID:KurSh,项目名称:netzob,代码行数:25,代码来源:XMLImport.py

示例13: __init__

    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)
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:25,代码来源:CreateNetworkActorView.py

示例14: renameLayer_cb

    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()
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:26,代码来源:ContextualMenuOnLayerController.py

示例15: __init__

    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()))
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:34,代码来源:EnvironmentDependenciesSearcherView.py


注:本文中的netzob.Common.ResourcesConfiguration.ResourcesConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。