Example #1
0
    def __init__(self, image_directory, application_path, nice, check_all,
                 check_cache):
        global_settings.client_name = nongui_misc.get_um_name()
        self.api_lock = nrlock.NRLock()
        self.image_dir_arg = image_directory
        if self.image_dir_arg == None:
            self.image_dir_arg = nongui_misc.get_image_path()
        self.application_path = application_path
        self.nice = nice
        self.check_all = check_all
        self.check_cache_only = check_cache
        try:
            self.application_dir = os.environ["PACKAGE_MANAGER_ROOT"]
        except KeyError:
            self.application_dir = "/"
        misc.setlocale(locale.LC_ALL, "")

        self.progress_tracker = progress.NullProgressTracker()
        self.api_obj = None
        self.return_status = enumerations.UPDATES_UNDETERMINED
        self.pylintstub = None

        # Check Updates - by default check all
        if self.check_all:
            self.api_obj = self.__get_api_obj()
            self.__check_for_updates()
        elif self.check_cache_only:
            self.api_obj = self.__get_api_obj()
            ret = self.__check_for_updates_cache_only()
            if ret == enumerations.UPDATES_UNDETERMINED:
                self.__send_return(enumerations.UPDATES_UNDETERMINED)
Example #2
0
        def __init__(self, image_directory, application_path):
                global_settings.client_name = gui_misc.get_um_name()
                self.api_lock = nrlock.NRLock()
                self.image_dir_arg = image_directory
                if self.image_dir_arg == None:
                        self.image_dir_arg = gui_misc.get_image_path()
                self.application_path = application_path
                self.gconf = pmgconf.PMGConf()
                try:
                        self.application_dir = os.environ["PACKAGE_MANAGER_ROOT"]
                except KeyError:
                        self.application_dir = "/"
                misc.setlocale(locale.LC_ALL, "")
                for module in (gettext, gtk.glade):
                        module.bindtextdomain("pkg", os.path.join(
                            self.application_dir,
                            "usr/share/locale"))
                        module.textdomain("pkg")
                gui_misc.init_for_help(self.application_dir)

                self.icon_theme = gtk.icon_theme_get_default()
                pkg_icon_location = os.path.join(self.application_dir, PKG_ICON_LOCATION)
                self.icon_theme.append_search_path(pkg_icon_location)
                icon_location = os.path.join(self.application_dir, ICON_LOCATION)
                self.icon_theme.append_search_path(icon_location)
                self.progress_tracker = progress.NullProgressTracker()
                self.api_obj = None
                self.installupdate = None
                self.return_status = enumerations.UPDATES_UNDETERMINED
                self.pylintstub = None
                
                gui_misc.setup_logging()
                gobject.idle_add(self.__do_image_update)
Example #3
0
 def RefreshPackages(self):
     self.installed = dict()
     self.image.history.operation_name = "list"
     self.image.load_catalogs(progress.NullProgressTracker())
     for (pfmri, pinfo) in self.image.inventory([], False):
         pname = pfmri.pkg_name
         pversion = pfmri.version.get_short_version()
         self.installed[pname] = pversion
         if pinfo['upgradable']:
             self.pending_upgrades.add(pname)
Example #4
0
        def check_and_start(self):
                self.check_already_running()
                self.client.add_dir(UPDATEMANAGER_PREFERENCES, 
                    gconf.CLIENT_PRELOAD_NONE)
                self.client.notify_add(REFRESH_PERIOD_PREFERENCES, 
                    self.refresh_period_changed)
                self.client.notify_add(SHOW_ICON_ON_STARTUP_PREFERENCES, 
                    self.show_icon_changed)
                self.refresh_period  =  self.get_refresh_period()
                self.host = socket.gethostname()

                self.last_check_time = self.get_last_check_time()
                self.pr = progress.NullProgressTracker()
                if self.get_show_icon_on_startup():
                        self.client.set_bool(SHOW_ICON_ON_STARTUP_PREFERENCES, False)
                        self.schedule_check_for_updates()
                else:
                        gobject.idle_add(self.do_next_check)
                return False
Example #5
0
        def __init__(self, index_dir, get_manifest_func, get_manifest_path_func,
            progtrack=None, excludes=EmptyI, log=None,
            sort_file_max_size=SORT_FILE_MAX_SIZE):
                self._num_keys = 0
                self._num_manifests = 0
                self._num_entries = 0
                self.get_manifest_func = get_manifest_func
                self.get_manifest_path_func = get_manifest_path_func
                self.excludes = excludes
                self.__log = log
                self.sort_file_max_size = sort_file_max_size
                if self.sort_file_max_size <= 0:
                        raise search_errors.IndexingException(
                            _("sort_file_max_size must be greater than 0"))

                # This structure was used to gather all index files into one
                # location. If a new index structure is needed, the files can
                # be added (or removed) from here. Providing a list or
                # dictionary allows an easy approach to opening or closing all
                # index files.

                self._data_dict = {
                        "fast_add":
                            ss.IndexStoreSet(ss.FAST_ADD),
                        "fast_remove":
                            ss.IndexStoreSet(ss.FAST_REMOVE),
                        "manf":
                            ss.IndexStoreListDict(ss.MANIFEST_LIST,
                                build_function=self.__build_fmri,
                                decode_function=self.__decode_fmri),
                        "full_fmri": ss.IndexStoreSet(ss.FULL_FMRI_FILE),
                        "main_dict": ss.IndexStoreMainDict(ss.MAIN_FILE),
                        "token_byte_offset":
                            ss.IndexStoreDictMutable(ss.BYTE_OFFSET_FILE)
                        }

                self._data_fast_add = self._data_dict["fast_add"]
                self._data_fast_remove = self._data_dict["fast_remove"]
                self._data_manf = self._data_dict["manf"]
                self._data_full_fmri = self._data_dict["full_fmri"]
                self._data_main_dict = self._data_dict["main_dict"]
                self._data_token_offset = self._data_dict["token_byte_offset"]

                # This is added to the dictionary after the others because it
                # needs one of the other mappings as an input.
                self._data_dict["fmri_offsets"] = \
                    ss.InvertedDict(ss.FMRI_OFFSETS_FILE, self._data_manf)
                self._data_fmri_offsets = self._data_dict["fmri_offsets"]

                self._index_dir = index_dir
                self._tmp_dir = os.path.join(self._index_dir, "TMP")

                self.__lockfile = lockfile.LockFile(os.path.join(
                    self._index_dir, "lock"),
                    set_lockstr=lockfile.generic_lock_set_str,
                    get_lockstr=lockfile.generic_lock_get_str,
                    failure_exc=search_errors.IndexLockedException)

                self._indexed_manifests = 0
                self.server_repo = True
                self.empty_index = False
                self.file_version_number = None

                if progtrack is None:
                        self._progtrack = progress.NullProgressTracker()
                else:
                        self._progtrack = progtrack

                self._file_timeout_secs = FILE_OPEN_TIMEOUT_SECS

                self._sort_fh = None
                self._sort_file_num = 0
                self._sort_file_bytes = 0

                # The action type and key indexes, which are necessary for
                # efficient searches by type or key, store their file handles in
                # dictionaries.  File handles for actions are in at_fh, while
                # filehandles for keys are kept in st_fh.
                self.at_fh = {}
                self.st_fh = {}

                self.old_out_token = None