コード例 #1
0
    def __init__( self,  wtree, callbacks, plugin_package_tabs, parent_name = '', parent_tree = []):
        self.wtree = wtree
        self.callbacks = callbacks
        self.plugin_package_tabs = plugin_package_tabs
        self.notebook = self.wtree.get_widget("notebook")
        self.installed_window = self.wtree.get_widget("installed_files_scrolled_window")
        #self.changelog = self.wtree.get_widget("changelog").get_buffer()
        self.changelog_scrolledwindow = self.wtree.get_widget('changelog_scrolled_window')
        self.changelog = ChangeLogView()
        self.changelog_scrolledwindow.add(self.changelog)
        self.changelog_scrolledwindow.show_all()
        #
        self.installed_files = self.wtree.get_widget("installed_files").get_buffer()
        #self.ebuild = self.wtree.get_widget("ebuild").get_buffer()
        self.ebuild_scrolledwindow = self.wtree.get_widget('ebuild_scrolled_window')
        self.ebuild = HighlightView(portage_lib.get_path, ['gentoo', 'shell'])
        self.ebuild_scrolledwindow.add(self.ebuild)
        self.ebuild_scrolledwindow.show_all()

        # summary view
        scroller = self.wtree.get_widget("summary_text_scrolled_window");
        self.summary = Summary(Dispatcher(self.callbacks["action_callback"]), self.callbacks["re_init_portage"])
        result = scroller.add(self.summary)
        self.summary.show()
        # setup the dependency treeview
        self.deps_view = DependsView(self.new_notebook, parent_name, parent_tree, Dispatcher(self.callbacks["action_callback"]))
        self.dep_window = {'window': None, 'notebook': None, 'callback': None, 'label': None, 'tooltip': None, 'tree': '', 'depth': 0}
        result = self.wtree.get_widget("dependencies_scrolled_window").add(self.deps_view)

        self.use_flag_page = self.wtree.get_widget("use_scrolledwindow")
        self.use_flag_view = None
        self.notebook.connect("switch-page", self.notebook_changed)
        self.reset_tabs()
コード例 #2
0
ファイル: sterminal.py プロジェクト: VentGrey/chrysalis
 def __init__(self, command, need_output, dprint_output='', callback=None):
     self.command = command
     self.pid = None
     # create the process reader
     self.reader = ProcessOutputReader(Dispatcher(self.cleanup),
                                       dprint_output)
     self.reader.record_output = need_output
     self.callback = callback
     # start the reader
     self.reader.start()
コード例 #3
0
def set_make_conf(property, add='', remove='', replace='', callback=None):
    """
    Sets a variable in make.conf.
    If remove: removes elements of <remove> from variable string.
    If add: adds elements of <add> to variable string.
    If replace: replaces entire variable string with <replace>.

    if remove contains the variable name, the whole variable is removed.

    e.g. set_make_conf('USE', add=['gtk', 'gtk2'], remove=['-gtk', '-gtk2'])
    e.g. set_make_conf('ACCEPT_KEYWORDS', remove='ACCEPT_KEYWORDS')
    e.g. set_make_conf('PORTAGE_NICENESS', replace='15')
    """
    debug.dprint("PORTAGELIB: set_make_conf()")
    command = ''
    _file = 'make.conf'
    if isinstance(add, list):
        add = ' '.join(add)
    if isinstance(remove, list):
        remove = ' '.join(remove)
    if isinstance(replace, list):
        replace = ' '.join(replace)
    if not os.access(os.path.join(portage.root, portage_const.MAKE_CONF_FILE),
                     os.W_OK):
        command = (config.Prefs.globals.su + ' "python ' +
                   config.Prefs.DATA_PATH +
                   'backends/set_config.py -d -f %s ' % _file)
        command = (command + '-p %s ' % property)
        if add != '':
            command = (command + '-a %s ' % ("'" + add + "'"))
        if remove != '':
            command = (command + '-r %s' % ("'" + remove + "'"))
        command = command + '"'
        debug.dprint(" * PORTAGELIB: set_make_conf(); command = %s" % command)
        if not callback:
            callback = reload_portage
        dispatcher = Dispatcher(callback)
        app = SimpleTerminal(command,
                             False,
                             dprint_output='SET_MAKE_CONF CHILD APP: ',
                             callback=dispatcher)
        app._run()
        del dispatcher
    else:
        add = add.split()
        remove = remove.split()
        set_config.set_make_conf(property, add, remove, replace)
        if callback: callback()
        else: reload_portage()
    # This is slow, but otherwise portage doesn't notice the change.
    #reload_portage()
    # Note: could perhaps just update portage.settings.
    # portage.settings.pmaskdict, punmaskdict, pkeywordsdict, pusedict
    # or portage.portdb.settings ?
    return True
コード例 #4
0
 def __init__(self, action):
     DBBase.__init__(self)
     self.descriptions = {}
     self.desc_loaded = False
     self.desc_reloaded = False
     self.db_thread_running = False
     self.db_init_waiting = False
     self.db_init_new_sync = False
     self.db_thread = None
     self.callback = None
     self.desc_callback = None
     self.desc_thread = None
     ## get home directory
     ##home = pwd.getpwuid(os.getuid())[5]
     self._DBFile = EPREFIX + "/var/db/porthole/descriptions.db"
     self.valid_sync = False  #used for auto-reload disabling
     ##del home
     #if action == NEW:
     self.dispatcher = Dispatcher(self.db_update)
     self.db_init()
コード例 #5
0
ファイル: advemerge.py プロジェクト: fcolecumberri/porthole
 def on_make_conf_commit(self, button_widget):
     debug.dprint("ADVEMERGE: on_make_conf_commit()")
     use_flags = self.get_use_flags()
     if not use_flags: return
     addlist = use_flags.split()
     removelist = []
     for item in addlist:  # get opposite of flags
         if item.startswith('-'):
             removelist.append(item[1:])
         else:
             removelist.append('-' + item)
     # set_user_config must be performed after set_make_conf has finished or we get problems.
     # we need to set package.use in case the flag was set there originally!
     package_use_callback = Dispatcher( db.userconfigs.set_user_config,\
             'USE', self.package.full_name, '', '', removelist, self.reload )
     backends.portage_lib.set_make_conf('USE',
                                        add=addlist,
                                        remove=removelist,
                                        callback=package_use_callback)
     self.version_changed(button_widget)
コード例 #6
0
def set_user_config( file, name='', ebuild='', add='', remove='', callback=None):
    """depricated function. this is now part of the db.user_configs module
    Function for parsing package.use, package.mask, package.unmask
    and package.keywords.

    Adds <name> or '=' + <ebuild> to <file> with flags <add>.
    If an existing entry is found, items in <remove> are removed and <add> is added.
    
    If <name> and <ebuild> are not given then lines starting with something in
    remove are removed, and items in <add> are added as new lines.
    """
    debug.dprint("PORTAGELIB: DEPRICATED FUNCTION! set_user_config(); depricated update calling code to use the db.user_configs module")
    command = ''
    maskfiles = ['package.mask', 'package.unmask']
    otherfiles = ['package.use', 'package.keywords']
    package_files = otherfiles + maskfiles
    if file not in package_files:
        debug.dprint(" * PORTAGELIB: set_user_config(); unsupported config file '%s'" % file)
        return False
    if isinstance(add, list):
        add = ' '.join(add)
    if isinstance(remove, list):
        remove = ' '.join(remove)
    config_path = portage_const.USER_CONFIG_PATH
    if not os.access(config_path, os.W_OK):
        commandlist = [config.Prefs.globals.su, '"python', config.Prefs.DATA_PATH + 'backends/set_config.py -d -f %s' %file]
        if name != '':
            commandlist.append('-n %s' %name)
        if ebuild != '':
            commandlist.append('-e %s' %ebuild)
        if add != '':
            items = add.split()
            for item in items:
                commandlist.append('-a %s' % item)
        if remove != '':
            items = remove.split()
            for item in items:
                commandlist.append('-r %s' % item)
        command = ' '.join(commandlist) + '"'
        debug.dprint(" * PORTAGELIB: set_user_config(); command = %s" %command )
        if not callback: callback = reload_portage
        app = SimpleTerminal(command, False, dprint_output='SET_USER_CONFIG CHILD APP: ', callback=Dispatcher(callback))
        app._run()
    else:
        add = add.split()
        remove = remove.split()
        set_config.set_user_config(file, name, ebuild, add, remove)
        if callback: callback()
        else: reload_portage()
    # This is slow, but otherwise portage doesn't notice the change.
    #reload_portage()
    # Note: could perhaps just update portage.settings.
    # portage.settings.pmaskdict, punmaskdict, pkeywordsdict, pusedict
    # or portage.portdb.mysettings ?
    return True
コード例 #7
0
    def __init__(self):
        debug.dprint("MAINWINDOW: process id = %d ****************" %
                     os.getpid())

        # set unfinished items to not be sensitive
        #self.wtree.get_widget("contents2").set_sensitive(False)
        # self.wtree.get_widget("btn_help").set_sensitive(False)

        # Initialize our subclasses
        PluginHandler.__init__(self)

        self.status = StatusHandler(self.wtree.get_widget("statusbar2"),
                                    self.wtree.get_widget("progressbar1"),
                                    self.category_view, self.package_view,
                                    self.current_pkg_path,
                                    self.current_pkg_cursor, self.plugin_views)

        # get an empty tooltip
        ##self.synctooltip = gtk.Tooltips()
        self.sync_tip = _(
            " Synchronise Package Database \n The last sync was done:\n")
        # set the sync label to the saved one set in the options
        self.widget["btn_sync"].set_label(config.Prefs.globals.Sync_label)
        self.widget["view_refresh"].set_sensitive(False)
        # restore last window width/height
        if config.Prefs.main.xpos and config.Prefs.main.ypos:
            self.mainwindow.move(config.Prefs.main.xpos,
                                 config.Prefs.main.ypos)
        self.mainwindow.resize(config.Prefs.main.width,
                               config.Prefs.main.height)
        # connect gtk callback for window movement and resize events
        self.mainwindow.connect("configure-event", self.size_update)
        # restore maximized state and set window-state-event
        # handler to keep track of it
        if config.Prefs.main.maximized:
            self.mainwindow.maximize()
        self.mainwindow.connect("window-state-event",
                                self.on_window_state_event)
        # move horizontal and vertical panes
        #debug.dprint("MAINWINDOW: __init__() before hpane; " +
        #"%d, vpane; %d"
        #%(config.Prefs.main.hpane, config.Prefs.main.vpane))
        self.hpane = self.wtree.get_widget("hpane")
        self.hpane.set_position(config.Prefs.main.hpane)
        self.hpane.connect("notify", self.on_pane_notify)
        self.vpane = self.wtree.get_widget("vpane")
        self.vpane.set_position(config.Prefs.main.vpane)
        self.vpane.connect("notify", self.on_pane_notify)
        # Intercept the window delete event signal
        self.mainwindow.connect('delete-event', self.confirm_delete)
        # initialize some variable to fix the hpane jump bug
        #self.hpane_bug_count = 0
        #self.hpane_bug = True
        # initialize now so that the update_db_callback doesn't puke
        self.status.set_statusbar2("Starting")
        # set if we are root or not
        self.is_root = utils.is_root()
        debug.dprint("MAINWINDOW: __init__(); is_root = " + str(self.is_root))
        if config.Prefs.main.show_nag_dialog:
            # let the user know if he can emerge or not
            self.check_for_root()
        self.toolbar_expander = self.wtree.get_widget("toolbar_expander")
        # This should be set in the glade file, but doesn't seem to work ?
        self.toolbar_expander.set_expand(True)
        # populate the view_filter menu
        self.widget["view_filter_list"] = gtk.ListStore(str)
        for i in [
                _("All Packages"),
                _("Installed Packages"),
                _("Search Results"),
                _("Upgradable Packages"),
                _("Deprecated Packages"),
                _("Sets")
        ]:
            self.widget["view_filter_list"].append([i])
        self.widget["view_filter"].set_model(self.widget["view_filter_list"])
        self.widget["view_filter"].set_active(SHOW_ALL)
        self.setup_plugins()

        callbacks = {
            "action_callback": self.action_callback,
            "re_init_portage": self.re_init_portage,
            "set_package_actions_sensitive": self.set_package_actions_sensitive
        }
        self.assign_packagebook(self.wtree, callbacks,
                                self.plugin_package_tabs)
        # initialize our data
        self.init_data()
        self.search_dispatcher = Dispatcher(self.search_done)
        debug.dprint("MAINWINDOW: Showing main window")
        self.mainwindow.show_all()
        if self.is_root:
            # hide warning toolbar widget
            debug.dprint("MAINWINDOW: __init__(); hiding btn_root_warning")
            self.wtree.get_widget("btn_root_warning").hide()
コード例 #8
0
    def set_user_config(self,
                        mytype,
                        name='',
                        ebuild='',
                        add='',
                        remove='',
                        callback=None,
                        parent_window=None,
                        *comment):
        """
        Adds <name> or '=' + <ebuild> to <file> with flags <add>.
        If an existing entry is found, items in <remove> 
        are removed and <add> is added.
        
        If <name> and <ebuild> are not given then lines starting with 
        something in remove are removed, and items in <add> are added
        as new lines.
        """
        debug.dprint("USER_CONFIGS: set_user_config()")
        self.set_callback = callback
        self.set_type = mytype
        command = ''
        if mytype not in CONFIG_TYPES:
            debug.dprint("USER_CONFIGS: set_user_config(): unsupported " +
                         "config mytype '%s'" % mytype)
            return False
        config_path = os.path.join(portage_lib.settings.config_root,
                                   portage_lib.settings.user_config_dir)
        # get an  existing atom if one exists.  pass both name and ebuild,
        # no need to check which one, I think
        atom = self.get_atom(mytype, name, ebuild)
        if atom == None or atom == []:  # get a target file
            if add == '' and remove != '':
                # then there is no need to create a new file entry
                # this call was probably to check and remove
                # an existing entry if it existed.
                return True
            file = target = CONFIG_FILES[CONFIG_TYPES.index(mytype)]
            target_path = os.path.join(config_path, target)
            debug.dprint("USER_CONFIGS: set_user_config(): target_path = " +
                         target_path)
            if os.path.isdir(
                    target_path):  # Then bring up a file selector dialog
                if parent_window == None:
                    parent_window = config.Mainwindow
                file_picker = FileSelector2(parent_window,
                                            os.path.join(target_path, target),
                                            overwrite_confirm=False)
                file = file_picker.get_filename(
                    _("Porthole: Please select the %s file to use") % (target),
                    'save')
                if file == '': return False
                file = os.path.join(target_path, file)
            else:
                file = target_path
            debug.dprint(
                "USER_CONFIGS: set_user_config(): got a filename :) " +
                "file = " + file)

        else:  # found one
            file = atom[0].file
            debug.dprint("USER_CONFIGS: set_user_config(): found an atom :) " +
                         "file = " + file)
        self.set_file = file

        if isinstance(add, list):
            add = ' '.join(add)
        if isinstance(remove, list):
            remove = ' '.join(remove)
        if ebuild:
            if ebuild[0] not in '=':
                ebuild = "=" + ebuild
        #debug.dprint("USER_CONFIGS: set_user_config(): add: " +
        #"%s,\n remove: %s " %(add,remove))
        if os.getuid == 0 or os.access(config_path, os.W_OK):
            add = add.split()
            remove = remove.split()
            debug.dprint("USER_CONFIGS: set_user_config(): add: " +
                         "%s,\n remove: %s " % (str(add), str(remove)))
            set_config.set_user_config(filename=file,
                                       name=name,
                                       ebuild=ebuild,
                                       comment=comment,
                                       username=privileges.user,
                                       add=add,
                                       remove=remove)
            self.set_config_callback()
        else:
            commandlist = [
                config.Prefs.globals.su, '"python',
                set_config.__file__ + ' -d -f ' + file
            ]
            if name != '':
                commandlist.append('-n %s' % name)
            if ebuild != '':
                commandlist.append('-e %s' % ebuild)
            comment = ''  # for now. TODO add comment input dialog
            if comment != '':
                commandlist.append('-c %s' % comment)
            commandlist.append('-u %s' % os.getenv("LOGNAME"))
            if add != '':
                items = add.split()
                for item in items:
                    commandlist.append('-a %s' % item)
            if remove != '':
                items = remove.split()
                for item in items:
                    commandlist.append('-r %s' % item)
            command = ' '.join(commandlist) + '"'
            debug.dprint(" * USER_CONFIGS: set_user_config(): command = %s" %
                         command)
            # add code to update_config()
            mycallback = self.set_config_callback  #portage_lib.reload_portage
            app = SimpleTerminal(command,
                                 False,
                                 dprint_output='SET_USER_CONFIG CHILD APP: ',
                                 callback=Dispatcher(mycallback))
            app._run()
        return True