本文整理汇总了Python中netzob.Common.ResourcesConfiguration.ResourcesConfiguration.getWorkspaceFile方法的典型用法代码示例。如果您正苦于以下问题:Python ResourcesConfiguration.getWorkspaceFile方法的具体用法?Python ResourcesConfiguration.getWorkspaceFile怎么用?Python ResourcesConfiguration.getWorkspaceFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类netzob.Common.ResourcesConfiguration.ResourcesConfiguration
的用法示例。
在下文中一共展示了ResourcesConfiguration.getWorkspaceFile方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createDefault
# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getWorkspaceFile [as 别名]
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
示例2: test_workspaceParsing
# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getWorkspaceFile [as 别名]
def test_workspaceParsing(self):
# We first load the workspace
workspace = Workspace.loadWorkspace(ResourcesConfiguration.getWorkspaceFile())
self.assertNotEqual(workspace, None)
# Now we load all the project which are declared in
for project_path in workspace.getProjectsPath() :
project = Project.loadProject(workspace, project_path)
if project != None :
logging.info("The project " + project.getName() + " has been loaded !")
示例3: __init__
# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getWorkspaceFile [as 别名]
def __init__(self):
self.configurationFilePath = os.path.join(ResourcesConfiguration.getWorkspaceFile(), ResourcesConfiguration.CONFFILE)
# If the config file exists we parse it
# if not we create an in-memory default one
if self.configurationFilePath == None or not os.path.isfile(self.configurationFilePath):
# create default in memory file
self.config = ConfigurationParser.createDefault()
self.config.write(open(self.configurationFilePath, "w"))
else:
# Configure the configuration parser
self.config = ConfigParser.ConfigParser()
# Parse the configuration file
self.config.read(self.configurationFilePath)
示例4: __init__
# 需要导入模块: from netzob.Common.ResourcesConfiguration import ResourcesConfiguration [as 别名]
# 或者: from netzob.Common.ResourcesConfiguration.ResourcesConfiguration import getWorkspaceFile [as 别名]
def __init__(self):
# Command line commands
parser = CommandLine.get_parser()
opts, args = parser.parse_args()
gettext.bindtextdomain("netzob", ResourcesConfiguration.getLocaleLocation())
gettext.textdomain("netzob")
try:
locale.getlocale()
except:
logging.exception("setlocale failed, resetting to C")
locale.setlocale(locale.LC_ALL, "C")
(status, version) = DepCheck.test_lxml()
if status == False:
logging.fatal("Version of python-lxml ({0}) is too old for Netzob. Please install a recent version (>= 2.3)".format(version))
sys.exit()
# First we initialize and verify all the resources
if not ResourcesConfiguration.initializeResources():
logging.fatal("Error while configuring the resources of Netzob")
sys.exit()
if opts.workspace == None:
workspace = str(ResourcesConfiguration.getWorkspaceFile())
else:
workspace = opts.workspace
logging.debug("The workspace: {0}".format(str(workspace)))
# loading the workspace
self.currentWorkspace = (Workspace.loadWorkspace(workspace))
# the semi-automatic loading of the workspace has failed (second attempt)
if self.currentWorkspace == None:
# we force the creation (or specification) of the workspace
if not ResourcesConfiguration.initializeResources(True):
logging.fatal("Error while configuring the resources of Netzob")
sys.exit()
workspace = str(ResourcesConfiguration.getWorkspaceFile())
logging.debug("The workspace: {0}".format(str(workspace)))
# loading the workspace
self.currentWorkspace = (Workspace.loadWorkspace(workspace))
if self.currentWorkspace == None:
logging.fatal("Stopping the execution (no workspace computed)!")
sys.exit()
self.currentProject = self.currentWorkspace.getLastProject()
# Second we create the logging infrastructure
LoggingConfiguration().initializeLogging(self.currentWorkspace)
# Now we load all the available plugins
NetzobPlugin.loadPlugins(self)
# create logger with the given configuration
self.log = logging.getLogger('netzob.py')
self.log.info(_("Starting netzob"))
# Main window definition
gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
self.set_default_size(800, 600)
self.set_title(_("Netzob: Inferring communication protocols"))
self.set_icon_from_file(("%s/logo.png" %
ResourcesConfiguration.getStaticResources()))
self.connect("delete_event", self.evnmtDelete)
self.connect("destroy", self.destroy)
main_vbox = gtk.VBox(False, spacing=0)
# Create and display the menu
self.menu = Menu(self)
menubar = self.menu.getMenuBar(self)
menubar.show()
self.menu.update()
main_vbox.pack_start(menubar, False, True, 0)
# Notebook definition
self.notebook = gtk.Notebook()
self.notebook.set_tab_pos(gtk.POS_TOP)
self.notebook.connect("switch-page", self.notebookFocus)
main_vbox.pack_start(self.notebook, True, True, 0)
self.pageList = []
# Adding the different notebook
self.modelization = UImodelization(self)
self.grammarInference = UIGrammarInference(self)
# self.fuzzing = UIfuzzing(self)
self.simulator = UISimulator(self)
self.pageList.append([_("Vocabulary inference"), self.modelization])
self.pageList.append([_("Grammar inference"), self.grammarInference])
# self.pageList.append(["Fuzzing", self.fuzzing])
self.pageList.append([_("Simulator"), self.simulator])
for page in self.pageList:
self.notebook.append_page(page[1].panel, gtk.Label(page[0]))
#.........这里部分代码省略.........