Exemplo n.º 1
0
    def __init__(self):
        # Parse command line arguments
        cmdLine = CommandLine()
        cmdLine.parse()
        opts = cmdLine.getOptions()

        # Current workspace path can be provided in command line argument
        if opts.workspace is None:
            workspaceDir = ResourcesConfiguration.getWorkspaceDir()
        else:
            workspaceDir = opts.workspace

        # Start the workspace management
        self.workspaceSelectorController = WorkspaceSelectorController(self)
        self.currentWorkspace = self.workspaceSelectorController.getWorkspace(workspaceDir)

        if self.currentWorkspace is None:
            sys.exit()

        #self.currentWorkspace = self._loadWorkspace(opts)
        self.currentProjet = None

        # Enable bug reporting, if workspace is configured so or if
        # netzob was explicitly started with the "-b" command line
        # option.
        enableBugReports = self.currentWorkspace.enableBugReporting
        if enableBugReports != opts.bugReport:
            enableBugReports = opts.bugReport
        self.enableBugReporter(enableBugReports)

        # Initialize everything else
        self._initLogging(opts)
        self._initResourcesAndLocales()

        # Intialize signals manager
        self.signalsManager = SignalsManager()

        # Loading the last project
        self.currentProject = self.currentWorkspace.getLastProject()

        # Initialize a clipboard object
        self.clipboard = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)

        # Check dependencies
        if not DepCheck.checkRequiredDependency():
            self.log.fatal("Netzob could not start because some of its required dependencies were not found.")
            sys.exit()

        # Initialize main view
        self.log.info("Starting netzob UI")
        self.view = None    # small hack since the attribute need to exists when the main glade is loaded
        self.view = NetzobMainView(self)

        # Load all available plugins
        NetzobPlugin.loadPlugins(self)

        self.view.registerPerspectives()

        # Refresh list of available exporter plugins
        self.updateListOfExporterPlugins()

        # Refresh list of available projects
        self.updateListOfAvailableProjects()