• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python ResourcesConfiguration.ResourcesConfiguration类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: loadWorkspace

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


示例17: __init__

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


示例18: createSymbolButton_clicked_cb

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


示例19: isFolderAValidWorkspace

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


示例20: loadProjectFromFile

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python TypeConvertor.TypeConvertor类代码示例发布时间:2022-05-27
下一篇:
Python TypeConverter.TypeConverter类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap