Exemple #1
0
    def _idle(self):

        if self.phase == 0:
            self.splash.text = _("Registering icons ...")

            from icons import register_icons
            register_icons()
        elif self.phase == 1:
            self.splash.text = _("Loading preferences ...")

            from umit.pm.manager.preferencemanager import Prefs
            self.prefs = Prefs()
        elif self.phase == 2:
            services_boot()
            self.splash.text = _("Creating main window ...")

            from mainwindow import MainWindow
            self.bus = ServiceBus()
            self.main_window = MainWindow()
            self.main_window.connect_tabs_signals()
            self.plugin_engine = PluginEngine()
            self.plugin_engine.load_selected_plugins()

            # Destroy the splash screen
            self.splash.hide()
            self.splash.destroy()
            self.splash.finished = True

            del self.splash

            # Now let's parse the args passed in the constructor
            parser = self._create_parser()
            options, args = parser.parse_args(self._args)

            if options.fread:
                self.main_window.open_generic_file_async(options.fread)

            if options.audit:
                dev1, dev2, bpf_filter = options.audit, '', ''

                try:
                    dev1, dev2 = options.audit.split(',', 1)
                    dev2, bpf_filter = other.split(':', 1)
                except:
                    pass

                self.main_window.start_new_audit(dev1, dev2, bpf_filter, False,
                                                 False)

            return False

        self.phase += 1
        return True
Exemple #2
0
    def __on_save_path(self, widget):
        "Save the paths in umit configuration file without recaching"

        # Simple create a list from ListStore
        # and then save to umit configuration file

        ret = []

        def add_to(model, path, titer, ret):
            ret.append(model.get_value(titer, 1))

        self.path_store.foreach(add_to, ret)

        self.p_window.engine.plugins.paths = ret
        self.p_window.engine.plugins.save_changes()

        PluginEngine().recache()

        if self.p_window.plug_page.clear(False) > 0:
            # Warn the user
            self.p_window.animated_bar.label = _("Remember that you have to "
                                                 "restart PacketManipulator to changes makes"
                                                 ". Plugins disable pending.")
            self.p_window.animated_bar.start_animation(True)

            def block_row(row, blah):
                row.activatable = False
                row.message = _("Need PacketManipulator restart to disable.")

            self.p_window.plug_page.richlist.foreach(block_row, None)

        self.p_window.plug_page.populate()
        self.p_window.audit_page.populate()
Exemple #3
0
    def _idle(self):

        if self.phase == 0:
            self.splash.text = _("Registering icons ...")

            from icons import register_icons
            register_icons()
        elif self.phase == 1:
            self.splash.text = _("Loading preferences ...")

            from umit.pm.manager.preferencemanager import Prefs
            self.prefs = Prefs()
        elif self.phase == 2:
            services_boot()
            self.splash.text = _("Creating main window ...")

            from mainwindow import MainWindow
            self.bus = ServiceBus()
            self.main_window = MainWindow()
            self.main_window.connect_tabs_signals()
            self.plugin_engine = PluginEngine()
            self.plugin_engine.load_selected_plugins()

            # Destroy the splash screen
            self.splash.hide()
            self.splash.destroy()
            self.splash.finished = True

            del self.splash

            # Now let's parse the args passed in the constructor
            parser = self._create_parser()
            options, args = parser.parse_args(self._args)

            if options.fread:
                self.main_window.open_generic_file_async(options.fread)

            if options.audit:
                dev1, dev2, bpf_filter = options.audit, '', ''

                try:
                    dev1, dev2 = options.audit.split(',', 1)
                    dev2, bpf_filter = other.split(':', 1)
                except:
                    pass

                self.main_window.start_new_audit(dev1, dev2, bpf_filter, False, False)

            return False

        self.phase += 1
        return True
Exemple #4
0
    def __init__(self):
        HIGWindow.__init__(self)

        self.engine = PluginEngine()
        self.update_eng = UpdateEngine()

        self.set_title(_('Plugin Manager'))
        self.set_position(gtk.WIN_POS_CENTER)
        self.set_size_request(600, 400)
        self.set_icon_from_file(os.path.join(PIXMAPS_DIR, 'pm-logo.png'))

        self.__create_widgets()
        self.__pack_widgets()
    def get_need(self, reader, needstr, classname=None, need_module=False):
        """
        Usefull function to return an instance of needstr:classname

        @param reader a PluginReader object or None
        """
        lst = []

        if reader:
            # We create a list of needs for the same package
            for need in reader.needs:
                name, op, ver = Version.extract_version(need)

                if name == needstr:
                    lst.append((op, ver, name))

        from umit.pm.gui.plugins.engine import PluginEngine
        ret = PluginEngine().tree.get_provide(needstr, lst, need_module)

        log.debug(">>> Core.get_need() -> %s (module: %s)" %
                  (ret, need_module))

        if not ret:
            return None

        if not need_module:
            if not classname:
                log.debug(">>> Core.get_need(): No classname specified. " \
                          "Returning first instance")
                return ret[0]

            for instance in ret:
                if instance.__class__.__name__ == classname:
                    return instance
        else:
            # We need a module

            if len(ret) > 1:
                log.debug(">>> Core.get_need(): Returning the first module")

            return ret[0]

        return None
Exemple #6
0
class PMApp(Singleton):
    "The PacketManipulator application singleton object"

    def __init__(self, args):
        """
        PacketManipulator Application class
        @param args pass sys.argv
        """
        gobject.threads_init()

        self._args = args
        root = False

        try:
            # FIXME: add maemo
            if sys.platform == 'win32':
                import ctypes
                root = bool(ctypes.windll.shell32.IsUserAnAdmin())
            elif os.getuid() == 0:
                root = True
        except: pass

        if Prefs()['system.check_pyver'].value == True and \
           sys.version_info[1] < 6:
            dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                       gtk.MESSAGE_WARNING,
                                       gtk.BUTTONS_YES_NO,
                                       _('Packet Manipulator requires at least '
                                         '2.6 version of Python but you\'ve %s '
                                         'installed. We not guarantee that all '
                                         'functionalities works properly.\n\n'
                                         'Do you want to continue?') % ".".join(
                                       map(str, sys.version_info[:3])))
            ret = dialog.run()
            dialog.hide()
            dialog.destroy()

            if ret == gtk.RESPONSE_NO:
                sys.exit(-1)


        if Prefs()['system.check_root'].value == True and not root:
            dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
                                       gtk.MESSAGE_WARNING,
                                       gtk.BUTTONS_YES_NO,
                                       _('You are running Packet Manipulator as'
                                         ' non-root user!\nSome functionalities'
                                         ' need root privileges to work\n\nDo '
                                         'you want to continue?'))
            ret = dialog.run()
            dialog.hide()
            dialog.destroy()

            if ret == gtk.RESPONSE_NO:
                sys.exit(-1)

        self.phase = 0
        self.splash = SplashScreen()

    def _idle(self):

        if self.phase == 0:
            self.splash.text = _("Registering icons ...")

            from icons import register_icons
            register_icons()
        elif self.phase == 1:
            self.splash.text = _("Loading preferences ...")

            from umit.pm.manager.preferencemanager import Prefs
            self.prefs = Prefs()
        elif self.phase == 2:
            services_boot()
            self.splash.text = _("Creating main window ...")

            from mainwindow import MainWindow
            self.bus = ServiceBus()
            self.main_window = MainWindow()
            self.main_window.connect_tabs_signals()
            self.plugin_engine = PluginEngine()
            self.plugin_engine.load_selected_plugins()

            # Destroy the splash screen
            self.splash.hide()
            self.splash.destroy()
            self.splash.finished = True

            del self.splash

            # Now let's parse the args passed in the constructor
            parser = self._create_parser()
            options, args = parser.parse_args(self._args)

            if options.fread:
                self.main_window.open_generic_file_async(options.fread)

            if options.audit:
                dev1, dev2, bpf_filter = options.audit, '', ''

                try:
                    dev1, dev2 = options.audit.split(',', 1)
                    dev2, bpf_filter = other.split(':', 1)
                except:
                    pass

                self.main_window.start_new_audit(dev1, dev2, bpf_filter, False, False)

            return False

        self.phase += 1
        return True

    def run(self):
        self.splash.show_all()
        gobject.idle_add(self._idle)
        gtk.main()

    def _create_parser(self):
        """
        @return an OptionParser object that can handle the sys.argv passed in
                the constructor.
        """

        opt = OptionParser()
        opt.add_option('-r', None, dest="fread",
                       help="Read packets/sequence from file.")
        opt.add_option('-a', None, dest="audit",
                       help="Start an audit using intf1[,intf2][:bpf_filter]")

        return opt
Exemple #7
0
class PMApp(Singleton):
    "The PacketManipulator application singleton object"

    def __init__(self, args):
        """
        PacketManipulator Application class
        @param args pass sys.argv
        """
        gobject.threads_init()

        self._args = args
        root = False

        try:
            # FIXME: add maemo
            if sys.platform == 'win32':
                import ctypes
                root = bool(ctypes.windll.shell32.IsUserAnAdmin())
            elif os.getuid() == 0:
                root = True
        except:
            pass

        if Prefs()['system.check_pyver'].value == True and \
           sys.version_info[1] < 6:
            dialog = gtk.MessageDialog(
                None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
                gtk.BUTTONS_YES_NO,
                _('Packet Manipulator requires at least '
                  '2.6 version of Python but you\'ve %s '
                  'installed. We not guarantee that all '
                  'functionalities works properly.\n\n'
                  'Do you want to continue?') %
                ".".join(map(str, sys.version_info[:3])))
            ret = dialog.run()
            dialog.hide()
            dialog.destroy()

            if ret == gtk.RESPONSE_NO:
                sys.exit(-1)

        if Prefs()['system.check_root'].value == True and not root:
            dialog = gtk.MessageDialog(
                None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING,
                gtk.BUTTONS_YES_NO,
                _('You are running Packet Manipulator as'
                  ' non-root user!\nSome functionalities'
                  ' need root privileges to work\n\nDo '
                  'you want to continue?'))
            ret = dialog.run()
            dialog.hide()
            dialog.destroy()

            if ret == gtk.RESPONSE_NO:
                sys.exit(-1)

        self.phase = 0
        self.splash = SplashScreen()

    def _idle(self):

        if self.phase == 0:
            self.splash.text = _("Registering icons ...")

            from icons import register_icons
            register_icons()
        elif self.phase == 1:
            self.splash.text = _("Loading preferences ...")

            from umit.pm.manager.preferencemanager import Prefs
            self.prefs = Prefs()
        elif self.phase == 2:
            services_boot()
            self.splash.text = _("Creating main window ...")

            from mainwindow import MainWindow
            self.bus = ServiceBus()
            self.main_window = MainWindow()
            self.main_window.connect_tabs_signals()
            self.plugin_engine = PluginEngine()
            self.plugin_engine.load_selected_plugins()

            # Destroy the splash screen
            self.splash.hide()
            self.splash.destroy()
            self.splash.finished = True

            del self.splash

            # Now let's parse the args passed in the constructor
            parser = self._create_parser()
            options, args = parser.parse_args(self._args)

            if options.fread:
                self.main_window.open_generic_file_async(options.fread)

            if options.audit:
                dev1, dev2, bpf_filter = options.audit, '', ''

                try:
                    dev1, dev2 = options.audit.split(',', 1)
                    dev2, bpf_filter = other.split(':', 1)
                except:
                    pass

                self.main_window.start_new_audit(dev1, dev2, bpf_filter, False,
                                                 False)

            return False

        self.phase += 1
        return True

    def run(self):
        self.splash.show_all()
        gobject.idle_add(self._idle)
        gtk.main()

    def _create_parser(self):
        """
        @return an OptionParser object that can handle the sys.argv passed in
                the constructor.
        """

        opt = OptionParser()
        opt.add_option('-r',
                       None,
                       dest="fread",
                       help="Read packets/sequence from file.")
        opt.add_option('-a',
                       None,
                       dest="audit",
                       help="Start an audit using intf1[,intf2][:bpf_filter]")

        return opt