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


Python ResourcesConfiguration.getStaticResources方法代码示例

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


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

示例1: createWorkspace

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:37,代码来源:Workspace.py

示例2: __init__

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:59,代码来源:WorkspaceConfigurationView.py

示例3: __init__

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:36,代码来源:EnvironmentDependenciesSearcherView.py

示例4: getNameOfProject

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:37,代码来源:Project.py

示例5: loadWorkspace

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:33,代码来源:Workspace.py

示例6: retrieveMessagesFromFiles

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:27,代码来源:XMLImport.py

示例7: __init__

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:27,代码来源:CreateNetworkActorView.py

示例8: loadProject

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:31,代码来源:Project.py

示例9: __init__

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
 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,代码行数:31,代码来源:ForcePartitioningView.py

示例10: renameLayer_cb

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:28,代码来源:ContextualMenuOnLayerController.py

示例11: __init__

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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())
开发者ID:EnjoyHacking,项目名称:netzob,代码行数:37,代码来源:CreateCloseChannelTransitionView.py

示例12: loadWorkspace

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:31,代码来源:Workspace.py

示例13: isFolderAValidWorkspace

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:28,代码来源:Workspace.py

示例14: loadProjectFromFile

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:30,代码来源:Project.py

示例15: createSymbolButton_clicked_cb

# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getStaticResources [as 别名]
    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,代码行数:30,代码来源:VocabularyController.py


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