From 8ca43939eb2f608cf0250d90894b470e785713b9 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Sun, 31 May 2009 01:03:54 +0200 Subject: Extract the package name from the status message --- apt/progress/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'apt/progress/__init__.py') diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 47d2a861..fddc7486 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -399,10 +399,11 @@ class DpkgInstallProgress(InstallProgress): print "got garbage from dpkg: '%s'" % self.read self.read = "" break + pkg_name = statusl[1].strip() status = statusl[2].strip() #print status if status == "error": - self.error(self.debname, status) + self.error(pkg_name, status) elif status == "conffile-prompt": # we get a string like this: # 'current-conffile' 'new-conffile' useredited distedited -- cgit v1.2.3 From 81a030505cb46a35f670150929fad5862cd12767 Mon Sep 17 00:00:00 2001 From: Sebastian Heinlein Date: Sun, 31 May 2009 01:05:48 +0200 Subject: Do not store the the Deb path and package name as an attribute of the progress class. Furthermore allow to specify more than one file. --- apt/progress/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'apt/progress/__init__.py') diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index fddc7486..6b170fc7 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -367,13 +367,11 @@ class DpkgInstallProgress(InstallProgress): def run(self, debfile): """Start installing the given Debian package.""" - self.debfile = debfile - self.debname = os.path.basename(debfile).split("_")[0] pid = self.fork() if pid == 0: # child res = os.system("/usr/bin/dpkg --status-fd %s -i %s" % \ - (self.writefd, self.debfile)) + (self.writefd, debfile)) os._exit(os.WEXITSTATUS(res)) self.child_pid = pid res = self.wait_child() -- cgit v1.2.3 From cdabff6d329baba8024224b362f79d822ddd943e Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 4 Jun 2009 18:54:50 +0200 Subject: apt, aptsources, doc: Update to use the new names. --- apt/__init__.py | 4 +- apt/cache.py | 78 ++--- apt/cdrom.py | 14 +- apt/debfile.py | 50 +-- apt/package.py | 208 ++++++------ apt/progress/__init__.py | 8 +- apt/progress/gtk2.py | 2 +- aptsources/distinfo.py | 2 +- aptsources/sourceslist.py | 16 +- doc/source/apt_pkg.rst | 608 +++++++++++++++++----------------- doc/source/examples/cache-packages.py | 16 +- doc/source/examples/cache-pkgfile.py | 14 +- doc/source/examples/dpkg-contents.py | 4 +- doc/source/examples/dpkg-extract.py | 2 +- doc/source/examples/dpkg-info.py | 4 +- doc/source/examples/missing-deps.py | 30 +- 16 files changed, 531 insertions(+), 529 deletions(-) (limited to 'apt/progress/__init__.py') diff --git a/apt/__init__.py b/apt/__init__.py index 734b3240..41c0a30f 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -31,7 +31,9 @@ if apt_pkg._COMPAT_0_7: if apt_pkg._COMPAT_0_7: - from apt_pkg import SizeToStr, TimeToStr, VersionCompare + from apt_pkg import (size_to_str as SizeToStr, + time_to_str as TimeToStr, + version_compare as VersionCompare) # init the package system apt_pkg.init() diff --git a/apt/cache.py b/apt/cache.py index 60fd6553..56b32d45 100644 --- a/apt/cache.py +++ b/apt/cache.py @@ -52,16 +52,16 @@ class Cache(object): self._callbacks = {} if memonly: # force apt to build its caches in memory - apt_pkg.Config.Set("Dir::Cache::pkgcache", "") + apt_pkg.config.set("Dir::Cache::pkgcache", "") if rootdir: if os.path.exists(rootdir+"/etc/apt/apt.conf"): - apt_pkg.ReadConfigFile(apt_pkg.Config, + apt_pkg.read_config_file(apt_pkg.config, rootdir + "/etc/apt/apt.conf") if os.path.isdir(rootdir+"/etc/apt/apt.conf.d"): - apt_pkg.ReadConfigDir(apt_pkg.Config, + apt_pkg.read_config_dir(apt_pkg.config, rootdir + "/etc/apt/apt.conf.d") - apt_pkg.Config.Set("Dir", rootdir) - apt_pkg.Config.Set("Dir::State::status", + apt_pkg.config.set("Dir", rootdir) + apt_pkg.config.set("Dir::State::status", rootdir + "/var/lib/dpkg/status") self.open(progress) @@ -82,20 +82,20 @@ class Cache(object): self._depcache = apt_pkg.DepCache(self._cache) self._records = apt_pkg.PackageRecords(self._cache) self._list = apt_pkg.SourceList() - self._list.ReadMainList() + self._list.read_main_list() self._set = set() self._weakref = weakref.WeakValueDictionary() progress.Op = "Building data structures" i=last=0 - size=len(self._cache.Packages) - for pkg in self._cache.Packages: + size=len(self._cache.packages) + for pkg in self._cache.packages: if progress is not None and last+100 < i: progress.update(i/float(size)*100) last=i # drop stuff with no versions (cruft) - if len(pkg.VersionList) > 0: - self._set.add(pkg.Name) + if len(pkg.version_list) > 0: + self._set.add(pkg.name) i += 1 @@ -148,7 +148,7 @@ class Cache(object): default value is False. """ self.cache_pre_change() - self._depcache.Upgrade(dist_upgrade) + self._depcache.upgrade(dist_upgrade) self.cache_post_change() @property @@ -156,13 +156,13 @@ class Cache(object): """Get the size of the packages that are required to download.""" pm = apt_pkg.PackageManager(self._depcache) fetcher = apt_pkg.Acquire() - pm.GetArchives(fetcher, self._list, self._records) - return fetcher.FetchNeeded + pm.get_archives(fetcher, self._list, self._records) + return fetcher.fetch_needed @property def required_space(self): """Get the size of the additional required space on the fs.""" - return self._depcache.UsrSize + return self._depcache.usr_size @property def req_reinstall_pkgs(self): @@ -170,31 +170,31 @@ class Cache(object): reqreinst = set() for pkg in self: if (not pkg.candidate.downloadable and - (pkg._pkg.InstState == apt_pkg.InstStateReInstReq or - pkg._pkg.InstState == apt_pkg.InstStateHoldReInstReq)): + (pkg._pkg.inst_state == apt_pkg.INSTSTATE_RE_INST_REQ or + pkg._pkg.inst_state == apt_pkg.INSTSTATE_HOLD_RE_INST_REQ)): reqreinst.add(pkg.name) return reqreinst def _run_fetcher(self, fetcher): # do the actual fetching - res = fetcher.Run() + res = fetcher.run() # now check the result (this is the code from apt-get.cc) failed = False transient = False err_msg = "" - for item in fetcher.Items: - if item.Status == item.StatDone: + for item in fetcher.items: + if item.status == item.stat_done: continue - if item.StatIdle: + if item.stat_idle: transient = True continue - err_msg += "Failed to fetch %s %s\n" % (item.DescURI, - item.ErrorText) + err_msg += "Failed to fetch %s %s\n" % (item.desc_uri, + item.error_text) failed = True # we raise a exception if the download failed or it was cancelt - if res == fetcher.ResultCancelled: + if res == fetcher.result_cancelled: raise FetchCancelledException(err_msg) elif failed: raise FetchFailedException(err_msg) @@ -204,14 +204,14 @@ class Cache(object): """ fetch the needed archives """ # get lock - lockfile = apt_pkg.Config.FindDir("Dir::Cache::Archives") + "lock" - lock = apt_pkg.GetLock(lockfile) + lockfile = apt_pkg.config.find_dir("Dir::Cache::Archives") + "lock" + lock = apt_pkg.get_lock(lockfile) if lock < 0: raise LockFailedException("Failed to lock %s" % lockfile) try: # this may as well throw a SystemError exception - if not pm.GetArchives(fetcher, self._list, self._records): + if not pm.get_archives(fetcher, self._list, self._records): return False # now run the fetcher, throw exception if something fails to be # fetched @@ -222,7 +222,7 @@ class Cache(object): def is_virtual_package(self, pkgname): """Return whether the package is a virtual package.""" pkg = self._cache[pkgname] - return bool(pkg.ProvidesList and not pkg.VersionList) + return bool(pkg.provides_list and not pkg.version_list) def get_providing_packages(self, virtual): """ @@ -232,15 +232,15 @@ class Cache(object): providers = [] try: vp = self._cache[virtual] - if len(vp.VersionList) != 0: + if len(vp.version_list) != 0: return providers except KeyError: return providers for pkg in self: - v = self._depcache.GetCandidateVer(pkg._pkg) + v = self._depcache.get_candidate_ver(pkg._pkg) if v is None: continue - for p in v.ProvidesList: + for p in v.provides_list: if virtual == p[0]: # we found a pkg that provides this virtual pkg providers.append(pkg) @@ -254,15 +254,15 @@ class Cache(object): apt.progress.FetchProgress, the default is apt.progress.FetchProgress() . """ - lockfile = apt_pkg.Config.FindDir("Dir::State::Lists") + "lock" - lock = apt_pkg.GetLock(lockfile) + lockfile = apt_pkg.config.find_dir("Dir::State::Lists") + "lock" + lock = apt_pkg.get_lock(lockfile) if lock < 0: raise LockFailedException("Failed to lock %s" % lockfile) try: if fetch_progress is None: fetch_progress = apt.progress.FetchProgress() - return self._cache.Update(fetch_progress, self._list) + return self._cache.update(fetch_progress, self._list) finally: os.close(lock) @@ -317,17 +317,17 @@ class Cache(object): # then install res = self.install_archives(pm, install_progress) - if res == pm.ResultCompleted: + if res == pm.result_completed: break - if res == pm.ResultFailed: + if res == pm.result_failed: raise SystemError("installArchives() failed") # reload the fetcher for media swaping - fetcher.Shutdown() - return (res == pm.ResultCompleted) + fetcher.shutdown() + return (res == pm.result_completed) def clear(self): """ Unmark all changes """ - self._depcache.Init() + self._depcache.init() # cache changes @@ -493,7 +493,7 @@ def _test(): for dir in ["/tmp/pytest", "/tmp/pytest/partial"]: if not os.path.exists(dir): os.mkdir(dir) - apt_pkg.Config.Set("Dir::Cache::Archives", "/tmp/pytest") + apt_pkg.config.set("Dir::Cache::Archives", "/tmp/pytest") pm = apt_pkg.PackageManager(cache._depcache) fetcher = apt_pkg.Acquire(apt.progress.TextFetchProgress()) cache._fetch_archives(fetcher, pm) diff --git a/apt/cdrom.py b/apt/cdrom.py index b9625ebf..a98b5d99 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -52,20 +52,20 @@ class Cdrom(object): self._progress = progress # see if we have a alternative mountpoint if mountpoint is not None: - apt_pkg.Config.Set("Acquire::cdrom::mount", mountpoint) + apt_pkg.config.set("Acquire::cdrom::mount", mountpoint) # do not mess with mount points by default if nomount: - apt_pkg.Config.Set("APT::CDROM::NoMount", "true") + apt_pkg.config.set("APT::CDROM::NoMount", "true") else: - apt_pkg.Config.Set("APT::CDROM::NoMount", "false") + apt_pkg.config.set("APT::CDROM::NoMount", "false") def add(self): """Add cdrom to the sources.list.""" - return self._cdrom.Add(self._progress) + return self._cdrom.add(self._progress) def ident(self): """Identify the cdrom.""" - (res, ident) = self._cdrom.Ident(self._progress) + (res, ident) = self._cdrom.ident(self._progress) if res: return ident @@ -77,8 +77,8 @@ class Cdrom(object): # FIXME: throw exception instead return False # Get a list of files - src = glob.glob(apt_pkg.Config.FindDir("Dir::Etc::sourceparts") + '*') - src.append(apt_pkg.Config.FindFile("Dir::Etc::sourcelist")) + src = glob.glob(apt_pkg.config.find_dir("Dir::Etc::sourceparts") + '*') + src.append(apt_pkg.config.find_file("Dir::Etc::sourcelist")) # Check each file for fname in src: for line in open(fname): diff --git a/apt/debfile.py b/apt/debfile.py index 6e4adb39..84bbe3ab 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -52,11 +52,11 @@ class DebPackage(object): def open(self, filename): " open given debfile " self.filename = filename - if not apt_inst.arCheckMember(open(self.filename), "debian-binary"): + if not apt_inst.ar_check_member(open(self.filename), "debian-binary"): raise NoDebArchiveException(_("This is not a valid DEB archive, " "missing '%s' member" % "debian-binary")) - control = apt_inst.debExtractControl(open(self.filename)) + control = apt_inst.deb_extract_control(open(self.filename)) self._sections = apt_pkg.TagSection(control) self.pkgname = self._sections["Package"] @@ -72,9 +72,9 @@ class DebPackage(object): files.append(name) for member in self._supported_data_members: - if apt_inst.arCheckMember(open(self.filename), member): + if apt_inst.ar_check_member(open(self.filename), member): try: - apt_inst.debExtract(open(self.filename), extract_cb, + apt_inst.deb_extract(open(self.filename), extract_cb, member) break except SystemError: @@ -106,7 +106,7 @@ class DebPackage(object): continue inst = self._cache[depname].installed - if inst is not None and apt_pkg.CheckDep(inst.version, oper, ver): + if inst is not None and apt_pkg.check_dep(inst.version, oper, ver): return True return False @@ -129,10 +129,10 @@ class DebPackage(object): # now check if we can satisfy the deps with the candidate(s) # in the cache pkg = self._cache[depname] - cand = self._cache._depcache.GetCandidateVer(pkg._pkg) + cand = self._cache._depcache.get_candidate_ver(pkg._pkg) if not cand: continue - if not apt_pkg.CheckDep(cand.VerStr, oper, ver): + if not apt_pkg.check_dep(cand.ver_str, oper, ver): continue # check if we need to install it @@ -168,7 +168,7 @@ class DebPackage(object): #print "ver: %s" % ver #print "pkgver: %s " % pkgver #print "oper: %s " % oper - if (apt_pkg.CheckDep(pkgver, oper, ver) and not + if (apt_pkg.check_dep(pkgver, oper, ver) and not self.replaces_real_pkg(pkgname, oper, ver)): self._failure_string += _("Conflicts with the installed package " "'%s'" % pkg.name) @@ -211,7 +211,7 @@ class DebPackage(object): """List of package names conflicting with this package.""" key = "Conflicts" try: - return apt_pkg.ParseDepends(self._sections[key]) + return apt_pkg.parse_depends(self._sections[key]) except KeyError: return [] @@ -222,7 +222,7 @@ class DebPackage(object): # find depends for key in "Depends", "PreDepends": try: - depends.extend(apt_pkg.ParseDepends(self._sections[key])) + depends.extend(apt_pkg.parse_depends(self._sections[key])) except KeyError: pass return depends @@ -232,7 +232,7 @@ class DebPackage(object): """List of virtual packages which are provided by this package.""" key = "Provides" try: - return apt_pkg.ParseDepends(self._sections[key]) + return apt_pkg.parse_depends(self._sections[key]) except KeyError: return [] @@ -241,7 +241,7 @@ class DebPackage(object): """List of packages which are replaced by this package.""" key = "Replaces" try: - return apt_pkg.ParseDepends(self._sections[key]) + return apt_pkg.parse_depends(self._sections[key]) except KeyError: return [] @@ -261,7 +261,7 @@ class DebPackage(object): pkgver = None for or_group in self.replaces: for (name, ver, oper) in or_group: - if (name == pkgname and apt_pkg.CheckDep(pkgver, oper, ver)): + if (name == pkgname and apt_pkg.check_dep(pkgver, oper, ver)): self._dbg(3, "we have a replaces in our package for the " "conflict against '%s'" % (pkgname)) return True @@ -298,7 +298,7 @@ class DebPackage(object): else: cachever = self._cache[pkgname].candidate.version if cachever is not None: - cmp = apt_pkg.VersionCompare(cachever, debver) + cmp = apt_pkg.version_compare(cachever, debver) self._dbg(1, "CompareVersion(debver,instver): %s" % cmp) if cmp == 0: return VERSION_SAME @@ -310,11 +310,11 @@ class DebPackage(object): def check(self): """Check if the package is installable.""" - self._dbg(3, "checkDepends") + self._dbg(3, "check_depends") # check arch arch = self._sections["Architecture"] - if arch != "all" and arch != apt_pkg.Config.Find("APT::Architecture"): + if arch != "all" and arch != apt_pkg.config.find("APT::Architecture"): self._dbg(1, "ERROR: Wrong architecture dude!") self._failure_string = _("Wrong architecture '%s'" % arch) return False @@ -341,7 +341,7 @@ class DebPackage(object): if not self.check_conflicts(): return False - if self._cache._depcache.BrokenCount > 0: + if self._cache._depcache.broken_count > 0: self._failure_string = _("Failed to satisfy all dependencies " "(broken cache)") # clean the cache again @@ -351,7 +351,7 @@ class DebPackage(object): def satisfy_depends_str(self, dependsstr): """Satisfy the dependencies in the given string.""" - return self._satisfy_depends(apt_pkg.ParseDepends(dependsstr)) + return self._satisfy_depends(apt_pkg.parse_depends(dependsstr)) def _satisfy_depends(self, depends): """Satisfy the dependencies.""" @@ -459,17 +459,17 @@ class DscSrcPackage(DebPackage): fobj = open(file) tagfile = apt_pkg.TagFile(fobj) - sec = tagfile.Section + sec = tagfile.section try: - while tagfile.Step() == 1: + while tagfile.step() == 1: for tag in depends_tags: if not tag in sec: continue - self._depends.extend(apt_pkg.ParseSrcDepends(sec[tag])) + self._depends.extend(apt_pkg.parse_src_depends(sec[tag])) for tag in conflicts_tags: if not tag in sec: continue - self._conflicts.extend(apt_pkg.ParseSrcDepends(sec[tag])) + self._conflicts.extend(apt_pkg.parse_src_depends(sec[tag])) if 'Source' in sec: self.pkgname = sec['Source'] if 'Binary' in sec: @@ -490,7 +490,7 @@ class DscSrcPackage(DebPackage): """Check if the package is installable..""" if not self.check_conflicts(): for pkgname in self._installed_conflicts: - if self._cache[pkgname]._pkg.Essential: + if self._cache[pkgname]._pkg.essential: raise Exception(_("An essential package would be removed")) self._cache[pkgname].mark_delete() # FIXME: a additional run of the checkConflicts() @@ -525,13 +525,13 @@ def _test(): print ret #s = DscSrcPackage(cache, "../tests/3ddesktop_0.2.9-6.dsc") - #s.checkDep() + #s.check_dep() #print "Missing deps: ",s.missingDeps #print "Print required changes: ", s.requiredChanges s = DscSrcPackage(cache=cache) d = "libc6 (>= 2.3.2), libaio (>= 0.3.96) | libaio1 (>= 0.3.96)" - print s._satisfy_depends(apt_pkg.ParseDepends(d)) + print s._satisfy_depends(apt_pkg.parse_depends(d)) if __name__ == "__main__": _test() diff --git a/apt/package.py b/apt/package.py index 3dbdf058..a24486e1 100644 --- a/apt/package.py +++ b/apt/package.py @@ -130,15 +130,15 @@ class Origin(object): """ def __init__(self, pkg, packagefile): - self.archive = packagefile.Archive - self.component = packagefile.Component - self.label = packagefile.Label - self.origin = packagefile.Origin - self.site = packagefile.Site - self.not_automatic = packagefile.NotAutomatic + self.archive = packagefile.archive + self.component = packagefile.component + self.label = packagefile.label + self.origin = packagefile.origin + self.site = packagefile.site + self.not_automatic = packagefile.not_automatic # check the trust - indexfile = pkg._pcache._list.FindIndex(packagefile) - if indexfile and indexfile.IsTrusted: + indexfile = pkg._pcache._list.find_index(packagefile) + if indexfile and indexfile.is_trusted: self.trusted = True else: self.trusted = False @@ -206,19 +206,19 @@ class Version(object): self._cand = cand def __eq__(self, other): - return self._cand.ID == other._cand.ID + return self._cand.id == other._cand.id def __gt__(self, other): - return apt_pkg.VersionCompare(self.version, other.version) > 0 + return apt_pkg.version_compare(self.version, other.version) > 0 def __lt__(self, other): - return apt_pkg.VersionCompare(self.version, other.version) < 0 + return apt_pkg.version_compare(self.version, other.version) < 0 def __ne__(self, other): return not self.__eq__(other) def __hash__(self): - return self._cand.Hash + return self._cand.hash def __repr__(self): return '' % (self.package.name, @@ -227,60 +227,60 @@ class Version(object): @property def _records(self): """Internal helper that moves the Records to the right position.""" - if self.package._pcache._records.Lookup(self._cand.FileList[0]): + if self.package._pcache._records.lookup(self._cand.file_list[0]): return self.package._pcache._records @property def _translated_records(self): """Internal helper to get the translated description.""" - desc_iter = self._cand.TranslatedDescription - self.package._pcache._records.Lookup(desc_iter.FileList.pop(0)) + desc_iter = self._cand.translated_description + self.package._pcache._records.lookup(desc_iter.file_list.pop(0)) return self.package._pcache._records @property def installed_size(self): """Return the size of the package when installed.""" - return self._cand.InstalledSize + return self._cand.installed_size @property def homepage(self): """Return the homepage for the package.""" - return self._records.Homepage + return self._records.homepage @property def size(self): """Return the size of the package.""" - return self._cand.Size + return self._cand.size @property def architecture(self): """Return the architecture of the package version.""" - return self._cand.Arch + return self._cand.arch @property def downloadable(self): """Return whether the version of the package is downloadable.""" - return bool(self._cand.Downloadable) + return bool(self._cand.downloadable) @property def version(self): """Return the version as a string.""" - return self._cand.VerStr + return self._cand.ver_str @property def summary(self): """Return the short description (one line summary).""" - return self._translated_records.ShortDesc + return self._translated_records.short_desc @property def raw_description(self): """return the long description (raw).""" - return self._records.LongDesc + return self._records.long_desc @property def section(self): """Return the section of the package.""" - return self._cand.Section + return self._cand.section @property def description(self): @@ -292,7 +292,7 @@ class Version(object): for more information. """ desc = '' - dsc = self._translated_records.LongDesc + dsc = self._translated_records.long_desc try: if not isinstance(dsc, unicode): # Only convert where needed (i.e. Python 2.X) @@ -333,32 +333,32 @@ class Version(object): def source_name(self): """Return the name of the source package.""" try: - return self._records.SourcePkg or self.package.name + return self._records.source_pkg or self.package.name except IndexError: return self.package.name @property def priority(self): """Return the priority of the package, as string.""" - return self._cand.PriorityStr + return self._cand.priority_str @property def record(self): """Return a Record() object for this version.""" - return Record(self._records.Record) + return Record(self._records.record) @property def dependencies(self): """Return the dependencies of the package version.""" depends_list = [] - depends = self._cand.DependsList + depends = self._cand.depends_list for t in ["PreDepends", "Depends"]: try: for dep_ver_list in depends[t]: base_deps = [] for dep_or in dep_ver_list: - base_deps.append(BaseDependency(dep_or.TargetPkg.Name, - dep_or.CompType, dep_or.TargetVer, + base_deps.append(BaseDependency(dep_or.target_pkg.name, + dep_or.comp_type, dep_or.target_ver, (t == "PreDepends"))) depends_list.append(Dependency(base_deps)) except KeyError: @@ -369,7 +369,7 @@ class Version(object): def origins(self): """Return a list of origins for the package version.""" origins = [] - for (packagefile, index) in self._cand.FileList: + for (packagefile, index) in self._cand.file_list: origins.append(Origin(self.package, packagefile)) return origins @@ -379,7 +379,7 @@ class Version(object): .. versionadded:: 0.7.10 """ - return self._records.FileName + return self._records.file_name @property def md5(self): @@ -387,7 +387,7 @@ class Version(object): .. versionadded:: 0.7.10 """ - return self._records.MD5Hash + return self._records.md5_hash @property def sha1(self): @@ -395,7 +395,7 @@ class Version(object): .. versionadded:: 0.7.10 """ - return self._records.SHA1Hash + return self._records.sha1_hash @property def sha256(self): @@ -403,17 +403,17 @@ class Version(object): .. versionadded:: 0.7.10 """ - return self._records.SHA256Hash + return self._records.sha256_hash def _uris(self): """Return an iterator over all available urls. .. versionadded:: 0.7.10 """ - for (packagefile, index) in self._cand.FileList: - indexfile = self.package._pcache._list.FindIndex(packagefile) + for (packagefile, index) in self._cand.file_list: + indexfile = self.package._pcache._list.find_index(packagefile) if indexfile: - yield indexfile.ArchiveURI(self._records.FileName) + yield indexfile.archive_uri(self._records.file_name) @property def uris(self): @@ -443,19 +443,19 @@ class Version(object): .. versionadded:: 0.7.10 """ - base = os.path.basename(self._records.FileName) + base = os.path.basename(self._records.file_name) destfile = os.path.join(destdir, base) - if _file_is_same(destfile, self.size, self._records.MD5Hash): + if _file_is_same(destfile, self.size, self._records.md5_hash): print 'Ignoring already existing file:', destfile return acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress()) - apt_pkg.AcquireFile(acq, self.uri, self._records.MD5Hash, self.size, - base, destfile=destfile) - acq.Run() - for item in acq.Items: - if item.Status != item.StatDone: + apt_pkg.AcquireFile(acq, self.uri, self._records.md5_hash, self.size, + base, dest_file=destfile) + acq.run() + for item in acq.items: + if item.status != item.stat_done: raise FetchError("The item %r could not be fetched: %s" % - (item.DestFile, item.ErrorText)) + (item.dest_file, item.error_text)) return os.path.abspath(destfile) def fetch_source(self, destdir="", progress=None, unpack=True): @@ -478,13 +478,13 @@ class Version(object): acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress()) dsc = None - src.Lookup(self.package.name) + src.lookup(self.package.name) try: - while self.version != src.Version: - src.Lookup(self.package.name) + while self.version != src.version: + src.lookup(self.package.name) except AttributeError: raise ValueError("No source for %r" % self) - for md5, size, path, type in src.Files: + for md5, size, path, type in src.files: base = os.path.basename(path) destfile = os.path.join(destdir, base) if type == 'dsc': @@ -497,17 +497,17 @@ class Version(object): continue finally: fobj.close() - apt_pkg.AcquireFile(acq, src.Index.ArchiveURI(path), md5, size, - base, destfile=destfile) - acq.Run() + apt_pkg.AcquireFile(acq, src.index.archive_uri(path), md5, size, + base, dest_file=destfile) + acq.run() - for item in acq.Items: - if item.Status != item.StatDone: + for item in acq.items: + if item.status != item.stat_done: raise FetchError("The item %r could not be fetched: %s" % - (item.DestFile, item.ErrorText)) + (item.dest_file, item.error_text)) if unpack: - outdir = src.Package + '-' + apt_pkg.UpstreamVersion(src.Version) + outdir = src.package + '-' + apt_pkg.upstream_version(src.version) outdir = os.path.join(destdir, outdir) subprocess.check_call(["dpkg-source", "-x", dsc, outdir]) return os.path.abspath(outdir) @@ -530,7 +530,7 @@ class Package(object): self._changelog = "" # Cached changelog def __repr__(self): - return '' % (self._pkg.Name, self._pkg.ID) + return '' % (self._pkg.name, self._pkg.id) def candidate(self): """Return the candidate version of the package. @@ -541,14 +541,14 @@ class Package(object): .. versionadded:: 0.7.9 """ - cand = self._pcache._depcache.GetCandidateVer(self._pkg) + cand = self._pcache._depcache.get_candidate_ver(self._pkg) if cand is not None: return Version(self, cand) def __set_candidate(self, version): """Set the candidate version of the package.""" self._pcache.cache_pre_change() - self._pcache._depcache.SetCandidateVer(self._pkg, version._cand) + self._pcache._depcache.set_candidate_ver(self._pkg, version._cand) self._pcache.cache_post_change() candidate = property(candidate, __set_candidate) @@ -559,26 +559,26 @@ class Package(object): .. versionadded:: 0.7.9 """ - if self._pkg.CurrentVer is not None: - return Version(self, self._pkg.CurrentVer) + if self._pkg.current_ver is not None: + return Version(self, self._pkg.current_ver) @property def name(self): """Return the name of the package.""" - return self._pkg.Name + return self._pkg.name @property def id(self): """Return a uniq ID for the package. This can be used eg. to store additional information about the pkg.""" - return self._pkg.ID + return self._pkg.id def __hash__(self): """Return the hash of the object. This returns the same value as ID, which is unique.""" - return self._pkg.ID + return self._pkg.id @DeprecatedProperty def installedVersion(self): #pylint: disable-msg=C0103 @@ -641,12 +641,12 @@ class Package(object): .. deprecated:: 0.7.9 """ try: - return self.candidate._records.SourcePkg or self._pkg.Name + return self.candidate._records.source_pkg or self._pkg.name except AttributeError: try: - return self.installed._records.SourcePkg or self._pkg.Name + return self.installed._records.source_pkg or self._pkg.name except AttributeError: - return self._pkg.Name + return self._pkg.name @DeprecatedProperty def homepage(self): @@ -659,7 +659,7 @@ class Package(object): @property def section(self): """Return the section of the package.""" - return self._pkg.Section + return self._pkg.section @DeprecatedProperty def priority(self): @@ -724,43 +724,43 @@ class Package(object): @property def marked_install(self): """Return ``True`` if the package is marked for install.""" - return self._pcache._depcache.MarkedInstall(self._pkg) + return self._pcache._depcache.marked_install(self._pkg) @property def marked_upgrade(self): """Return ``True`` if the package is marked for upgrade.""" - return self._pcache._depcache.MarkedUpgrade(self._pkg) + return self._pcache._depcache.marked_upgrade(self._pkg) @property def marked_delete(self): """Return ``True`` if the package is marked for delete.""" - return self._pcache._depcache.MarkedDelete(self._pkg) + return self._pcache._depcache.marked_delete(self._pkg) @property def marked_keep(self): """Return ``True`` if the package is marked for keep.""" - return self._pcache._depcache.MarkedKeep(self._pkg) + return self._pcache._depcache.marked_keep(self._pkg) @property def marked_downgrade(self): """ Package is marked for downgrade """ - return self._pcache._depcache.MarkedDowngrade(self._pkg) + return self._pcache._depcache.marked_downgrade(self._pkg) @property def marked_reinstall(self): """Return ``True`` if the package is marked for reinstall.""" - return self._pcache._depcache.MarkedReinstall(self._pkg) + return self._pcache._depcache.marked_reinstall(self._pkg) @property def is_installed(self): """Return ``True`` if the package is installed.""" - return (self._pkg.CurrentVer is not None) + return (self._pkg.current_ver is not None) @property def is_upgradable(self): """Return ``True`` if the package is upgradable.""" return (self.is_installed and - self._pcache._depcache.IsUpgradable(self._pkg)) + self._pcache._depcache.is_upgradable(self._pkg)) @property def is_auto_removable(self): @@ -771,7 +771,7 @@ class Package(object): is no longer required. """ return self.is_installed and \ - self._pcache._depcache.IsGarbage(self._pkg) + self._pcache._depcache.is_garbage(self._pkg) # sizes @@ -880,15 +880,15 @@ class Package(object): # sources.list # otherwise we fall back to the binary version number src_records = apt_pkg.SourceRecords() - src_rec = src_records.Lookup(src_pkg) + src_rec = src_records.lookup(src_pkg) if src_rec: - src_ver = src_records.Version + src_ver = src_records.version #if apt_pkg.VersionCompare(binver, srcver) > 0: # srcver = binver if not src_ver: src_ver = bin_ver #print "srcver: %s" % src_ver - section = src_records.Section + section = src_records.section #print "srcsect: %s" % section else: # fail into the error handler @@ -954,8 +954,8 @@ class Package(object): changelog_ver = match.group(1) if changelog_ver and ":" in changelog_ver: changelog_ver = changelog_ver.split(":", 1)[1] - if (installed and apt_pkg.VersionCompare(changelog_ver, - installed) <= 0): + if (installed and apt_pkg.version_compare( + changelog_ver, installed) <= 0): break # EOF (shouldn't really happen) changelog += line @@ -992,14 +992,14 @@ class Package(object): .. versionadded:: 0.7.9 """ - return [Version(self, ver) for ver in self._pkg.VersionList] + return [Version(self, ver) for ver in self._pkg.version_list] # depcache actions def mark_keep(self): """Mark a package for keep.""" self._pcache.cache_pre_change() - self._pcache._depcache.MarkKeep(self._pkg) + self._pcache._depcache.mark_keep(self._pkg) self._pcache.cache_post_change() @deprecated_args @@ -1013,15 +1013,15 @@ class Package(object): as well. The default is to keep the configuration. """ self._pcache.cache_pre_change() - self._pcache._depcache.MarkDelete(self._pkg, purge) + self._pcache._depcache.mark_delete(self._pkg, purge) # try to fix broken stuffsta - if auto_fix and self._pcache._depcache.BrokenCount > 0: + if auto_fix and self._pcache._depcache.broken_count > 0: fix = apt_pkg.ProblemResolver(self._pcache._depcache) - fix.Clear(self._pkg) - fix.Protect(self._pkg) - fix.Remove(self._pkg) - fix.InstallProtect() - fix.Resolve() + fix.clear(self._pkg) + fix.protect(self._pkg) + fix.remove(self._pkg) + fix.install_protect() + fix.resolve() self._pcache.cache_post_change() @deprecated_args @@ -1040,13 +1040,13 @@ class Package(object): when no other package depends on it. """ self._pcache.cache_pre_change() - self._pcache._depcache.MarkInstall(self._pkg, auto_inst, from_user) + self._pcache._depcache.mark_install(self._pkg, auto_inst, from_user) # try to fix broken stuff - if auto_fix and self._pcache._depcache.BrokenCount > 0: + if auto_fix and self._pcache._depcache.broken_count > 0: fixer = apt_pkg.ProblemResolver(self._pcache._depcache) - fixer.Clear(self._pkg) - fixer.Protect(self._pkg) - fixer.Resolve(True) + fixer.clear(self._pkg) + fixer.protect(self._pkg) + fixer.resolve(True) self._pcache.cache_post_change() def mark_upgrade(self): @@ -1056,7 +1056,7 @@ class Package(object): else: # FIXME: we may want to throw a exception here sys.stderr.write(("MarkUpgrade() called on a non-upgrable pkg: " - "'%s'\n") % self._pkg.Name) + "'%s'\n") % self._pkg.name) def commit(self, fprogress, iprogress): """Commit the changes. @@ -1067,7 +1067,7 @@ class Package(object): The parameter *iprogress* refers to an InstallProgress() object, as found in apt.progress. """ - self._pcache._depcache.Commit(fprogress, iprogress) + self._pcache._depcache.commit(fprogress, iprogress) if not apt_pkg._COMPAT_0_7: @@ -1149,8 +1149,8 @@ def _test(): if pkg.is_upgradable: if random.randint(0, 1) == 1: pkg.mark_install(i) - print "Broken: %s " % cache._depcache.BrokenCount - print "InstCount: %s " % cache._depcache.InstCount + print "Broken: %s " % cache._depcache.broken_count + print "InstCount: %s " % cache._depcache.inst_count print # get a new cache @@ -1163,8 +1163,8 @@ def _test(): cache[name].mark_delete(i) except SystemError: print "Error trying to remove: %s " % name - print "Broken: %s " % cache._depcache.BrokenCount - print "DelCount: %s " % cache._depcache.DelCount + print "Broken: %s " % cache._depcache.broken_count + print "DelCount: %s " % cache._depcache.del_count # self-test if __name__ == "__main__": diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 769942ce..d2a9d497 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -153,8 +153,8 @@ class TextFetchProgress(FetchProgress): FetchProgress.pulse(self) if self.currentCPS > 0: s = "[%2.f%%] %sB/s %s" % (self.percent, - apt_pkg.SizeToStr(int(self.currentCPS)), - apt_pkg.TimeToStr(int(self.eta))) + apt_pkg.size_to_str(int(self.currentCPS)), + apt_pkg.time_to_str(int(self.eta))) else: s = "%2.f%% [Working]" % (self.percent) print "\r%s" % (s), @@ -184,7 +184,7 @@ class DumbInstallProgress(object): def run(self, pm): """Start installation.""" - return pm.DoInstall() + return pm.do_install() def finishUpdate(self): """Called when update has finished.""" @@ -278,7 +278,7 @@ class InstallProgress(DumbInstallProgress): pid = self.fork() if pid == 0: # child - res = pm.DoInstall(self.writefd) + res = pm.do_install(self.writefd) os._exit(res) self.child_pid = pid res = self.waitChild() diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index 36d459bc..06ece2d5 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -247,7 +247,7 @@ class GFetchProgress(gobject.GObject, apt.progress.FetchProgress): "%(speed)s/s") % \ {"current": currentItem, "total": self.totalItems, - "speed": apt_pkg.SizeToStr(self.currentCPS)}) + "speed": apt_pkg.size_to_str(self.currentCPS)}) else: text = (_("Downloading file %(current)li of %(total)li") % \ {"current": currentItem, diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index ce44e48b..268d9b9f 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -148,7 +148,7 @@ class DistInfo: base_dir = "/usr/share/python-apt/templates"): self.metarelease_uri = '' self.templates = [] - self.arch = apt_pkg.Config.Find("APT::Architecture") + self.arch = apt_pkg.config.find("APT::Architecture") location = None match_loc = re.compile(r"^#LOC:(.+)$") diff --git a/aptsources/sourceslist.py b/aptsources/sourceslist.py index fdc0f029..710bfe15 100644 --- a/aptsources/sourceslist.py +++ b/aptsources/sourceslist.py @@ -88,8 +88,8 @@ class SourceEntry: self.comment = "" # (optional) comment self.line = line # the original sources.list line if file is None: - file = apt_pkg.Config.FindDir( - "Dir::Etc")+apt_pkg.Config.Find("Dir::Etc::sourcelist") + file = apt_pkg.config.find_dir( + "Dir::Etc")+apt_pkg.config.find("Dir::Etc::sourcelist") self.file = file # the file that the entry is located in self.parse(line) self.template = None # type DistInfo.Suite @@ -237,10 +237,10 @@ class SourcesList(object): """ update the list of known entries """ self.list = [] # read sources.list - file = apt_pkg.Config.FindFile("Dir::Etc::sourcelist") + file = apt_pkg.config.find_file("Dir::Etc::sourcelist") self.load(file) # read sources.list.d - partsdir = apt_pkg.Config.FindDir("Dir::Etc::sourceparts") + partsdir = apt_pkg.config.find_dir("Dir::Etc::sourceparts") for file in glob.glob("%s/*.list" % partsdir): self.load(file) # check if the source item fits a predefined template @@ -312,12 +312,12 @@ class SourcesList(object): def restore_backup(self, backup_ext): " restore sources.list files based on the backup extension " - file = apt_pkg.Config.FindFile("Dir::Etc::sourcelist") + file = apt_pkg.config.find_file("Dir::Etc::sourcelist") if os.path.exists(file+backup_ext) and \ os.path.exists(file): shutil.copy(file+backup_ext, file) # now sources.list.d - partsdir = apt_pkg.Config.FindDir("Dir::Etc::sourceparts") + partsdir = apt_pkg.config.find_dir("Dir::Etc::sourceparts") for file in glob.glob("%s/*.list" % partsdir): if os.path.exists(file+backup_ext): shutil.copy(file+backup_ext, file) @@ -355,7 +355,7 @@ class SourcesList(object): files = {} # write an empty default config file if there aren't any sources if len(self.list) == 0: - path = apt_pkg.Config.FindFile("Dir::Etc::sourcelist") + path = apt_pkg.config.find_file("Dir::Etc::sourcelist") header = ( "## See sources.list(5) for more information, especialy\n" "# Remember that you can only use http, ftp or file URIs\n" @@ -433,7 +433,7 @@ class SourceEntryMatcher: # some simple tests if __name__ == "__main__": - apt_pkg.InitConfig() + apt_pkg.init_config() sources = SourcesList() for entry in sources: diff --git a/doc/source/apt_pkg.rst b/doc/source/apt_pkg.rst index 8c602f37..39b48c35 100644 --- a/doc/source/apt_pkg.rst +++ b/doc/source/apt_pkg.rst @@ -13,17 +13,17 @@ Module Initialization Initialization is needed for most functions, but not for all of them. Some can be called without having run init*(), but will not return the expected value. -.. function:: initConfig +.. function:: init_config Initialize the configuration of apt. This is needed for most operations. -.. function:: initSystem +.. function:: init_system Initialize the system. .. function:: init - Deprecated function. Use initConfig() and initSystem() instead. + Deprecated function. Use init_config() and init_system() instead. Working with the cache ---------------------- @@ -38,49 +38,49 @@ Working with the cache Return the :class:`Package()` object for the package name given by *pkgname*. - .. method:: Close() + .. method:: close() Close the package cache. - .. method:: Open([progress]) + .. method:: open([progress]) Open the package cache again. The parameter *progress* may be set to an :class:`apt.progress.OpProgress()` object or `None`. - .. method:: Update(progress, list) + .. method:: update(progress, list) Update the package cache. The parameter *progress* points to an :class:`apt.progress.FetchProgress()` object. The parameter *list* refers to a :class:`SourceList()` object. - .. attribute:: DependsCount + .. attribute:: depends_count The total number of dependencies. - .. attribute:: PackageCount + .. attribute:: package_count The total number of packages available in the cache. - .. attribute:: ProvidesCount + .. attribute:: provides_count The number of provided packages. - .. attribute:: VerFileCount + .. attribute:: ver_file_count .. todo:: Seems to be some mixture of versions and pkgFile. - .. attribute:: VersionCount + .. attribute:: version_count The total number of package versions available in the cache. - .. attribute:: PackageFileCount + .. attribute:: package_file_count The total number of Packages files available (the Packages files listing the packages). This is the same as the length of the list in - the attribute :attr:`FileList`. + the attribute :attr:`file_list`. - .. attribute:: FileList + .. attribute:: file_list A list of :class:`PackageFile` objects. @@ -92,7 +92,7 @@ Working with the cache The DepCache object contains various methods to manipulate the cache, to install packages, to remove them, and much more. - .. method:: Commit(fprogress, iprogress) + .. method:: commit(fprogress, iprogress) Apply all the changes made. @@ -102,11 +102,11 @@ Working with the cache The parameter *iprogress* has to be set to an instance of apt.progress.InstallProgress or one of its subclasses. - .. method:: FixBroken() + .. method:: fix_broken() Try to fix all broken packages in the cache. - .. method:: GetCandidateVer(pkg) + .. method:: get_candidate_ver(pkg) Return the candidate version of the package, ie. the version that would be installed normally. @@ -116,31 +116,31 @@ Working with the cache This method returns a :class:`Version` object. - .. method:: SetCandidateVer(pkg, version) + .. method:: set_candidate_ver(pkg, version) - The opposite of :meth:`pkgDepCache.GetCandidateVer`. Set the candidate + The opposite of :meth:`pkgDepCache.get_candidate_ver`. Set the candidate version of the :class:`Package` *pkg* to the :class:`Version` *version*. - .. method:: Upgrade([distUpgrade=False]) + .. method:: upgrade([dist_upgrade=False]) Perform an upgrade. More detailed, this marks all the upgradable packages for upgrade. You still need to call - :meth:`pkgDepCache.Commit` for the changes to apply. + :meth:`pkgDepCache.commit` for the changes to apply. - To perform a dist-upgrade, the optional parameter *distUpgrade* has + To perform a dist-upgrade, the optional parameter *dist_upgrade* has to be set to True. - .. method:: FixBroken() + .. method:: fix_broken() Fix broken packages. - .. method:: ReadPinFile() + .. method:: read_pin_file() Read the policy, eg. /etc/apt/preferences. - .. method:: MinimizeUpgrade() + .. method:: minimize_upgrade() Go over the entire set of packages and try to keep each package marked for upgrade. If a conflict is generated then the package is restored. @@ -148,101 +148,101 @@ Working with the cache .. todo:: Explain better.. - .. method:: MarkKeep(pkg) + .. method:: mark_keep(pkg) Mark the :class:`Package` *pkg* for keep. - .. method:: MarkDelete(pkg[, purge]) + .. method:: mark_delete(pkg[, purge]) Mark the :class:`Package` *pkg* for delete. If *purge* is True, the configuration files will be removed as well. - .. method:: MarkInstall(pkg[, autoInst=True[, fromUser=True]]) + .. method:: mark_install(pkg[, auto_inst=True[, from_user=True]]) Mark the :class:`Package` *pkg* for install. - If *autoInst* is ``True``, the dependencies of the package will be + If *auto_inst* is ``True``, the dependencies of the package will be installed as well. This is the default. - If *fromUser* is ``True``, the package will be marked as manually + If *from_user* is ``True``, the package will be marked as manually installed. This is the default. - .. method:: SetReinstall(pkg) + .. method:: set_re_install(pkg) Set if the :class:`Package` *pkg* should be reinstalled. - .. method:: IsUpgradable(pkg) + .. method:: is_upgradable(pkg) Return ``1`` if the package is upgradable. The package can be upgraded by calling :meth:`pkgDepCache.MarkInstall`. - .. method:: IsNowBroken(pkg) + .. method:: is_now_broken(pkg) Return `1` if the package is broken now (including changes made, but not committed). - .. method:: IsInstBroken(pkg) + .. method:: is_inst_broken(pkg) Return ``1`` if the package is broken on the current install. This takes changes which have not been committed not into effect. - .. method:: IsGarbage(pkg) + .. method:: is_garbage(pkg) Return ``1`` if the package is garbage, ie. if it is automatically installed and no longer referenced by other packages. - .. method:: IsAutoInstalled(pkg) + .. method:: is_auto_installed(pkg) Return ``1`` if the package is automatically installed (eg. as the dependency of another package). - .. method:: MarkedInstall(pkg) + .. method:: marked_install(pkg) Return ``1`` if the package is marked for install. - .. method:: MarkedUpgrade(pkg) + .. method:: marked_upgrade(pkg) Return ``1`` if the package is marked for upgrade. - .. method:: MarkedDelete(pkg) + .. method:: marked_delete(pkg) Return ``1`` if the package is marked for delete. - .. method:: MarkedKeep(pkg) + .. method:: marked_keep(pkg) Return ``1`` if the package is marked for keep. - .. method:: MarkedReinstall(pkg) + .. method:: marked_reinstall(pkg) Return ``1`` if the package should be installed. - .. method:: MarkedDowngrade(pkg) + .. method:: marked_downgrade(pkg) Return ``1`` if the package should be downgraded. - .. attribute:: KeepCount + .. attribute:: keep_count Integer, number of packages marked as keep - .. attribute:: InstCount + .. attribute:: inst_count Integer, number of packages marked for installation. - .. attribute:: DelCount + .. attribute:: del_count Number of packages which should be removed. - .. attribute:: BrokenCount + .. attribute:: broken_count Number of packages which are broken. - .. attribute:: UsrSize + .. attribute:: usr_size The size required for the changes on the filesystem. If you install packages, this is positive, if you remove them its negative. - .. attribute:: DebSize + .. attribute:: deb_size The size of the packages which are needed for the changes to be applied. @@ -256,7 +256,7 @@ Working with the cache :class:`PackageManager` objects provide several methods and attributes, which will be listed here: - .. method:: GetArchives(fetcher, list, records) + .. method:: get_archives(fetcher, list, records) Add all the selected packages to the :class:`Acquire()` object *fetcher*. @@ -265,34 +265,34 @@ Working with the cache The parameter *records* refers to a :class:`PackageRecords()` object. - .. method:: DoInstall() + .. method:: do_install() Install the packages. - .. method:: FixMissing + .. method:: fix_missing Fix the installation if a package could not be downloaded. - .. attribute:: ResultCompleted + .. attribute:: result_completed A constant for checking whether the the result is 'completed'. - Compare it against the return value of :meth:`PkgManager.GetArchives` - or :meth:`PkgManager.DoInstall`. + Compare it against the return value of :meth:`PackageManager.get_archives` + or :meth:`PackageManager.do_install`. - .. attribute:: ResultFailed + .. attribute:: result_failed A constant for checking whether the the result is 'failed'. - Compare it against the return value of :meth:`PkgManager.GetArchives` - or :meth:`PkgManager.DoInstall`. + Compare it against the return value of :meth:`PackageManager.get_archives` + or :meth:`PackageManager.do_install`. - .. attribute:: ResultIncomplete + .. attribute:: result_incomplete A constant for checking whether the the result is 'incomplete'. - Compare it against the return value of :meth:`PkgManager.GetArchives` - or :meth:`PkgManager.DoInstall`. + Compare it against the return value of :meth:`PackageManager.get_archives` + or :meth:`PackageManager.do_install`. Improve performance with :class:`ActionGroup` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -336,13 +336,13 @@ Resolving Dependencies .. class:: ProblemResolver(depcache) Return a new :class:`ProblemResolver` object. The parameter *depcache* - specifies a :class:`pkgDepCache` object as returned by :func:`GetDepCache`. + specifies a :class:`pDepCache` object. The problem resolver helps when there are problems in the package selection. An example is a package which conflicts with another, already installed package. - .. method:: Protect(pkg) + .. method:: protect(pkg) Protect the :class:`Package()` object given by the parameter *pkg*. @@ -350,11 +350,11 @@ Resolving Dependencies Really document it. - .. method:: InstallProtect() + .. method:: install_protect() Protect all installed packages from being removed. - .. method:: Remove(pkg) + .. method:: remove(pkg) Remove the :class:`Package()` object given by the parameter *pkg*. @@ -362,7 +362,7 @@ Resolving Dependencies Really document it. - .. method:: Clear(pkg) + .. method:: clear(pkg) Reset the :class:`Package()` *pkg* to the default state. @@ -370,11 +370,11 @@ Resolving Dependencies Really document it. - .. method:: Resolve() + .. method:: resolve() Try to resolve problems by installing and removing packages. - .. method:: ResolveByKeep() + .. method:: resolve_by_keep() Try to resolve problems only by using keep. @@ -386,65 +386,65 @@ Resolving Dependencies A :class:`PackageFile` represents a Packages file, eg. /var/lib/dpkg/status. - .. attribute:: Architecture + .. attribute:: architecture The architecture of the package file. - .. attribute:: Archive + .. attribute:: archive The archive (eg. unstable) - .. attribute:: Component + .. attribute:: component The component (eg. main) - .. attribute:: FileName + .. attribute:: file_name The name of the file. - .. attribute:: ID + .. attribute:: id The ID of the package. This is an integer which can be used to store further information about the file [eg. as dictionary key]. - .. attribute:: IndexType + .. attribute:: index_type The sort of the index file. In normal cases, this is 'Debian Package Index'. - .. attribute:: Label + .. attribute:: label The Label, as set in the Release file - .. attribute:: NotAutomatic + .. attribute:: not_automatic Whether packages from this list will be updated automatically. The default for eg. example is 0 (aka false). - .. attribute:: NotSource + .. attribute:: not_source Whether the file has no source from which it can be updated. In such a case, the value is 1; else 0. /var/lib/dpkg/status is 0 for example. Example:: - for pkgfile in cache.FileList: - if pkgfile.NotSource: - print 'The file %s has no source.' % pkgfile.FileName + for pkgfile in cache.file_list: + if pkgfile.not_source: + print 'The file %s has no source.' % pkgfile.file_name - .. attribute:: Origin + .. attribute:: origin The Origin, as set in the Release file - .. attribute:: Site + .. attribute:: site The hostname of the site. - .. attribute:: Size + .. attribute:: size The size of the file. - .. attribute:: Version + .. attribute:: version The version, as set in the release file (eg. "4.0" for "Etch") @@ -465,78 +465,78 @@ Example Attributes: - .. attribute:: CurrentVer + .. attribute:: current_ver The version currently installed, or None. This returns a :class:`Version` object. - .. attribute:: ID + .. attribute:: id The ID of the package. This can be used to store information about the package. The ID is an int value. - .. attribute:: Name + .. attribute:: name This is the name of the package. - .. attribute:: ProvidesList + .. attribute:: provides_list A list of packages providing this package. More detailed, this is a list of tuples (str:pkgname, ????, :class:`Version`). If you want to check for check for virtual packages, the expression - ``pkg.ProvidesList and not pkg.VersionList`` helps you. It detects if + ``pkg.provides_list and not pkg._version_list`` helps you. It detects if the package is provided by something else and is not available as a real package. - .. attribute:: RevDependsList + .. attribute:: rev_depends_list An iterator of :class:`Dependency` objects for dependencies on this package. - .. attribute:: Section + .. attribute:: section The section of the package, as specified in the record. The list of possible sections is defined in the Policy. - .. attribute:: VersionList + .. attribute:: version_list A list of :class:`Version` objects for all versions available in the cache. **States**: - .. attribute:: SelectedState + .. attribute:: selected_state The state we want it to be, ie. if you mark a package for installation, - this is :attr:`apt_pkg.SelStateInstall`. + this is :attr:`apt_pkg.SELSTATE_INSTALL`. See :ref:`SelStates` for a list of available states. - .. attribute:: InstState + .. attribute:: inst_state The state the currently installed version is in. This is normally - :attr:`apt_pkg.InstStateOK`, unless the installation failed. + :attr:`apt_pkg.INSTSTATE_OK`, unless the installation failed. See :ref:`InstStates` for a list of available states. - .. attribute:: CurState + .. attribute:: cur_state The current state of the package (not installed, unpacked, installed, etc). See :ref:`CurStates` for a list of available states. **Flags**: - .. attribute:: Auto + .. attribute:: auto Whether the package was installed automatically as a dependency of another package. (or marked otherwise as automatically installed) - .. attribute:: Essential + .. attribute:: essential Whether the package is essential. - .. attribute:: Important + .. attribute:: important Whether the package is important. @@ -553,25 +553,25 @@ Example: The version object contains all information related to a specific package version. - .. attribute:: VerStr + .. attribute:: ver_str The version, as a string. - .. attribute:: Section + .. attribute:: section The usual sections (eg. admin, net, etc.). Prefixed with the component name for packages not in main (eg. non-free/admin). - .. attribute:: Arch + .. attribute:: arch The architecture of the package, eg. amd64 or all. - .. attribute:: FileList + .. attribute:: file_list A list of (:class:`PackageFile`, int: index) tuples for all Package files containing this version of the package. - .. attribute:: DependsListStr + .. attribute:: depends_list_str A dictionary of dependencies. The key specifies the type of the dependency ('Depends', 'Recommends', etc.). @@ -601,58 +601,58 @@ Example: ] } - .. attribute:: DependsList + .. attribute:: depends_list This is basically the same as :attr:`Version.DependsListStr`, but instead of the ('pkgname', 'version', 'relation') tuples, it returns :class:`Dependency` objects, which can assist you with useful functions. - .. attribute:: ParentPkg + .. attribute:: parent_pkg The :class:`Package` object this version belongs to. - .. attribute:: ProvidesList + .. attribute:: provides_list This returns a list of all packages provided by this version. Like - :attr:`Package.ProvidesList`, it returns a list of tuples + :attr:`Package.provides_list`, it returns a list of tuples of the form ('virtualpkgname', ???, :class:`Version`), where as the last item is the same as the object itself. - .. attribute:: Size + .. attribute:: size The size of the .deb file, in bytes. - .. attribute:: InstalledSize + .. attribute:: installed_size The size of the package (in kilobytes), when unpacked on the disk. - .. attribute:: Hash + .. attribute:: hash An integer hash value. - .. attribute:: ID + .. attribute:: id An integer id. - .. attribute:: Priority + .. attribute:: priority The integer representation of the priority. This can be used to speed - up comparisons a lot, compared to :attr:`Version.PriorityStr`. + up comparisons a lot, compared to :attr:`Version.priority_str`. The values are defined in the :mod:`apt_pkg` extension, see :ref:`Priorities` for more information. - .. attribute:: PriorityStr + .. attribute:: priority_str Return the priority of the package version, as a string, eg. "optional". - .. attribute:: Downloadable + .. attribute:: downloadable Whether this package can be downloaded from a remote site. - .. attribute:: TranslatedDescription + .. attribute:: translated_description Return a :class:`Description` object. @@ -663,7 +663,7 @@ Example: Represent a dependency from one package to another one. - .. method:: AllTargets + .. method:: all_targets A list of :class:`Version` objects which satisfy the dependency, and do not conflict with already installed ones. @@ -673,40 +673,40 @@ Example: other candidates is already installed. This leads to results being very close to the normal package installation. - .. method:: SmartTargetPkg + .. method:: smart_target_pkg Return a :class:`Version` object of a package which satisfies the dependency and does not conflict with installed packages (the 'natural target'). - .. attribute:: TargetVer + .. attribute:: target_ver The target version of the dependency, as string. Empty string if the dependency is not versioned. - .. attribute:: TargetPkg + .. attribute:: target_pkg The :class:`Package` object of the target package. - .. attribute:: ParentVer + .. attribute:: parent_ver The :class:`Version` object of the parent version, ie. the package which declares the dependency. - .. attribute:: ParentPkg + .. attribute:: parent_pkg The :class:`Package` object of the package which declares the dependency. This is the same as using ParentVer.ParentPkg. - .. attribute:: CompType + .. attribute:: comp_type The type of comparison (>=, ==, >>, <=), as string. - .. attribute:: DepType + .. attribute:: dep_type The type of the dependency, as string, eg. "Depends". - .. attribute:: ID + .. attribute:: id The ID of the package, as integer. @@ -724,7 +724,7 @@ broken dependencies: Represent the description of the package. - .. attribute:: LanguageCode + .. attribute:: language_code The language code of the description @@ -732,7 +732,7 @@ broken dependencies: The md5 hashsum of the description - .. attribute:: FileList + .. attribute:: file_list A list of tuples (:class:`PackageFile`, int: index). @@ -747,10 +747,10 @@ broken dependencies: .. class:: MetaIndex - .. attribute:: URI - .. attribute:: Dist - .. attribute:: IsTrusted - .. attribute:: IndexFiles + .. attribute:: uri + .. attribute:: dist + .. attribute:: is_trusted + .. attribute:: index_files :class:`PackageIndexFile` @@ -758,27 +758,27 @@ broken dependencies: .. class:: PackageIndexFile - .. method:: ArchiveURI(path) + .. method:: archive_uri(path) Return the full url to path in the archive. - .. attribute:: Label + .. attribute:: label Return the Label. - .. attribute:: Exists + .. attribute:: exists Return whether the file exists. - .. attribute:: HasPackages + .. attribute:: has_packages Return whether the file has packages. - .. attribute:: Size + .. attribute:: size Size of the file - .. attribute:: IsTrusted + .. attribute:: is_trusted Whether we can trust the file. @@ -794,13 +794,13 @@ Records Provide access to the packages records. This provides very useful attributes for fast (convient) access to some fields of the record. - .. method:: Lookup(verfile_iter) + .. method:: lookup(verfile_iter) Change the actual package to the package given by the verfile_iter. The parameter *verfile_iter* refers to a tuple consisting of (:class:`PackageFile()`, int: index), as returned by various - attributes, including :attr:`Version.FileList`. + attributes, including :attr:`Version.file_list`. Example (shortened):: @@ -809,69 +809,69 @@ Records # Now you can access the record print records.SourcePkg # == python-apt - .. attribute:: FileName + .. attribute:: file_name Return the field 'Filename' of the record. This is the path to the package, relative to the base path of the archive. - .. attribute:: MD5Hash + .. attribute:: md5_hash Return the MD5 hashsum of the package This refers to the field 'MD5Sum' in the raw record. - .. attribute:: SHA1Hash + .. attribute:: sha1_hash Return the SHA1 hashsum of the package. This refers to the field 'SHA1' in the raw record. - .. attribute:: SHA256Hash + .. attribute:: sha256_hash Return the SHA256 hashsum of the package. This refers to the field 'SHA256' in the raw record. .. versionadded:: 0.7.9 - .. attribute:: SourcePkg + .. attribute:: source_pkg Return the source package. - .. attribute:: SourceVer + .. attribute:: source_ver Return the source version. - .. attribute:: Maintainer + .. attribute:: maintainer Return the maintainer of the package. - .. attribute:: ShortDesc + .. attribute:: short_desc Return the short description. This is the summary on the first line of the 'Description' field. - .. attribute:: LongDesc + .. attribute:: long_desc Return the long description. These are lines 2-END from the 'Description' field. - .. attribute:: Name + .. attribute:: name Return the name of the package. This is the 'Package' field. - .. attribute:: Homepage + .. attribute:: homepage Return the Homepage. This is the 'Homepage' field. - .. attribute:: Record + .. attribute:: record Return the whole record as a string. If you want to access fields of the record not available as an attribute, you can use - :func:`apt_pkg.ParseSection` to parse the record and access the field + :class:`apt_pkg.TagSection` to parse the record and access the field name. Example:: - section = apt_pkg.ParseSection(records.Record) - print section['SHA256'] + section = apt_pkg.TagSection(records.record) + print section['SHA256'] # Use records.sha256_hash instead .. class:: SourceRecords @@ -886,16 +886,16 @@ Records anymore (same applies when no Lookup has been made, or when it has been restarted). - .. method:: Lookup(pkgname) + .. method:: lookup(pkgname) Lookup the record for the package named *pkgname*. To access all available records, you need to call it multiple times. - Imagine a package P with two versions X, Y. The first ``Lookup(P)`` - would set the record to version X and the second ``Lookup(P)`` to + Imagine a package P with two versions X, Y. The first ``lookup(P)`` + would set the record to version X and the second ``lookup(P)`` to version Y. - .. method:: Restart() + .. method:: restart() Restart the lookup. @@ -903,26 +903,26 @@ Records would set the record to version X and the second ``Lookup(P)`` to version Y. - If you now call ``Restart()``, the internal position will be cleared. - Now you can call ``Lookup(P)`` again to move to X. + If you now call ``restart()``, the internal position will be cleared. + Now you can call ``lookup(P)`` again to move to X. - .. attribute:: Package + .. attribute:: package The name of the source package. - .. attribute:: Version + .. attribute:: version A string describing the version of the source package. - .. attribute:: Maintainer + .. attribute:: maintainer A string describing the name of the maintainer. - .. attribute:: Section + .. attribute:: section A string describing the section. - .. attribute:: Record + .. attribute:: record The whole record, as a string. You can use :func:`apt_pkg.ParseSection` if you need to parse it. @@ -930,22 +930,22 @@ Records You need to parse the record if you want to access fields not available via the attributes, eg. 'Standards-Version' - .. attribute:: Binaries + .. attribute:: binaries Return a list of strings describing the package names of the binaries created by the source package. This matches the 'Binary' field in the raw record. - .. attribute:: Index + .. attribute:: index The index in the Sources files. - .. attribute:: Files + .. attribute:: files The list of files. This returns a list of tuples with the contents ``(str: md5, int: size, str: path, str:type)``. - .. attribute:: BuildDepends + .. attribute:: build_depends Return the list of Build dependencies, as ``(str: package, str: version, int: op, int: type)``. @@ -1015,24 +1015,24 @@ installation. Acquire items have multiple methods: - .. method:: Acquire.Run() + .. method:: run() - Fetch all the items which have been added by :func:`GetPkgAcqFile`. + Fetch all the items which have been added by :class:`AcquireFile`. - .. method:: Acquire.Shutdown() + .. method:: shutdown() Shut the fetcher down. - .. attribute:: Acquire.TotalNeeded + .. attribute:: total_needed The total amount of bytes needed (including those of files which are already present) - .. attribute:: Acquire.FetchNeeded + .. attribute:: fetch_needed The total amount of bytes which need to be fetched. - .. attribute:: Acquire.PartialPresent + .. attribute:: partial_present Whether some files have been acquired already. (???) @@ -1040,70 +1040,70 @@ installation. The :class:`AcquireItem()` objects represent the items of a :class:`Acquire` object. :class:`AcquireItem()` objects can not be created - by the user, they are solely available through the :attr:`Acquire.Items` + by the user, they are solely available through the :attr:`Acquire.items` list of an :class:`Acquire` object. - .. attribute:: ID + .. attribute:: id The ID of the item. - .. attribute:: Complete + .. attribute:: complete Is the item completely acquired? - .. attribute:: Local + .. attribute:: local Is the item a local file? - .. attribute:: IsTrusted + .. attribute:: is_trusted Can the file be trusted? - .. attribute:: FileSize + .. attribute:: file_size The size of the file, in bytes. - .. attribute:: ErrorText + .. attribute:: error_text The error message. For example, when a file does not exist on a http server, this will contain a 404 error message. - .. attribute:: DestFile + .. attribute:: dest_file The location the file is saved as. - .. attribute:: DescURI + .. attribute:: desc_uri The source location. **Status**: - .. attribute:: Status + .. attribute:: status Integer, representing the status of the item. - .. attribute:: StatIdle + .. attribute:: stat_idle - Constant for comparing :attr:`AcquireItem.Status`. + Constant for comparing :attr:`AcquireItem.status`. - .. attribute:: StatFetching + .. attribute:: stat_fetching - Constant for comparing :attr:`AcquireItem.Status` + Constant for comparing :attr:`AcquireItem.status` - .. attribute:: StatDone + .. attribute:: stat_done - Constant for comparing :attr:`AcquireItem.Status` + Constant for comparing :attr:`AcquireItem.status` - .. attribute:: StatError + .. attribute:: stat_error - Constant for comparing :attr:`AcquireItem.Status` + Constant for comparing :attr:`AcquireItem.status` - .. attribute:: StatAuthError + .. attribute:: stat_auth_error - Constant for comparing :attr:`AcquireItem.Status` + Constant for comparing :attr:`AcquireItem.status` -.. class:: AcquireFile(owner, uri[, md5, size, descr, shortdescr, destdir, destfile]) +.. class:: AcquireFile(owner, uri[, md5, size, descr, short_descr, dest_dir, dest_file]) Create a new :class:`AcquireFile()` object and register it with *acquire*, so it will be fetched. AcquireFile objects provide no methods or attributes @@ -1123,12 +1123,12 @@ installation. which can then be used to calculate the progress and validate the download. The parameter *descr* is a descripition of the download. It may be - used to describe the item in the progress class. *shortDescr* is the + used to describe the item in the progress class. *short_descr* is the short form of it. - You can use *destdir* to manipulate the directory where the file will - be saved in. Instead of *destdir*, you can also specify the full path to - the file using the parameter *destfile*. You can not combine both. + You can use *dest_dir* to manipulate the directory where the file will + be saved in. Instead of *dest_dir*, you can also specify the full path to + the file using the parameter *dest_file*. You can not combine both. @@ -1192,24 +1192,24 @@ section as a string. An example for working with a TagFile could look like:: tagf = apt_pkg.TagFile(open('/var/lib/dpkg/status')) - tagf.Step() - print tagf.Section['Package'] + tagf.step() + print tagf.section['Package'] - .. method:: Step + .. method:: step Step forward to the next section. This simply returns ``1`` if OK, and ``0`` if there is no section - .. method:: Offset + .. method:: offset Return the current offset (in bytes) from the beginning of the file. - .. method:: Jump(offset) + .. method:: jump(offset) - Jump back/forward to *offset*. Use ``Jump(0)`` to jump to the + Jump back/forward to *offset*. Use ``jump(0)`` to jump to the beginning of the file again. - .. attribute:: Section + .. attribute:: section This is the current :class:`TagSection()` instance. @@ -1228,16 +1228,16 @@ section as a string. .. versionadded:: 0.8.0 - .. method:: Bytes + .. method:: bytes The number of bytes in the section. - .. method:: Find(key, default='') + .. method:: find(key, default='') Return the value of the field at the key *key* if available, else return *default*. - .. method:: FindFlag(key) + .. method:: find_flag(key) Find a yes/no value for the key *key*. An example for such a field is 'Essential'. @@ -1257,31 +1257,31 @@ section as a string. Return a list of keys in the section. -.. autofunction:: RewriteSection(section, order, rewrite_list) +.. autofunction:: rewrite_section(section, order, rewrite_list) -.. data:: RewritePackageOrder +.. data:: REWRITE_PACKAGE_ORDER The order in which the information for binary packages should be rewritten, i.e. the order in which the fields should appear. -.. data:: RewriteSourceOrder +.. data:: REWRITE_SOURCE_ORDER The order in which the information for source packages should be rewritten, i.e. the order in which the fields should appear. Dependencies ------------ -.. function:: CheckDep(pkgver, op, depver) +.. function:: check_dep(pkgver, op, depver) Check that the dependency requirements consisting of op and depver can be satisfied by the version pkgver. Example:: - >>> bool(apt_pkg.CheckDep("1.0", ">=", "1")) + >>> bool(apt_pkg.check_dep("1.0", ">=", "1")) True -.. function:: ParseDepends(depends) +.. function:: parse_depends(depends) Parse the string *depends* which contains dependency information as specified in Debian Policy, Section 7.1. @@ -1290,10 +1290,10 @@ Dependencies one or more tuples in the format ``(package,version,operation)`` for every 'or'-option given, e.g.:: - >>> apt_pkg.ParseDepends("PkgA (>= VerA) | PkgB (>= VerB)") + >>> apt_pkg.parse_depends("PkgA (>= VerA) | PkgB (>= VerB)") [[('PkgA', 'VerA', '>='), ('PkgB', 'VerB', '>=')]] -.. function:: ParseSrcDepends(depends) +.. function:: parse_src_depends(depends) Parse the string *depends* which contains dependency information as specified in Debian Policy, Section 7.1. @@ -1302,14 +1302,14 @@ Dependencies one or more tuples in the format ``(package,version,operation)`` for every 'or'-option given, e.g.:: - >>> apt_pkg.ParseDepends("PkgA (>= VerA) | PkgB (>= VerB)") + >>> apt_pkg.parse_depends("PkgA (>= VerA) | PkgB (>= VerB)") [[('PkgA', 'VerA', '>='), ('PkgB', 'VerB', '>=')]] Furthemore, this function also supports to limit the architectures, as used in e.g. Build-Depends:: - >>> apt_pkg.ParseSrcDepends("a (>= 01) [i386 amd64]") + >>> apt_pkg.parse_src_depends("a (>= 01) [i386 amd64]") [[('a', '01', '>=')]] @@ -1337,70 +1337,70 @@ Configuration Set the option at *key* to *value*. - .. method:: Find(key[, default='']) + .. method:: find(key[, default='']) Return the value for the given key *key*. This is the same as :meth:`Configuration.get`. If *key* does not exist, return *default*. - .. method:: FindFile(key[, default='']) + .. method:: find_file(key[, default='']) Return the filename hold by the configuration at *key*. This formats the filename correctly and supports the Dir:: stuff in the configuration. If *key* does not exist, return *default*. - .. method:: FindDir(key[, default='/']) + .. method:: find_dir(key[, default='/']) Return the absolute path to the directory specified in *key*. A trailing slash is appended. If *key* does not exist, return *default*. - .. method:: FindI(key[, default=0]) + .. method:: find_i(key[, default=0]) Return the integer value stored at *key*. If *key* does not exist, return *default*. - .. method:: FindB(key[, default=0]) + .. method:: find_b(key[, default=0]) Return the boolean value stored at *key*. This returns an integer, but it should be treated like True/False. If *key* does not exist, return *default*. - .. method:: Set(key, value) + .. method:: set(key, value) Set the value of *key* to *value*. - .. method:: Exists(key) + .. method:: exists(key) Check whether the key *key* exists in the configuration. - .. method:: SubTree(key) + .. method:: sub_tree(key) Return a sub tree starting at *key*. The resulting object can be used like this one. - .. method:: List([key]) + .. method:: list([key]) List all items at *key*. Normally, return the keys at the top level, eg. APT, Dir, etc. Use *key* to specify a key of which the childs will be returned. - .. method:: ValueList([key]) + .. method:: value_list([key]) - Same as :meth:`Configuration.List`, but this time for the values. + Same as :meth:`Configuration.list`, but this time for the values. - .. method:: MyTag() + .. method:: my_tag() Return the tag name of the current tree. Normally this is an empty string, but for subtrees it is the key of the subtree. - .. method:: Clear(key) + .. method:: clear(key) Clear the configuration. Remove all values and keys at *key*. @@ -1416,7 +1416,7 @@ Configuration .. method:: get(key[, default='']) - This behaves just like :meth:`dict.get` and :meth:`Configuration.Find`, + This behaves just like :meth:`dict.get` and :meth:`Configuration.find`, it returns the value of key or if it does not exist, *default*. .. class:: ConfigurationPtr @@ -1429,37 +1429,37 @@ Configuration Behaves like a :class:`Configuration()` objects, but provides access to a subsection of another Configuration-like object. This type of object is - returned by the :meth:`Configuration.SubTree()` method. + returned by the :meth:`Configuration.sub_tree()` method. -.. data:: Config +.. data:: config A :class:`ConfigurationPtr()` object with the default configuration. This - object is initialized by calling :func:`InitConfig`. + object is initialized by calling :func:`init_config`. Modifying ^^^^^^^^^ -.. function:: ReadConfigFile(configuration, filename) +.. function:: read_config_file(configuration, filename) Read the configuration file specified by the parameter *filename* and add the settings therein to the :class:`Configuration()` object specified by the parameter *configuration* -.. function:: ReadConfigDir(configuration, dirname) +.. function:: read_config_dir(configuration, dirname) Read configuration files in the directory specified by the parameter *dirname* and add the settings therein to the :class:`Configuration()` object specified by the parameter *configuration*. -.. function:: ReadConfigFileISC(configuration, filename) +.. function:: read_config_file_isc(configuration, filename) Read the configuration file specified by the parameter *filename* and add the settings therein to the :class:`Configuration()` object specified by the parameter *configuration* -.. function:: ParseCommandLine(configuration,options,argv) +.. function:: parse_command_line(configuration, options, argv) This function is like getopt except it manipulates a configuration space. output is a list of non-option arguments (filenames, etc). *options* is a @@ -1472,7 +1472,7 @@ Modifying Locking -------- -.. function:: GetLock(filename) +.. function:: get_lock(filename) Create an empty file at the path specified by the parameter *filename* and lock it. @@ -1483,11 +1483,11 @@ Locking When the lock is not required anymore, the file descriptor should be closed using :func:`os.close`. -.. function:: PkgSystemLock() +.. function:: pkg_system_lock() Lock the global pkgsystem. -.. function:: PkgSystemUnLock() +.. function:: pkg_system_un_lock() Unlock the global pkgsystem. @@ -1497,12 +1497,12 @@ Other classes Return a Cdrom object with the following methods: - .. method:: Ident(progress) + .. method:: ident(progress) Identify the cdrom. The parameter *progress* refers to an :class:`apt.progress.CdromProgress()` object. - .. method:: Add(progress) + .. method:: add(progress) Add the cdrom to the sources.list file. The parameter *progress* refers to an :class:`apt.progress.CdromProgress()` object. @@ -1511,52 +1511,52 @@ Other classes This is for :file:`/etc/apt/sources.list`. - .. method:: FindIndex(pkgfile) + .. method:: find_index(pkgfile) Return a :class:`PackageIndexFile` object for the :class:`PackageFile` *pkgfile*. - .. method:: ReadMainList + .. method:: read_main_list Read the main list. - .. method:: GetIndexes(acq[, all]) + .. method:: get_indexes(acq[, all]) Add the index files to the :class:`Acquire()` object *acq*. If *all* is given and ``True``, all files are fetched. String functions ---------------- -.. function:: Base64Encode(string) +.. function:: base64_encode(string) Encode the given string using base64, e.g:: - >>> apt_pkg.Base64Encode(u"A") + >>> apt_pkg.base64_encode(u"A") 'QQ==' -.. function:: CheckDomainList(host, list) +.. function:: check_domain_list(host, list) See if Host is in a ',' seperated list, e.g.:: - apt_pkg.CheckDomainList("alioth.debian.org","debian.net,debian.org") + apt_pkg.check_domain_list("alioth.debian.org","debian.net,debian.org") -.. function:: DeQuoteString(string) +.. function:: de_quote_string(string) Dequote the string specified by the parameter *string*, e.g.:: >>> apt_pkg.DeQuoteString("%61%70%74%20is%20cool") 'apt is cool' -.. function:: QuoteString(string, repl) +.. function:: quote_string(string, repl) For every character listed in the string *repl*, replace all occurences in the string *string* with the correct HTTP encoded value: - >>> apt_pkg.QuoteString("apt is cool","apt") + >>> apt_pkg.quote_string("apt is cool","apt") '%61%70%74%20is%20cool' -.. function:: SizeToStr(size) +.. function:: size_to_str(size) Return a string presenting the human-readable version of the integer *size*. When calculating the units (k,M,G,etc.) the size is divided by the @@ -1564,10 +1564,10 @@ String functions Example:: - >>> apt_pkg.SizeToStr(10000) + >>> apt_pkg.size_to_str(10000) '10.0k' -.. function:: StringToBool(input) +.. function:: string_to_bool(input) Parse the string *input* and return one of **-1**, **0**, **1**. @@ -1583,35 +1583,35 @@ String functions Example:: - >>> apt_pkg.StringToBool("yes") + >>> apt_pkg.string_to_bool("yes") 1 - >>> apt_pkg.StringToBool("no") + >>> apt_pkg.string_to_bool("no") 0 - >>> apt_pkg.StringToBool("not-recognized") + >>> apt_pkg.string_to_bool("not-recognized") -1 -.. function:: StrToTime(rfc_time) +.. function:: str_to_time(rfc_time) Convert the :rfc:`1123` conforming string *rfc_time* to the unix time, and return the integer. This is the opposite of :func:`TimeRFC1123`. Example:: - >> apt_pkg.StrToTime('Thu, 01 Jan 1970 00:00:00 GMT') + >> apt_pkg.str_to_time('Thu, 01 Jan 1970 00:00:00 GMT') 0 -.. function:: TimeRFC1123(seconds) +.. function:: time_rfc1123(seconds) Format the unix time specified by the integer *seconds*, according to the requirements of :rfc:`1123`. Example:: - >>> apt_pkg.TimeRFC1123(0) + >>> apt_pkg.time_rfc1123(0) 'Thu, 01 Jan 1970 00:00:00 GMT' -.. function:: TimeToStr(seconds) +.. function:: time_to_str(seconds) Format a given duration in a human-readable manner. The parameter *seconds* refers to a number of seconds, given as an integer. The return value is a @@ -1619,26 +1619,26 @@ String functions Example:: - >>> apt_pkg.TimeToStr(3601) + >>> apt_pkg.time_to_str(3601) '1h0min1s' -.. function:: UpstreamVersion(version) +.. function:: upstream_version(version) Return the string *version*, eliminating everything following the last '-'. Thus, this should be equivalent to ``version.rsplit('-', 1)[0]``. -.. function:: URItoFileName(uri) +.. function:: uri_to_file_name(uri) Take a string *uri* as parameter and return a filename which can be used to store the file, based on the URI. Example:: - >>> apt_pkg.URItoFileName('http://debian.org/index.html') + >>> apt_pkg.uri_to_file_name('http://debian.org/index.html') 'debian.org_index.html' -.. function:: VersionCompare(a, b) +.. function:: version_compare(a, b) Compare two versions, *a* and *b*, and return an integer value which has the same characteristic as the built-in :func:`cmp` function. @@ -1662,73 +1662,73 @@ Module Constants Package States ^^^^^^^^^^^^^^^ -.. data:: CurStateConfigFiles -.. data:: CurStateHalfConfigured -.. data:: CurStateHalfInstalled -.. data:: CurStateInstalled -.. data:: CurStateNotInstalled -.. data:: CurStateUnPacked +.. data:: CURSTATE_CONFIG_FILES +.. data:: CURSTATE_HALF_CONFIGURED +.. data:: CURSTATE_HALF_INSTALLED +.. data:: CURSTATE_INSTALLED +.. data:: CURSTATE_NOT_INSTALLED +.. data:: CURSTATE_UN_PACKED Dependency types ^^^^^^^^^^^^^^^^ -.. data:: DepConflicts -.. data:: DepDepends -.. data:: DepObsoletes -.. data:: DepPreDepends -.. data:: DepRecommends -.. data:: DepReplaces -.. data:: DepSuggests +.. data:: DEP_CONFLICTS +.. data:: DEP_DEPENDS +.. data:: DEP_OBSOLETES +.. data:: DEP_PRE_DEPENDS +.. data:: DEP_RECOMMENDS +.. data:: DEP_REPLACES +.. data:: DEP_SUGGESTS .. _InstStates: Installed states ^^^^^^^^^^^^^^^^ -.. data:: InstStateHold -.. data:: InstStateHoldReInstReq -.. data:: InstStateOk -.. data:: InstStateReInstReq +.. data:: INSTSTATE_HOLD +.. data:: INSTSTATE_HOLD_RE_INST_REQ +.. data:: INSTSTATE_OK +.. data:: INSTSTATE_RE_INST_REQ .. _Priorities: Priorities ^^^^^^^^^^^ -.. data:: PriExtra -.. data:: PriImportant -.. data:: PriOptional -.. data:: PriRequired -.. data:: PriStandard +.. data:: PRI_EXTRA +.. data:: PRI_IMPORTANT +.. data:: PRI_OPTIONAL +.. data:: PRI_REQUIRED +.. data:: PRI_STANDARD .. _SelStates: Select states ^^^^^^^^^^^^^ -.. data:: SelStateDeInstall -.. data:: SelStateHold -.. data:: SelStateInstall -.. data:: SelStatePurge -.. data:: SelStateUnknown +.. data:: SELSTATE_DE_INSTALL +.. data:: SELSTATE_HOLD +.. data:: SELSTATE_INSTALL +.. data:: SELSTATE_PURGE +.. data:: SELSTATE_UNKNOWN Build information ^^^^^^^^^^^^^^^^^ -.. data:: Date +.. data:: DATE The date on which this extension has been compiled. -.. data:: LibVersion +.. data:: LIB_VERSION The version of the apt_pkg library. This is **not** the version of apt, nor the version of python-apt. -.. data:: Time +.. data:: TIME The time this extension has been built. -.. data:: Version +.. data:: VERSION The version of apt (not of python-apt). diff --git a/doc/source/examples/cache-packages.py b/doc/source/examples/cache-packages.py index 0af96f7d..72534303 100644 --- a/doc/source/examples/cache-packages.py +++ b/doc/source/examples/cache-packages.py @@ -6,17 +6,17 @@ import apt_pkg def main(): """Main.""" - apt_pkg.InitConfig() - apt_pkg.InitSystem() + apt_pkg.init_config() + apt_pkg.init_system() cache = apt_pkg.Cache() print "Essential packages:" - for pkg in cache.Packages: - if pkg.Essential: - print " ", pkg.Name + for pkg in cache.packages: + if pkg.essential: + print " ", pkg.name print "Important packages:" - for pkg in cache.Packages: - if pkg.Important: - print " ", pkg.Name + for pkg in cache.packages: + if pkg.important: + print " ", pkg.name if __name__ == "__main__": main() diff --git a/doc/source/examples/cache-pkgfile.py b/doc/source/examples/cache-pkgfile.py index a7c22c97..1300a55c 100644 --- a/doc/source/examples/cache-pkgfile.py +++ b/doc/source/examples/cache-pkgfile.py @@ -6,19 +6,19 @@ def main(): """Example for PackageFile()""" apt_pkg.init() cache = apt_pkg.Cache() - for pkgfile in cache.FileList: - print 'Package-File:', pkgfile.FileName - print 'Index-Type:', pkgfile.IndexType # 'Debian Package Index' - if pkgfile.NotSource: + for pkgfile in cache.file_list: + print 'Package-File:', pkgfile.file_name + print 'Index-Type:', pkgfile.index_type # 'Debian Package Index' + if pkgfile.not_source: print 'Source: None' else: - if pkgfile.Site: + if pkgfile.site: # There is a source, and a site, print the site - print 'Source:', pkgfile.Site + print 'Source:', pkgfile.site else: # It seems to be a local repository print 'Source: Local package file' - if pkgfile.NotAutomatic: + if pkgfile.not_automatic: # The system won't be updated automatically (eg. experimental) print 'Automatic: No' else: diff --git a/doc/source/examples/dpkg-contents.py b/doc/source/examples/dpkg-contents.py index 99d1596f..24d7ce98 100644 --- a/doc/source/examples/dpkg-contents.py +++ b/doc/source/examples/dpkg-contents.py @@ -28,7 +28,7 @@ def format_mode(what, mode): def callback(what, name, link, mode, uid, gid, size, mtime, major, minor): - """callback for debExtract""" + """callback for deb_extract""" s_mode = format_mode(what, mode) s_owner = "%s/%s" % (pwd.getpwuid(uid)[0], grp.getgrgid(gid)[0]) s_size = "%9d" % size @@ -47,7 +47,7 @@ def main(): fobj = open(sys.argv[1]) try: - apt_inst.debExtract(fobj, callback, "data.tar.gz") + apt_inst.deb_extract(fobj, callback, "data.tar.gz") finally: fobj.close() diff --git a/doc/source/examples/dpkg-extract.py b/doc/source/examples/dpkg-extract.py index ced8652f..8d144029 100644 --- a/doc/source/examples/dpkg-extract.py +++ b/doc/source/examples/dpkg-extract.py @@ -17,7 +17,7 @@ def main(): fobj = open(sys.argv[1]) try: - apt_inst.debExtractArchive(fobj, sys.argv[2]) + apt_inst.deb_extract_archive(fobj, sys.argv[2]) finally: fobj.close() diff --git a/doc/source/examples/dpkg-info.py b/doc/source/examples/dpkg-info.py index ff98d8b1..6be8595c 100644 --- a/doc/source/examples/dpkg-info.py +++ b/doc/source/examples/dpkg-info.py @@ -2,7 +2,7 @@ """Emulate dpkg --info package.deb control-file""" import sys -from apt_inst import debExtractControl +from apt_inst import deb_extract_control def main(): @@ -12,7 +12,7 @@ def main(): sys.exit(0) fobj = open(sys.argv[1]) try: - print debExtractControl(fobj, sys.argv[2]) + print deb_extract_control(fobj, sys.argv[2]) finally: fobj.close() diff --git a/doc/source/examples/missing-deps.py b/doc/source/examples/missing-deps.py index dd5eeb8a..7af18128 100644 --- a/doc/source/examples/missing-deps.py +++ b/doc/source/examples/missing-deps.py @@ -5,9 +5,9 @@ import apt_pkg def fmt_dep(dep): """Format a Dependency object [of apt_pkg] as a string.""" - ret = dep.TargetPkg.Name - if dep.TargetVer: - ret += " (%s %s)" % (dep.CompType, dep.TargetVer) + ret = dep.target_pkg.name + if dep.target_ver: + ret += " (%s %s)" % (dep.comp_type, dep.target_ver) return ret @@ -15,15 +15,15 @@ def check_version(pkgver): """Check the version of the package""" missing = [] - for or_group in pkgver.DependsList.get("Pre-Depends", []) + \ - pkgver.DependsList.get("Depends", []): - if not any(dep.AllTargets() for dep in or_group): + for or_group in pkgver.depends_list.get("Pre-Depends", []) + \ + pkgver.depends_list.get("Depends", []): + if not any(dep.all_targets() for dep in or_group): # If none of the or-choices can be satisfied, add it to missing missing.append(or_group) if missing: - print "Package:", pkgver.ParentPkg.Name - print "Version:", pkgver.VerStr + print "Package:", pkgver.parent_pkg.name + print "Version:", pkgver.ver_str print "Missing:", print ", ".join(" | ".join(fmt_dep(dep) for dep in or_group) for or_group in missing) @@ -32,18 +32,18 @@ def check_version(pkgver): def main(): """The main function.""" - apt_pkg.InitConfig() - apt_pkg.InitSystem() + apt_pkg.init_config() + apt_pkg.init_system() cache = apt_pkg.Cache() - for pkg in sorted(cache.Packages, key=lambda pkg: pkg.Name): + for pkg in sorted(cache.packages, key=lambda pkg: pkg.name): # pkg is from a list of packages, sorted by name. - for version in pkg.VersionList: + for version in pkg.version_list: # Check every version - for pfile, _ in version.FileList: - if (pfile.Origin == "Debian" and pfile.Component == "main" and - pfile.Archive == "unstable"): + for pfile, _ in version.file_list: + if (pfile.origin == "Debian" and pfile.component == "main" and + pfile.archive == "unstable"): # We only want packages from Debian unstable main. check_version(version) break -- cgit v1.2.3 From 994a13b252f97f6ae77872b5d5118ac1366b2a24 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 5 Jun 2009 19:13:20 +0200 Subject: python/progress.cc, apt/progress/*.py: Use PEP 8 naming conventions for progress This changes the progress classes to use PEP 8 names. Due to the concept of the deprecation system, this causes methods of subclasses not to be called at all. If a class implements a command with underscores, it is called. If the class also implements the version in mixedCase, this is ignored. This means that all subclasses will not work correctly, because only the method from the parent class is called. --- apt/deprecation.py | 2 +- apt/progress/__init__.py | 133 +++++++++++++++++++++++++++++++---------------- apt/progress/gtk2.py | 52 +++++++++++------- python/progress.cc | 81 +++++++++++++++++++++++------ 4 files changed, 184 insertions(+), 84 deletions(-) (limited to 'apt/progress/__init__.py') diff --git a/apt/deprecation.py b/apt/deprecation.py index 6827a8b9..0f39ad63 100644 --- a/apt/deprecation.py +++ b/apt/deprecation.py @@ -67,7 +67,7 @@ def function_deprecated_by(func, convert_names=True): This function also converts all keyword argument names from mixedCase to lowercase_with_underscores, but only if 'convert_names' is True (default). """ - warning = 'Deprecated, please use \'%s\' instead' % func.__name__ + warning = 'Deprecated, please use \'%s()\' instead' % func.__name__ def deprecated_function(*args, **kwds): """Wrapper around a deprecated function.""" diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index d2a9d497..6e4c6eec 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -33,6 +33,7 @@ import select import sys import apt_pkg +from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by __all__ = ('CdromProgress', 'DpkgInstallProgress', 'DumbInstallProgress', @@ -48,7 +49,7 @@ class OpProgress(object): def __init__(self): self.op = None - self.subOp = None + self.sub_op = None def update(self, percent): """Called periodically to update the user interface.""" @@ -56,6 +57,9 @@ class OpProgress(object): def done(self): """Called once an operation has been completed.""" + if apt_pkg._COMPAT_0_7: + subOp = AttributeDeprecatedBy('sub_op') + class OpTextProgress(OpProgress): """A simple text based cache open reporting class.""" @@ -65,7 +69,7 @@ class OpTextProgress(OpProgress): def update(self, percent): """Called periodically to update the user interface.""" - sys.stdout.write("\r%s: %.2i " % (self.subOp, percent)) + sys.stdout.write("\r%s: %.2i " % (self.sub_op, percent)) sys.stdout.flush() def done(self): @@ -80,26 +84,26 @@ class FetchProgress(object): """ # download status constants - dlDone = 0 - dlQueued = 1 - dlFailed = 2 - dlHit = 3 - dlIgnored = 4 - dlStatusStr = {dlDone: "Done", - dlQueued: "Queued", - dlFailed: "Failed", - dlHit: "Hit", - dlIgnored: "Ignored"} + dl_done = 0 + dl_queued = 1 + dl_failed = 2 + dl_hit = 3 + dl_ignored = 4 + dl_status_str = {dl_done: "Done", + dl_queued: "Queued", + dl_failed: "Failed", + dl_hit: "Hit", + dl_ignored: "Ignored"} def __init__(self): self.eta = 0.0 self.percent = 0.0 # Make checking easier - self.currentBytes = 0 - self.currentItems = 0 - self.totalBytes = 0 - self.totalItems = 0 - self.currentCPS = 0 + self.current_bytes = 0 + self.current_items = 0 + self.total_bytes = 0 + self.total_items = 0 + self.current_cps = 0 def start(self): """Called when the fetching starts.""" @@ -107,7 +111,7 @@ class FetchProgress(object): def stop(self): """Called when all files have been fetched.""" - def updateStatus(self, uri, descr, shortDescr, status): + def update_status(self, uri, descr, short_descr, status): """Called when the status of an item changes. This happens eg. when the downloads fails or is completed. @@ -118,16 +122,31 @@ class FetchProgress(object): Return True to continue or False to cancel. """ - self.percent = (((self.currentBytes + self.currentItems) * 100.0) / - float(self.totalBytes + self.totalItems)) - if self.currentCPS > 0: - self.eta = ((self.totalBytes - self.currentBytes) / - float(self.currentCPS)) + self.percent = (((self.current_bytes + self.current_items) * 100.0) / + float(self.total_bytes + self.total_items)) + if self.current_cps > 0: + self.eta = ((self.total_bytes - self.current_bytes) / + float(self.current_cps)) return True - def mediaChange(self, medium, drive): + def media_change(self, medium, drive): """react to media change events.""" + if apt_pkg._COMPAT_0_7: + dlDone = AttributeDeprecatedBy('dl_done') + dlQueued = AttributeDeprecatedBy('dl_queued') + dlFailed = AttributeDeprecatedBy('dl_failed') + dlHit = AttributeDeprecatedBy('dl_hit') + dlIgnored = AttributeDeprecatedBy('dl_ignored') + dlStatusStr = AttributeDeprecatedBy('dl_status_str') + currentBytes = AttributeDeprecatedBy('current_bytes') + currentItems = AttributeDeprecatedBy('current_items') + totalBytes = AttributeDeprecatedBy('total_bytes') + totalItems = AttributeDeprecatedBy('total_items') + currentCPS = AttributeDeprecatedBy('current_cps') + updateStatus = function_deprecated_by(update_status) + mediaChange = function_deprecated_by(media_change) + class TextFetchProgress(FetchProgress): """ Ready to use progress object for terminal windows """ @@ -136,13 +155,13 @@ class TextFetchProgress(FetchProgress): FetchProgress.__init__(self) self.items = {} - def updateStatus(self, uri, descr, shortDescr, status): + def update_status(self, uri, descr, short_descr, status): """Called when the status of an item changes. This happens eg. when the downloads fails or is completed. """ - if status != self.dlQueued: - print "\r%s %s" % (self.dlStatusStr[status], descr) + if status != self.dl_queued: + print "\r%s %s" % (self.dl_status_str[status], descr) self.items[uri] = status def pulse(self): @@ -151,10 +170,10 @@ class TextFetchProgress(FetchProgress): Return True to continue or False to cancel. """ FetchProgress.pulse(self) - if self.currentCPS > 0: + if self.current_cps > 0: s = "[%2.f%%] %sB/s %s" % (self.percent, - apt_pkg.size_to_str(int(self.currentCPS)), - apt_pkg.time_to_str(int(self.eta))) + apt_pkg.size_to_str(int(self.current_cps)), + apt_pkg.time_to_str(int(self.eta))) else: s = "%2.f%% [Working]" % (self.percent) print "\r%s" % (s), @@ -165,13 +184,17 @@ class TextFetchProgress(FetchProgress): """Called when all files have been fetched.""" print "\rDone downloading " - def mediaChange(self, medium, drive): + def media_change(self, medium, drive): """react to media change events.""" print ("Media change: please insert the disc labeled " "'%s' in the drive '%s' and press enter") % (medium, drive) return raw_input() not in ('c', 'C') + if apt_pkg._COMPAT_0_7: + updateStatus = function_deprecated_by(update_status) + mediaChange = function_deprecated_by(media_change) + class DumbInstallProgress(object): """Report the install progress. @@ -179,19 +202,24 @@ class DumbInstallProgress(object): Subclass this class to implement install progress reporting. """ - def startUpdate(self): + def start_update(self): """Start update.""" def run(self, pm): """Start installation.""" return pm.do_install() - def finishUpdate(self): + def finish_update(self): """Called when update has finished.""" - def updateInterface(self): + def update_interface(self): """Called periodically to update the user interface""" + if apt_pkg._COMPAT_0_7: + startUpdate = function_deprecated_by(start_update) + finishUpdate = function_deprecated_by(finish_update) + updateInterface = function_deprecated_by(update_interface) + class InstallProgress(DumbInstallProgress): """An InstallProgress that is pretty useful. @@ -202,7 +230,7 @@ class InstallProgress(DumbInstallProgress): def __init__(self): DumbInstallProgress.__init__(self) - self.selectTimeout = 0.1 + self.select_timeout = 0.1 (read, write) = os.pipe() self.writefd = write self.statusfd = os.fdopen(read, "r") @@ -217,10 +245,10 @@ class InstallProgress(DumbInstallProgress): def conffile(self, current, new): """Called when a conffile question from dpkg is detected.""" - def statusChange(self, pkg, percent, status): + def status_change(self, pkg, percent, status): """Called when the status changed.""" - def updateInterface(self): + def update_interface(self): """Called periodically to update the interface.""" if self.statusfd is None: return @@ -253,7 +281,7 @@ class InstallProgress(DumbInstallProgress): self.conffile(match.group(1), match.group(2)) elif status == "pmstatus": if float(percent) != self.percent or status_str != self.status: - self.statusChange(pkg, float(percent), + self.status_change(pkg, float(percent), status_str.strip()) self.percent = float(percent) self.status = status_str.strip() @@ -263,11 +291,11 @@ class InstallProgress(DumbInstallProgress): """Fork.""" return os.fork() - def waitChild(self): + def wait_child(self): """Wait for child progress to exit.""" while True: - select.select([self.statusfd], [], [], self.selectTimeout) - self.updateInterface() + select.select([self.statusfd], [], [], self.select_timeout) + self.update_interface() (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) if pid == self.child_pid: break @@ -281,9 +309,15 @@ class InstallProgress(DumbInstallProgress): res = pm.do_install(self.writefd) os._exit(res) self.child_pid = pid - res = self.waitChild() + res = self.wait_child() return os.WEXITSTATUS(res) + if apt_pkg._COMPAT_0_7: + selectTimeout = AttributeDeprecatedBy('select_timeout') + statusChange = function_deprecated_by(status_change) + waitChild = function_deprecated_by(wait_child) + updateInterface = function_deprecated_by(update_interface) + class CdromProgress(object): """Report the cdrom add progress. @@ -297,12 +331,16 @@ class CdromProgress(object): def update(self, text, step): """Called periodically to update the user interface.""" - def askCdromName(self): + def ask_cdrom_name(self): """Called to ask for the name of the cdrom.""" - def changeCdrom(self): + def change_cdrom(self): """Called to ask for the cdrom to be changed.""" + if apt_pkg._COMPAT_0_7: + askCdromName = function_deprecated_by(ask_cdrom_name) + changeCdrom = function_deprecated_by(change_cdrom) + class DpkgInstallProgress(InstallProgress): """Progress handler for a local Debian package installation.""" @@ -318,10 +356,10 @@ class DpkgInstallProgress(InstallProgress): (self.writefd, self.debfile)) os._exit(os.WEXITSTATUS(res)) self.child_pid = pid - res = self.waitChild() + res = self.wait_child() return res - def updateInterface(self): + def update_interface(self): """Process status messages from dpkg.""" if self.statusfd is None: return @@ -354,3 +392,6 @@ class DpkgInstallProgress(InstallProgress): else: self.status = status self.read = "" + + if apt_pkg._COMPAT_0_7: + updateInterface = function_deprecated_by(update_interface) diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index 06ece2d5..c0c05426 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -39,6 +39,7 @@ import vte import apt import apt_pkg +from apt.deprecation import function_deprecated_by def mksig(params=(), run=gobject.SIGNAL_RUN_FIRST, rettype=gobject.TYPE_NONE): @@ -113,13 +114,13 @@ class GInstallProgress(gobject.GObject, apt.progress.InstallProgress): self.time_last_update = time.time() self.term = term reaper = vte.reaper_get() - reaper.connect("child-exited", self.childExited) + reaper.connect("child-exited", self.child_exited) self.env = ["VTE_PTY_KEEP_FD=%s" % self.writefd, "DEBIAN_FRONTEND=gnome", "APT_LISTCHANGES_FRONTEND=gtk"] self._context = glib.main_context_default() - def childExited(self, term, pid, status): + def child_exited(self, term, pid, status): """Called when a child process exits""" self.apt_status = os.WEXITSTATUS(status) self.finished = True @@ -138,21 +139,21 @@ class GInstallProgress(gobject.GObject, apt.progress.InstallProgress): """ self.emit("status-conffile") - def startUpdate(self): + def start_update(self): """Called when the update starts. Emits: status-started() """ self.emit("status-started") - def finishUpdate(self): + def finish_update(self): """Called when the update finished. Emits: status-finished() """ self.emit("status-finished") - def statusChange(self, pkg, percent, status): + def status_change(self, pkg, percent, status): """Called when the status changed. Emits: status-changed(status, percent) @@ -160,12 +161,12 @@ class GInstallProgress(gobject.GObject, apt.progress.InstallProgress): self.time_last_update = time.time() self.emit("status-changed", status, percent) - def updateInterface(self): + def update_interface(self): """Called periodically to update the interface. Emits: status-timeout() [When a timeout happens] """ - apt.progress.InstallProgress.updateInterface(self) + apt.progress.InstallProgress.update_interface(self) while self._context.pending(): self._context.iteration() if self.time_last_update + self.INSTALL_TIMEOUT < time.time(): @@ -175,12 +176,20 @@ class GInstallProgress(gobject.GObject, apt.progress.InstallProgress): """Fork the process.""" return self.term.forkpty(envv=self.env) - def waitChild(self): + def wait_child(self): """Wait for the child process to exit.""" while not self.finished: - self.updateInterface() + self.update_interface() return self.apt_status + if apt_pkg._COMPAT_0_7: + updateInterface = function_deprecated_by(update_interface) + startUpdate = function_deprecated_by(start_update) + finishUpdate = function_deprecated_by(finish_update) + statusChange = function_deprecated_by(status_change) + waitChild = function_deprecated_by(wait_child) + childExited = function_deprecated_by(child_exited) + class GDpkgInstallProgress(apt.progress.DpkgInstallProgress, GInstallProgress): """An InstallProgress for local installations. @@ -199,14 +208,17 @@ class GDpkgInstallProgress(apt.progress.DpkgInstallProgress, GInstallProgress): """Install the given package.""" apt.progress.DpkgInstallProgress.run(self, debfile) - def updateInterface(self): + def update_interface(self): """Called periodically to update the interface. Emits: status-timeout() [When a timeout happens]""" - apt.progress.DpkgInstallProgress.updateInterface(self) + apt.progress.DpkgInstallProgress.update_interface(self) if self.time_last_update + self.INSTALL_TIMEOUT < time.time(): self.emit("status-timeout") + if apt_pkg._COMPAT_0_7: + updateInterface = function_deprecated_by(update_interface) + class GFetchProgress(gobject.GObject, apt.progress.FetchProgress): """A Fetch Progress with GObject signals. @@ -239,19 +251,19 @@ class GFetchProgress(gobject.GObject, apt.progress.FetchProgress): def pulse(self): apt.progress.FetchProgress.pulse(self) - currentItem = self.currentItems + 1 - if currentItem > self.totalItems: - currentItem = self.totalItems - if self.currentCPS > 0: + current_item = self.current_items + 1 + if current_item > self.total_items: + current_item = self.total_items + if self.current_cps > 0: text = (_("Downloading file %(current)li of %(total)li with " "%(speed)s/s") % \ - {"current": currentItem, - "total": self.totalItems, - "speed": apt_pkg.size_to_str(self.currentCPS)}) + {"current": current_item, + "total": self.total_items, + "speed": apt_pkg.size_to_str(self.current_cps)}) else: text = (_("Downloading file %(current)li of %(total)li") % \ - {"current": currentItem, - "total": self.totalItems}) + {"current": current_item, + "total": self.total_items}) self.emit("status-changed", text, self.percent) while self._context.pending(): self._context.iteration() diff --git a/python/progress.cc b/python/progress.cc index bec40ce9..8214a789 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -12,7 +12,6 @@ #include #include "progress.h" - // generic bool PyCallbackObj::RunSimpleCallback(const char* method_name, PyObject *arglist, @@ -58,10 +57,16 @@ void PyOpProgress::Update() PyObject_SetAttrString(callbackInst, "op", o); Py_XDECREF(o); o = Py_BuildValue("s", SubOp.c_str()); - PyObject_SetAttrString(callbackInst, "subOp", o); + if(PyObject_HasAttrString(callbackInst, "sub_op")) + PyObject_SetAttrString(callbackInst, "sub_op", o); + else + PyObject_SetAttrString(callbackInst, "subOp", o); Py_XDECREF(o); o = Py_BuildValue("b", MajorChange); - PyObject_SetAttrString(callbackInst, "majorChange", o); + if(PyObject_HasAttrString(callbackInst, "major_change")) + PyObject_SetAttrString(callbackInst, "major_change", o); + else + PyObject_SetAttrString(callbackInst, "majorChange", o); Py_XDECREF(o); // Build up the argument list... @@ -89,7 +94,10 @@ bool PyFetchProgress::MediaChange(string Media, string Drive) //std::cout << "MediaChange" << std::endl; PyObject *arglist = Py_BuildValue("(ss)", Media.c_str(), Drive.c_str()); PyObject *result; - RunSimpleCallback("mediaChange", arglist, &result); + if(PyObject_HasAttrString(callbackInst, "media_change")) + RunSimpleCallback("media_change", arglist, &result); + else + RunSimpleCallback("mediaChange", arglist, &result); bool res = true; if(!PyArg_Parse(result, "b", &res)) @@ -105,7 +113,10 @@ void PyFetchProgress::UpdateStatus(pkgAcquire::ItemDesc &Itm, int status) { //std::cout << "UpdateStatus: " << Itm.URI << " " << status << std::endl; PyObject *arglist = Py_BuildValue("(sssi)", Itm.URI.c_str(), Itm.Description.c_str(), Itm.ShortDesc.c_str(), status); - RunSimpleCallback("updateStatus", arglist); + if(PyObject_HasAttrString(callbackInst, "update_status")) + RunSimpleCallback("update_status", arglist); + else + RunSimpleCallback("updateStatus", arglist); } void PyFetchProgress::IMSHit(pkgAcquire::ItemDesc &Itm) @@ -163,19 +174,34 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) // set stats PyObject *o; o = Py_BuildValue("f", CurrentCPS); - PyObject_SetAttrString(callbackInst, "currentCPS", o); + if(PyObject_HasAttrString(callbackInst, "current_cps")) + PyObject_SetAttrString(callbackInst, "current_cps", o); + else + PyObject_SetAttrString(callbackInst, "currentCPS", o); Py_XDECREF(o); o = Py_BuildValue("f", CurrentBytes); - PyObject_SetAttrString(callbackInst, "currentBytes", o); + if(PyObject_HasAttrString(callbackInst, "current_bytes")) + PyObject_SetAttrString(callbackInst, "current_bytes", o); + else + PyObject_SetAttrString(callbackInst, "currentBytes", o); Py_XDECREF(o); o = Py_BuildValue("i", CurrentItems); - PyObject_SetAttrString(callbackInst, "currentItems", o); + if(PyObject_HasAttrString(callbackInst, "current_items")) + PyObject_SetAttrString(callbackInst, "current_items", o); + else + PyObject_SetAttrString(callbackInst, "currentItems", o); Py_XDECREF(o); o = Py_BuildValue("i", TotalItems); - PyObject_SetAttrString(callbackInst, "totalItems", o); + if(PyObject_HasAttrString(callbackInst, "total_items")) + PyObject_SetAttrString(callbackInst, "total_items", o); + else + PyObject_SetAttrString(callbackInst, "totalItems", o); Py_XDECREF(o); o = Py_BuildValue("f", TotalBytes); - PyObject_SetAttrString(callbackInst, "totalBytes", o); + if(PyObject_HasAttrString(callbackInst, "total_bytes")) + PyObject_SetAttrString(callbackInst, "total_bytes", o); + else + PyObject_SetAttrString(callbackInst, "totalBytes", o); Py_XDECREF(o); PyObject *arglist = Py_BuildValue("()"); @@ -201,17 +227,26 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) void PyInstallProgress::StartUpdate() { - RunSimpleCallback("startUpdate"); + if(PyObject_HasAttrString(callbackInst, "start_update")) + RunSimpleCallback("start_update"); + else + RunSimpleCallback("startUpdate"); } void PyInstallProgress::UpdateInterface() { - RunSimpleCallback("updateInterface"); + if(PyObject_HasAttrString(callbackInst, "update_interface")) + RunSimpleCallback("update_interface"); + else + RunSimpleCallback("updateInterface"); } void PyInstallProgress::FinishUpdate() { - RunSimpleCallback("finishUpdate"); + if(PyObject_HasAttrString(callbackInst, "finish_update")) + RunSimpleCallback("finish_update"); + else + RunSimpleCallback("finishUpdate"); } pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) @@ -272,8 +307,13 @@ pkgPackageManager::OrderResult PyInstallProgress::Run(pkgPackageManager *pm) StartUpdate(); - if(PyObject_HasAttrString(callbackInst, "waitChild")) { - PyObject *method = PyObject_GetAttrString(callbackInst, "waitChild"); + if(PyObject_HasAttrString(callbackInst, "waitChild") || + PyObject_HasAttrString(callbackInst, "wait_child")) { + PyObject *method; + if (PyObject_HasAttrString(callbackInst, "wait_child")) + method = PyObject_GetAttrString(callbackInst, "wait_child"); + else + method = PyObject_GetAttrString(callbackInst, "waitChild"); //std::cerr << "custom waitChild found" << std::endl; PyObject *arglist = Py_BuildValue("(i)",child_id); PyObject *result = PyEval_CallObject(method, arglist); @@ -323,7 +363,10 @@ bool PyCdromProgress::ChangeCdrom() { PyObject *arglist = Py_BuildValue("()"); PyObject *result; - RunSimpleCallback("changeCdrom", arglist, &result); + if(PyObject_HasAttrString(callbackInst, "change_cdrom")) + RunSimpleCallback("change_cdrom", arglist, &result); + else + RunSimpleCallback("changeCdrom", arglist, &result); bool res = true; if(!PyArg_Parse(result, "b", &res)) @@ -337,7 +380,11 @@ bool PyCdromProgress::AskCdromName(string &Name) { PyObject *arglist = Py_BuildValue("()"); PyObject *result; - RunSimpleCallback("askCdromName", arglist, &result); + + if(PyObject_HasAttrString(callbackInst, "ask_cdrom_name")) + RunSimpleCallback("ask_cdrom_name", arglist, &result); + else + RunSimpleCallback("askCdromName", arglist, &result); const char *new_name; bool res; -- cgit v1.2.3 From dc759b837ad5d7790fd54f081c1b95ffe76b926c Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 15 Jun 2009 14:47:15 +0200 Subject: apt/progress/__init__.py: Check for EINTR in select (Closes: #499296) --- apt/progress/__init__.py | 8 +++++++- debian/changelog | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'apt/progress/__init__.py') diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index a6287dc4..3c5d4588 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -116,6 +116,7 @@ class FetchProgress(object): This happens eg. when the downloads fails or is completed. """ + def update_status_full(self, uri, descr, short_descr, status, file_size, partial_size): """Called when the status of an item changes. @@ -314,7 +315,12 @@ class InstallProgress(DumbInstallProgress): def wait_child(self): """Wait for child progress to exit.""" while True: - select.select([self.statusfd], [], [], self.select_timeout) + try: + select.select([self.statusfd], [], [], self.select_timeout) + except select.error, e: + if e[0] != errno.EINTR: + raise + self.update_interface() (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) if pid == self.child_pid: diff --git a/debian/changelog b/debian/changelog index 6ad40154..55d3a834 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * Bugfix: Delete pointers correctly, fixing memory leaks. (LP: #370149) * apt/package.py: Return VersionList objects in Package.versions, which are sequences and also provide features of mappings. (small API BREAK) + * apt/progress/__init__.py: Check for EINTR in select (Closes: #499296) [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -22,7 +23,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Sun, 14 Jun 2009 16:23:39 +0200 + -- Julian Andres Klode Mon, 15 Jun 2009 14:45:06 +0200 python-apt (0.7.91) experimental; urgency=low -- cgit v1.2.3 From 51f0b08149c39dc76664e1758aa0d71701920bd7 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 16 Jul 2009 19:50:18 +0200 Subject: apt/progress: Move apt.progress to apt.progress.old --- apt/__init__.py | 5 +- apt/cdrom.py | 2 +- apt/package.py | 27 +-- apt/progress/__init__.py | 439 +++-------------------------------------------- apt/progress/old.py | 426 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 464 insertions(+), 435 deletions(-) create mode 100644 apt/progress/old.py (limited to 'apt/progress/__init__.py') diff --git a/apt/__init__.py b/apt/__init__.py index 41c0a30f..ec7103a1 100644 --- a/apt/__init__.py +++ b/apt/__init__.py @@ -26,9 +26,8 @@ from apt.cache import Cache from apt.cdrom import Cdrom if apt_pkg._COMPAT_0_7: - from apt.progress import (OpProgress, FetchProgress, InstallProgress, - CdromProgress) - + from apt.progress.old import (OpProgress, FetchProgress, InstallProgress, + CdromProgress) if apt_pkg._COMPAT_0_7: from apt_pkg import (size_to_str as SizeToStr, diff --git a/apt/cdrom.py b/apt/cdrom.py index a98b5d99..a3811ccb 100644 --- a/apt/cdrom.py +++ b/apt/cdrom.py @@ -23,7 +23,7 @@ import glob import apt_pkg -from apt.progress import CdromProgress +from apt.progress.old import CdromProgress from apt.deprecation import AttributeDeprecatedBy diff --git a/apt/package.py b/apt/package.py index 0ce2da3a..491571c2 100644 --- a/apt/package.py +++ b/apt/package.py @@ -35,7 +35,7 @@ except ImportError: Sequence = Mapping = object import apt_pkg -import apt.progress +import apt.progress.text from apt.deprecation import (function_deprecated_by, AttributeDeprecatedBy, deprecated_args) @@ -442,9 +442,9 @@ class Version(object): The parameter *destdir* specifies the directory where the package will be fetched to. - The parameter *progress* may refer to an apt.progress.FetchProgress() - object. If not specified or None, apt.progress.TextFetchProgress() is - used. + The parameter *progress* may refer to an apt_pkg.AcquireProgress() + object. If not specified or None, apt.progress.text.AcquireProgress() + is used. .. versionadded:: 0.7.10 """ @@ -453,7 +453,7 @@ class Version(object): if _file_is_same(destfile, self.size, self._records.md5_hash): print 'Ignoring already existing file:', destfile return - acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress()) + acq = apt_pkg.Acquire(progress or apt.progress.text.AcquireProgress()) acqfile = apt_pkg.AcquireFile(acq, self.uri, self._records.md5_hash, self.size, base, destfile=destfile) acq.run() @@ -461,6 +461,7 @@ class Version(object): if acqfile.status != acqfile.stat_done: raise FetchError("The item %r could not be fetched: %s" % (acqfile.destfile, acqfile.error_text)) + print self._records.filename return os.path.abspath(destfile) def fetch_source(self, destdir="", progress=None, unpack=True): @@ -469,9 +470,9 @@ class Version(object): The parameter *destdir* specifies the directory where the source will be fetched to. - The parameter *progress* may refer to an apt.progress.FetchProgress() - object. If not specified or None, apt.progress.TextFetchProgress() is - used. + The parameter *progress* may refer to an apt_pkg.AcquireProgress() + object. If not specified or None, apt.progress.text.AcquireProgress() + is used. The parameter *unpack* describes whether the source should be unpacked (``True``) or not (``False``). By default, it is unpacked. @@ -480,7 +481,7 @@ class Version(object): returned. Otherwise, the path to the .dsc file is returned. """ src = apt_pkg.SourceRecords() - acq = apt_pkg.Acquire(progress or apt.progress.TextFetchProgress()) + acq = apt_pkg.Acquire(progress or apt.progress.text.AcquireProgress()) dsc = None src.lookup(self.package.name) @@ -1152,11 +1153,11 @@ class Package(object): def commit(self, fprogress, iprogress): """Commit the changes. - The parameter *fprogress* refers to a FetchProgress() object, as - found in apt.progress. + The parameter *fprogress* refers to a apt_pkg.AcquireProgress() object, + like apt.progress.text.AcquireProgress(). The parameter *iprogress* refers to an InstallProgress() object, as - found in apt.progress. + found in apt.progress.old. """ self._pcache._depcache.commit(fprogress, iprogress) @@ -1207,7 +1208,7 @@ def _test(): print "Self-test for the Package modul" import random apt_pkg.init() - progress = apt.progress.OpTextProgress() + progress = apt.progress.text.OpProgress() cache = apt.Cache(progress) pkg = cache["apt-utils"] print "Name: %s " % pkg.name diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 3c5d4588..67880903 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -1,426 +1,29 @@ -# progress.py - progress reporting classes +# Copyright (c) 2009 Julian Andres Klode # -# Copyright (c) 2005-2009 Canonical +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. # -# Author: Michael Vogt +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. # -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA -"""progress reporting classes. - -This module provides classes for progress reporting. They can be used with -e.g., for reporting progress on the cache opening process, the cache update -progress, or the package install progress. -""" - -import errno -import fcntl -import os -import re -import select -import sys - +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +"""Progress reporting.""" import apt_pkg -from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by - - -__all__ = ('CdromProgress', 'DpkgInstallProgress', 'DumbInstallProgress', - 'FetchProgress', 'InstallProgress', 'OpProgress', 'OpTextProgress', - 'TextFetchProgress') - - -class OpProgress(object): - """Abstract class to implement reporting on cache opening. - - Subclass this class to implement simple Operation progress reporting. - """ - - def __init__(self): - self.op = None - self.sub_op = None - - def update(self, percent): - """Called periodically to update the user interface.""" - - def done(self): - """Called once an operation has been completed.""" - - if apt_pkg._COMPAT_0_7: - subOp = AttributeDeprecatedBy('sub_op') - - -class OpTextProgress(OpProgress): - """A simple text based cache open reporting class.""" - - def __init__(self): - OpProgress.__init__(self) - - def update(self, percent): - """Called periodically to update the user interface.""" - sys.stdout.write("\r%s: %.2i " % (self.sub_op, percent)) - sys.stdout.flush() - - def done(self): - """Called once an operation has been completed.""" - sys.stdout.write("\r%s: Done\n" % self.op) - - -class FetchProgress(object): - """Report the download/fetching progress. - - Subclass this class to implement fetch progress reporting - """ - - # download status constants - dl_done = 0 - dl_queued = 1 - dl_failed = 2 - dl_hit = 3 - dl_ignored = 4 - dl_status_str = {dl_done: "Done", - dl_queued: "Queued", - dl_failed: "Failed", - dl_hit: "Hit", - dl_ignored: "Ignored"} - - def __init__(self): - self.eta = 0.0 - self.percent = 0.0 - # Make checking easier - self.current_bytes = 0 - self.current_items = 0 - self.total_bytes = 0 - self.total_items = 0 - self.current_cps = 0 - - def start(self): - """Called when the fetching starts.""" - - def stop(self): - """Called when all files have been fetched.""" - - def update_status(self, uri, descr, short_descr, status): - """Called when the status of an item changes. - - This happens eg. when the downloads fails or is completed. - """ - - def update_status_full(self, uri, descr, short_descr, status, file_size, - partial_size): - """Called when the status of an item changes. - - This happens eg. when the downloads fails or is completed. This - version include information on current filesize and partial size - """ - - def pulse(self): - """Called periodically to update the user interface. - - Return True to continue or False to cancel. - """ - self.percent = (((self.current_bytes + self.current_items) * 100.0) / - float(self.total_bytes + self.total_items)) - if self.current_cps > 0: - self.eta = ((self.total_bytes - self.current_bytes) / - float(self.current_cps)) - return True - - def pulse_items(self, items): - """Called periodically to update the user interface. - This function includes details about the items being fetched - Return True to continue or False to cancel. - - """ - self.percent = (((self.current_bytes + self.current_items) * 100.0) / - float(self.total_bytes + self.total_items)) - if self.current_cps > 0: - self.eta = ((self.total_bytes - self.current_bytes) / - float(self.current_cps)) - return True - - def media_change(self, medium, drive): - """react to media change events.""" - - if apt_pkg._COMPAT_0_7: - dlDone = AttributeDeprecatedBy('dl_done') - dlQueued = AttributeDeprecatedBy('dl_queued') - dlFailed = AttributeDeprecatedBy('dl_failed') - dlHit = AttributeDeprecatedBy('dl_hit') - dlIgnored = AttributeDeprecatedBy('dl_ignored') - dlStatusStr = AttributeDeprecatedBy('dl_status_str') - currentBytes = AttributeDeprecatedBy('current_bytes') - currentItems = AttributeDeprecatedBy('current_items') - totalBytes = AttributeDeprecatedBy('total_bytes') - totalItems = AttributeDeprecatedBy('total_items') - currentCPS = AttributeDeprecatedBy('current_cps') - updateStatus = function_deprecated_by(update_status) - mediaChange = function_deprecated_by(media_change) - - -class TextFetchProgress(FetchProgress): - """ Ready to use progress object for terminal windows """ - - def __init__(self): - FetchProgress.__init__(self) - self.items = {} - - def update_status(self, uri, descr, short_descr, status): - """Called when the status of an item changes. - - This happens eg. when the downloads fails or is completed. - """ - if status != self.dl_queued: - print "\r%s %s" % (self.dl_status_str[status], descr) - self.items[uri] = status - - def pulse(self): - """Called periodically to update the user interface. - - Return True to continue or False to cancel. - """ - FetchProgress.pulse(self) - if self.current_cps > 0: - s = "[%2.f%%] %sB/s %s" % (self.percent, - apt_pkg.size_to_str(int(self.current_cps)), - apt_pkg.time_to_str(int(self.eta))) - else: - s = "%2.f%% [Working]" % (self.percent) - print "\r%s" % (s), - sys.stdout.flush() - return True - - def stop(self): - """Called when all files have been fetched.""" - print "\rDone downloading " - - def media_change(self, medium, drive): - """react to media change events.""" - print ("Media change: please insert the disc labeled " - "'%s' in the drive '%s' and press enter") % (medium, drive) - - return raw_input() not in ('c', 'C') - - if apt_pkg._COMPAT_0_7: - updateStatus = function_deprecated_by(update_status) - mediaChange = function_deprecated_by(media_change) - - -class DumbInstallProgress(object): - """Report the install progress. - - Subclass this class to implement install progress reporting. - """ - - def start_update(self): - """Start update.""" - - def run(self, pm): - """Start installation.""" - return pm.do_install() - - def finish_update(self): - """Called when update has finished.""" - - def update_interface(self): - """Called periodically to update the user interface""" - - if apt_pkg._COMPAT_0_7: - startUpdate = function_deprecated_by(start_update) - finishUpdate = function_deprecated_by(finish_update) - updateInterface = function_deprecated_by(update_interface) - - -class InstallProgress(DumbInstallProgress): - """An InstallProgress that is pretty useful. - - It supports the attributes 'percent' 'status' and callbacks for the dpkg - errors and conffiles and status changes. - """ - - def __init__(self): - DumbInstallProgress.__init__(self) - self.select_timeout = 0.1 - (read, write) = os.pipe() - self.writefd = write - self.statusfd = os.fdopen(read, "r") - fcntl.fcntl(self.statusfd.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) - self.read = "" - self.percent = 0.0 - self.status = "" - - def error(self, pkg, errormsg): - """Called when a error is detected during the install.""" - - def conffile(self, current, new): - """Called when a conffile question from dpkg is detected.""" - - def status_change(self, pkg, percent, status): - """Called when the status changed.""" - - def update_interface(self): - """Called periodically to update the interface.""" - if self.statusfd is None: - return - try: - while not self.read.endswith("\n"): - self.read += os.read(self.statusfd.fileno(), 1) - except OSError, (errno_, errstr): - # resource temporarly unavailable is ignored - if errno_ != errno.EAGAIN and errno_ != errno.EWOULDBLOCK: - print errstr - if not self.read.endswith("\n"): - return - - s = self.read - #print s - try: - (status, pkg, percent, status_str) = s.split(":", 3) - except ValueError: - # silently ignore lines that can't be parsed - self.read = "" - return - #print "percent: %s %s" % (pkg, float(percent)/100.0) - if status == "pmerror": - self.error(pkg, status_str) - elif status == "pmconffile": - # we get a string like this: - # 'current-conffile' 'new-conffile' useredited distedited - match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", status_str) - if match: - self.conffile(match.group(1), match.group(2)) - elif status == "pmstatus": - if float(percent) != self.percent or status_str != self.status: - self.status_change(pkg, float(percent), - status_str.strip()) - self.percent = float(percent) - self.status = status_str.strip() - self.read = "" - - def fork(self): - """Fork.""" - return os.fork() - - def wait_child(self): - """Wait for child progress to exit.""" - while True: - try: - select.select([self.statusfd], [], [], self.select_timeout) - except select.error, e: - if e[0] != errno.EINTR: - raise - - self.update_interface() - (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) - if pid == self.child_pid: - break - return res - - def run(self, pm): - """Start installing.""" - pid = self.fork() - if pid == 0: - # child - res = pm.do_install(self.writefd) - os._exit(res) - self.child_pid = pid - res = self.wait_child() - return os.WEXITSTATUS(res) - - if apt_pkg._COMPAT_0_7: - selectTimeout = AttributeDeprecatedBy('select_timeout') - statusChange = function_deprecated_by(status_change) - waitChild = function_deprecated_by(wait_child) - updateInterface = function_deprecated_by(update_interface) - - -class CdromProgress(object): - """Report the cdrom add progress. - - Subclass this class to implement cdrom add progress reporting. - """ - - def __init__(self): - pass - - def update(self, text, step): - """Called periodically to update the user interface.""" - - def ask_cdrom_name(self): - """Called to ask for the name of the cdrom.""" - - def change_cdrom(self): - """Called to ask for the cdrom to be changed.""" - - if apt_pkg._COMPAT_0_7: - askCdromName = function_deprecated_by(ask_cdrom_name) - changeCdrom = function_deprecated_by(change_cdrom) - - -class DpkgInstallProgress(InstallProgress): - """Progress handler for a local Debian package installation.""" - - def run(self, debfile): - """Start installing the given Debian package.""" - if apt_pkg._COMPAT_0_7: # Deprecated stuff - self.debfile = debfile - self.debname = os.path.basename(debfile).split("_")[0] - pid = self.fork() - if pid == 0: - # child - res = os.system("/usr/bin/dpkg --status-fd %s -i %s" % \ - (self.writefd, debfile)) - os._exit(os.WEXITSTATUS(res)) - self.child_pid = pid - res = self.wait_child() - return res +#from apt.progress.text import AcquireProgress as TextAcquireProgress +#from apt.progress.text import OpProgress as TextOpProgress - def update_interface(self): - """Process status messages from dpkg.""" - if self.statusfd is None: - return - while True: - try: - self.read += os.read(self.statusfd.fileno(), 1) - except OSError, (errno_, errstr): - # resource temporarly unavailable is ignored - if errno_ != 11: - print errstr - break - if not self.read.endswith("\n"): - continue +__all__ = [] #'TextAcquireProgress', 'TextOpProgress'] - statusl = self.read.split(":") - if len(statusl) < 3: - print "got garbage from dpkg: '%s'" % self.read - self.read = "" - break - pkg_name = statusl[1].strip() - status = statusl[2].strip() - #print status - if status == "error": - self.error(pkg_name, status) - elif status == "conffile-prompt": - # we get a string like this: - # 'current-conffile' 'new-conffile' useredited distedited - match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", statusl[3]) - if match: - self.conffile(match.group(1), match.group(2)) - else: - self.status = status - self.read = "" +if apt_pkg._COMPAT_0_7: + import apt.progress.old + from apt.progress.old import * - if apt_pkg._COMPAT_0_7: - updateInterface = function_deprecated_by(update_interface) + __all__ += apt.progress.old.__all__ diff --git a/apt/progress/old.py b/apt/progress/old.py new file mode 100644 index 00000000..3c5d4588 --- /dev/null +++ b/apt/progress/old.py @@ -0,0 +1,426 @@ +# progress.py - progress reporting classes +# +# Copyright (c) 2005-2009 Canonical +# +# Author: Michael Vogt +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA +"""progress reporting classes. + +This module provides classes for progress reporting. They can be used with +e.g., for reporting progress on the cache opening process, the cache update +progress, or the package install progress. +""" + +import errno +import fcntl +import os +import re +import select +import sys + +import apt_pkg +from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by + + +__all__ = ('CdromProgress', 'DpkgInstallProgress', 'DumbInstallProgress', + 'FetchProgress', 'InstallProgress', 'OpProgress', 'OpTextProgress', + 'TextFetchProgress') + + +class OpProgress(object): + """Abstract class to implement reporting on cache opening. + + Subclass this class to implement simple Operation progress reporting. + """ + + def __init__(self): + self.op = None + self.sub_op = None + + def update(self, percent): + """Called periodically to update the user interface.""" + + def done(self): + """Called once an operation has been completed.""" + + if apt_pkg._COMPAT_0_7: + subOp = AttributeDeprecatedBy('sub_op') + + +class OpTextProgress(OpProgress): + """A simple text based cache open reporting class.""" + + def __init__(self): + OpProgress.__init__(self) + + def update(self, percent): + """Called periodically to update the user interface.""" + sys.stdout.write("\r%s: %.2i " % (self.sub_op, percent)) + sys.stdout.flush() + + def done(self): + """Called once an operation has been completed.""" + sys.stdout.write("\r%s: Done\n" % self.op) + + +class FetchProgress(object): + """Report the download/fetching progress. + + Subclass this class to implement fetch progress reporting + """ + + # download status constants + dl_done = 0 + dl_queued = 1 + dl_failed = 2 + dl_hit = 3 + dl_ignored = 4 + dl_status_str = {dl_done: "Done", + dl_queued: "Queued", + dl_failed: "Failed", + dl_hit: "Hit", + dl_ignored: "Ignored"} + + def __init__(self): + self.eta = 0.0 + self.percent = 0.0 + # Make checking easier + self.current_bytes = 0 + self.current_items = 0 + self.total_bytes = 0 + self.total_items = 0 + self.current_cps = 0 + + def start(self): + """Called when the fetching starts.""" + + def stop(self): + """Called when all files have been fetched.""" + + def update_status(self, uri, descr, short_descr, status): + """Called when the status of an item changes. + + This happens eg. when the downloads fails or is completed. + """ + + def update_status_full(self, uri, descr, short_descr, status, file_size, + partial_size): + """Called when the status of an item changes. + + This happens eg. when the downloads fails or is completed. This + version include information on current filesize and partial size + """ + + def pulse(self): + """Called periodically to update the user interface. + + Return True to continue or False to cancel. + """ + self.percent = (((self.current_bytes + self.current_items) * 100.0) / + float(self.total_bytes + self.total_items)) + if self.current_cps > 0: + self.eta = ((self.total_bytes - self.current_bytes) / + float(self.current_cps)) + return True + + def pulse_items(self, items): + """Called periodically to update the user interface. + This function includes details about the items being fetched + Return True to continue or False to cancel. + + """ + self.percent = (((self.current_bytes + self.current_items) * 100.0) / + float(self.total_bytes + self.total_items)) + if self.current_cps > 0: + self.eta = ((self.total_bytes - self.current_bytes) / + float(self.current_cps)) + return True + + def media_change(self, medium, drive): + """react to media change events.""" + + if apt_pkg._COMPAT_0_7: + dlDone = AttributeDeprecatedBy('dl_done') + dlQueued = AttributeDeprecatedBy('dl_queued') + dlFailed = AttributeDeprecatedBy('dl_failed') + dlHit = AttributeDeprecatedBy('dl_hit') + dlIgnored = AttributeDeprecatedBy('dl_ignored') + dlStatusStr = AttributeDeprecatedBy('dl_status_str') + currentBytes = AttributeDeprecatedBy('current_bytes') + currentItems = AttributeDeprecatedBy('current_items') + totalBytes = AttributeDeprecatedBy('total_bytes') + totalItems = AttributeDeprecatedBy('total_items') + currentCPS = AttributeDeprecatedBy('current_cps') + updateStatus = function_deprecated_by(update_status) + mediaChange = function_deprecated_by(media_change) + + +class TextFetchProgress(FetchProgress): + """ Ready to use progress object for terminal windows """ + + def __init__(self): + FetchProgress.__init__(self) + self.items = {} + + def update_status(self, uri, descr, short_descr, status): + """Called when the status of an item changes. + + This happens eg. when the downloads fails or is completed. + """ + if status != self.dl_queued: + print "\r%s %s" % (self.dl_status_str[status], descr) + self.items[uri] = status + + def pulse(self): + """Called periodically to update the user interface. + + Return True to continue or False to cancel. + """ + FetchProgress.pulse(self) + if self.current_cps > 0: + s = "[%2.f%%] %sB/s %s" % (self.percent, + apt_pkg.size_to_str(int(self.current_cps)), + apt_pkg.time_to_str(int(self.eta))) + else: + s = "%2.f%% [Working]" % (self.percent) + print "\r%s" % (s), + sys.stdout.flush() + return True + + def stop(self): + """Called when all files have been fetched.""" + print "\rDone downloading " + + def media_change(self, medium, drive): + """react to media change events.""" + print ("Media change: please insert the disc labeled " + "'%s' in the drive '%s' and press enter") % (medium, drive) + + return raw_input() not in ('c', 'C') + + if apt_pkg._COMPAT_0_7: + updateStatus = function_deprecated_by(update_status) + mediaChange = function_deprecated_by(media_change) + + +class DumbInstallProgress(object): + """Report the install progress. + + Subclass this class to implement install progress reporting. + """ + + def start_update(self): + """Start update.""" + + def run(self, pm): + """Start installation.""" + return pm.do_install() + + def finish_update(self): + """Called when update has finished.""" + + def update_interface(self): + """Called periodically to update the user interface""" + + if apt_pkg._COMPAT_0_7: + startUpdate = function_deprecated_by(start_update) + finishUpdate = function_deprecated_by(finish_update) + updateInterface = function_deprecated_by(update_interface) + + +class InstallProgress(DumbInstallProgress): + """An InstallProgress that is pretty useful. + + It supports the attributes 'percent' 'status' and callbacks for the dpkg + errors and conffiles and status changes. + """ + + def __init__(self): + DumbInstallProgress.__init__(self) + self.select_timeout = 0.1 + (read, write) = os.pipe() + self.writefd = write + self.statusfd = os.fdopen(read, "r") + fcntl.fcntl(self.statusfd.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) + self.read = "" + self.percent = 0.0 + self.status = "" + + def error(self, pkg, errormsg): + """Called when a error is detected during the install.""" + + def conffile(self, current, new): + """Called when a conffile question from dpkg is detected.""" + + def status_change(self, pkg, percent, status): + """Called when the status changed.""" + + def update_interface(self): + """Called periodically to update the interface.""" + if self.statusfd is None: + return + try: + while not self.read.endswith("\n"): + self.read += os.read(self.statusfd.fileno(), 1) + except OSError, (errno_, errstr): + # resource temporarly unavailable is ignored + if errno_ != errno.EAGAIN and errno_ != errno.EWOULDBLOCK: + print errstr + if not self.read.endswith("\n"): + return + + s = self.read + #print s + try: + (status, pkg, percent, status_str) = s.split(":", 3) + except ValueError: + # silently ignore lines that can't be parsed + self.read = "" + return + #print "percent: %s %s" % (pkg, float(percent)/100.0) + if status == "pmerror": + self.error(pkg, status_str) + elif status == "pmconffile": + # we get a string like this: + # 'current-conffile' 'new-conffile' useredited distedited + match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", status_str) + if match: + self.conffile(match.group(1), match.group(2)) + elif status == "pmstatus": + if float(percent) != self.percent or status_str != self.status: + self.status_change(pkg, float(percent), + status_str.strip()) + self.percent = float(percent) + self.status = status_str.strip() + self.read = "" + + def fork(self): + """Fork.""" + return os.fork() + + def wait_child(self): + """Wait for child progress to exit.""" + while True: + try: + select.select([self.statusfd], [], [], self.select_timeout) + except select.error, e: + if e[0] != errno.EINTR: + raise + + self.update_interface() + (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) + if pid == self.child_pid: + break + return res + + def run(self, pm): + """Start installing.""" + pid = self.fork() + if pid == 0: + # child + res = pm.do_install(self.writefd) + os._exit(res) + self.child_pid = pid + res = self.wait_child() + return os.WEXITSTATUS(res) + + if apt_pkg._COMPAT_0_7: + selectTimeout = AttributeDeprecatedBy('select_timeout') + statusChange = function_deprecated_by(status_change) + waitChild = function_deprecated_by(wait_child) + updateInterface = function_deprecated_by(update_interface) + + +class CdromProgress(object): + """Report the cdrom add progress. + + Subclass this class to implement cdrom add progress reporting. + """ + + def __init__(self): + pass + + def update(self, text, step): + """Called periodically to update the user interface.""" + + def ask_cdrom_name(self): + """Called to ask for the name of the cdrom.""" + + def change_cdrom(self): + """Called to ask for the cdrom to be changed.""" + + if apt_pkg._COMPAT_0_7: + askCdromName = function_deprecated_by(ask_cdrom_name) + changeCdrom = function_deprecated_by(change_cdrom) + + +class DpkgInstallProgress(InstallProgress): + """Progress handler for a local Debian package installation.""" + + def run(self, debfile): + """Start installing the given Debian package.""" + if apt_pkg._COMPAT_0_7: # Deprecated stuff + self.debfile = debfile + self.debname = os.path.basename(debfile).split("_")[0] + + pid = self.fork() + if pid == 0: + # child + res = os.system("/usr/bin/dpkg --status-fd %s -i %s" % \ + (self.writefd, debfile)) + os._exit(os.WEXITSTATUS(res)) + self.child_pid = pid + res = self.wait_child() + return res + + def update_interface(self): + """Process status messages from dpkg.""" + if self.statusfd is None: + return + while True: + try: + self.read += os.read(self.statusfd.fileno(), 1) + except OSError, (errno_, errstr): + # resource temporarly unavailable is ignored + if errno_ != 11: + print errstr + break + if not self.read.endswith("\n"): + continue + + statusl = self.read.split(":") + if len(statusl) < 3: + print "got garbage from dpkg: '%s'" % self.read + self.read = "" + break + pkg_name = statusl[1].strip() + status = statusl[2].strip() + #print status + if status == "error": + self.error(pkg_name, status) + elif status == "conffile-prompt": + # we get a string like this: + # 'current-conffile' 'new-conffile' useredited distedited + match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", statusl[3]) + if match: + self.conffile(match.group(1), match.group(2)) + else: + self.status = status + self.read = "" + + if apt_pkg._COMPAT_0_7: + updateInterface = function_deprecated_by(update_interface) -- cgit v1.2.3 From 837e2fd927906c229801e41a5effbf95f9c6a106 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 17 Jul 2009 16:14:56 +0200 Subject: apt/progress: Fix apt.progress with COMPAT_0_7 --- apt/progress/__init__.py | 13 ++++--------- apt/progress/old.py | 6 ++---- 2 files changed, 6 insertions(+), 13 deletions(-) (limited to 'apt/progress/__init__.py') diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index 67880903..c75c368b 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -17,13 +17,8 @@ """Progress reporting.""" import apt_pkg -#from apt.progress.text import AcquireProgress as TextAcquireProgress -#from apt.progress.text import OpProgress as TextOpProgress - -__all__ = [] #'TextAcquireProgress', 'TextOpProgress'] - if apt_pkg._COMPAT_0_7: - import apt.progress.old - from apt.progress.old import * - - __all__ += apt.progress.old.__all__ + from apt.progress.old import (CdromProgress, DpkgInstallProgress, + DumbInstallProgress, FetchProgress, + InstallProgress, OpProgress, + OpTextProgress, TextFetchProgress) diff --git a/apt/progress/old.py b/apt/progress/old.py index 3c5d4588..d4ff5815 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -18,7 +18,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -"""progress reporting classes. +"""Deprecated progress reporting classes. This module provides classes for progress reporting. They can be used with e.g., for reporting progress on the cache opening process, the cache update @@ -36,9 +36,7 @@ import apt_pkg from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by -__all__ = ('CdromProgress', 'DpkgInstallProgress', 'DumbInstallProgress', - 'FetchProgress', 'InstallProgress', 'OpProgress', 'OpTextProgress', - 'TextFetchProgress') +__all__ = [] class OpProgress(object): -- cgit v1.2.3 From e556b2cbbe5878c33d9e7302e637cc7f35dd14bf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 31 Jul 2009 20:51:57 +0200 Subject: apt/progress: Large update, introducing apt.progress.base.InstallProgress. This contains many updates including the introduction of a new InstallProgress class which replaces the old InstallProgress and DpkgInstallProgress classes. --- apt/debfile.py | 2 +- apt/package.py | 2 +- apt/progress/__init__.py | 13 ++- apt/progress/base.py | 135 ++++++++++++++++++++-- apt/progress/gtk2.py | 82 +++++-------- apt/progress/old.py | 294 +++++++++-------------------------------------- apt/progress/text.py | 2 + 7 files changed, 225 insertions(+), 305 deletions(-) (limited to 'apt/progress/__init__.py') diff --git a/apt/debfile.py b/apt/debfile.py index e05233f4..fd6c1532 100644 --- a/apt/debfile.py +++ b/apt/debfile.py @@ -417,7 +417,7 @@ class DebPackage(object): def install(self, install_progress=None): """Install the package.""" if install_progress is None: - return os.system("dpkg -i %s" % self.filename) + return os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "-i", self.filename) else: try: install_progress.start_update() diff --git a/apt/package.py b/apt/package.py index f8e1354b..9a1b0d68 100644 --- a/apt/package.py +++ b/apt/package.py @@ -1180,7 +1180,7 @@ class Package(object): like apt.progress.text.AcquireProgress(). The parameter *iprogress* refers to an InstallProgress() object, as - found in apt.progress.old. + found in apt.progress.base. """ self._pcache._depcache.commit(fprogress, iprogress) diff --git a/apt/progress/__init__.py b/apt/progress/__init__.py index c75c368b..10c11021 100644 --- a/apt/progress/__init__.py +++ b/apt/progress/__init__.py @@ -1,3 +1,5 @@ +# apt/progress/__init__.py - Initialization file for apt.progress. +# # Copyright (c) 2009 Julian Andres Klode # # This program is free software; you can redistribute it and/or @@ -14,9 +16,18 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -"""Progress reporting.""" +"""Progress reporting. + +This package provides progress reporting for the python-apt package. The module +'base' provides classes with no output, the module 'gtk2' provides classes for +GTK+ applications, and the module 'text' provides classes for terminals, etc. +""" import apt_pkg + +__all__ = [] + + if apt_pkg._COMPAT_0_7: from apt.progress.old import (CdromProgress, DpkgInstallProgress, DumbInstallProgress, FetchProgress, diff --git a/apt/progress/base.py b/apt/progress/base.py index fc5a8107..08d35533 100644 --- a/apt/progress/base.py +++ b/apt/progress/base.py @@ -21,6 +21,13 @@ Custom progress classes should inherit from these classes. They can also be used as dummy progress classes which simply do nothing. """ +import errno +import fcntl +import os +import re +import select + +__all__ = ['AcquireProgress', 'CdromProgress', 'InstallProgress', 'OpProgress'] class AcquireProgress(object): @@ -125,23 +132,131 @@ class CdromProgress(object): class InstallProgress(object): - """Report the install progress. + """Class to report the progress of installing packages.""" - Subclass this class to implement install progress reporting. - """ + percent, select_timeout, status = 0.0, 0.1, "" - def start_update(self): - """Start update.""" + def __init__(self): + (read, write) = os.pipe() + self.writefd = os.fdopen(write, "w") + self.statusfd = os.fdopen(read, "r") + fcntl.fcntl(self.statusfd, fcntl.F_SETFL, os.O_NONBLOCK) - def run(self, pm): - """Start installation.""" - return pm.do_install() + def start_update(self): + """(Abstract) Start update.""" def finish_update(self): - """Called when update has finished.""" + """(Abstract) Called when update has finished.""" + + def error(self, pkg, errormsg): + """(Abstract) Called when a error is detected during the install.""" + + def conffile(self, current, new): + """(Abstract) Called when a conffile question from dpkg is detected.""" + + def status_change(self, pkg, percent, status): + """(Abstract) Called when the status changed.""" + + def processing(self, pkg, stage): + """(Abstract) Sent just before a processing stage starts. + + The parameter 'stage' is one of "upgrade", "install" + (both sent before unpacking), "configure", "trigproc", "remove", + "purge". This method is used for dpkg only. + """ + + def run(self, obj): + """Install using the object 'obj'. + + This functions runs install actions. The parameter 'obj' may either + be a PackageManager object in which case its do_install() method is + called or the path to a deb file. + + If the object is a PackageManager, the functions returns the result + of calling its do_install() method. Otherwise, the function returns + the exit status of dpkg. In both cases, 0 means that there were no + problems. + """ + pid = self.fork() + if pid == 0: + try: + os._exit(obj.do_install(self.writefd.fileno())) + except AttributeError: + os._exit(os.spawnlp(os.P_WAIT, "dpkg", "dpkg", "--status-fd", + str(self.writefd.fileno()), "-i", obj)) + self.child_pid = pid + res = self.wait_child() + return os.WEXITSTATUS(res) + + def fork(self): + """Fork.""" + return os.fork() def update_interface(self): - """Called periodically to update the user interface.""" + """Update the interface.""" + try: + line = self.statusfd.readline() + except IOError, (errno_, errstr): + # resource temporarly unavailable is ignored + if errno_ != errno.EAGAIN and errno_ != errno.EWOULDBLOCK: + print errstr + return + + pkgname = status = status_str = percent = base = "" + + if line.startswith('pm'): + try: + (status, pkgname, percent, status_str) = line.split(":", 3) + except ValueError: + # silently ignore lines that can't be parsed + self.read = "" + return + elif line.startswith('status'): + try: + (base, pkgname, status, status_str) = line.split(": ", 3) + except ValueError: + (base, pkgname, status) = line.split(": ", 2) + elif line.startswith('processing'): + (status, status_str, pkgname) = line.split(": ", 2) + self.processing(pkgname.strip(), status_str.strip()) + + if status == 'pmerror' or status == 'error': + self.error(pkgname, status_str) + elif status == 'conffile-prompt' or status == 'pmconffile': + match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", status_str) + if match: + self.conffile(match.group(1), match.group(2)) + elif status == "pmstatus": + if float(percent) != self.percent or status_str != self.status: + self.status_change(pkgname, float(percent), status_str.strip()) + self.percent = float(percent) + self.status = status_str.strip() + + def wait_child(self): + """Wait for child progress to exit. + + This method is responsible for calling update_interface() from time to + time. It exits once the child has exited. + """ + (pid, res) = (0, 0) + while True: + try: + select.select([self.statusfd], [], [], self.select_timeout) + except select.error, err: + if err[0] != errno.EINTR: + raise + + self.update_interface() + try: + (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) + if pid == self.child_pid: + break + except OSError, err: + if err[0] != errno.EINTR: + raise + if err[0] == errno.ECHILD: + break + return res class OpProgress(object): diff --git a/apt/progress/gtk2.py b/apt/progress/gtk2.py index edba0a4d..22788984 100644 --- a/apt/progress/gtk2.py +++ b/apt/progress/gtk2.py @@ -11,7 +11,7 @@ # published by the Free Software Foundation; either version 2 of the # License, or (at your option) any later version. # -# his program is distributed in the hope that it will be useful, +# This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. @@ -42,6 +42,9 @@ from apt.deprecation import function_deprecated_by, AttributeDeprecatedBy from apt.progress import base, old +__all__ = ['GInstallProgress', 'GOpProgress', 'GtkAptProgress'] + + def mksig(params=(), run=gobject.SIGNAL_RUN_FIRST, rettype=gobject.TYPE_NONE): """Simplified Create a gobject signal. @@ -90,7 +93,7 @@ class GOpProgress(gobject.GObject, base.OpProgress): Op = AttributeDeprecatedBy('op') -class GInstallProgress(gobject.GObject, old.InstallProgress): +class GInstallProgress(gobject.GObject, base.InstallProgress): """Installation progress with GObject signals. Signals: @@ -114,7 +117,7 @@ class GInstallProgress(gobject.GObject, old.InstallProgress): "status-finished": mksig()} def __init__(self, term): - old.InstallProgress.__init__(self) + base.InstallProgress.__init__(self) gobject.GObject.__init__(self) self.finished = False self.time_last_update = time.time() @@ -152,6 +155,11 @@ class GInstallProgress(gobject.GObject, old.InstallProgress): """ self.emit("status-started") + def run(self, obj): + """Run.""" + self.finished = False + return base.InstallProgress.run(self, obj) + def finish_update(self): """Called when the update finished. @@ -159,6 +167,11 @@ class GInstallProgress(gobject.GObject, old.InstallProgress): """ self.emit("status-finished") + def processing(self, pkg, stage): + """Called when entering a new stage in dpkg.""" + # We have no percentage or alike, send -1 to let the bar pulse. + self.emit("status-changed", ("Installing %s...") % pkg, -1) + def status_change(self, pkg, percent, status): """Called when the status changed. @@ -172,7 +185,7 @@ class GInstallProgress(gobject.GObject, old.InstallProgress): Emits: status-timeout() [When a timeout happens] """ - old.InstallProgress.update_interface(self) + base.InstallProgress.update_interface(self) while self._context.pending(): self._context.iteration() if self.time_last_update + self.INSTALL_TIMEOUT < time.time(): @@ -197,34 +210,7 @@ class GInstallProgress(gobject.GObject, old.InstallProgress): childExited = function_deprecated_by(child_exited) -class GDpkgInstallProgress(old.DpkgInstallProgress, - GInstallProgress): - """An InstallProgress for local installations. - - Signals: - - * status-changed(str: status, int: percent) - * status-started() - Not Implemented yet - * status-finished() - * status-timeout() - When the maintainer script hangs - * status-error() - When an error happens - * status-conffile() - On Conffile - """ - - def run(self, debfile): - """Install the given package.""" - old.DpkgInstallProgress.run(self, debfile) - - def update_interface(self): - """Called periodically to update the interface. - - Emits: status-timeout() [When a timeout happens]""" - old.DpkgInstallProgress.update_interface(self) - if self.time_last_update + self.INSTALL_TIMEOUT < time.time(): - self.emit("status-timeout") - - if apt_pkg._COMPAT_0_7: - updateInterface = function_deprecated_by(update_interface) +GDpkgInstallProgress = GInstallProgress class GFetchProgress(gobject.GObject, old.FetchProgress): @@ -235,6 +221,8 @@ class GFetchProgress(gobject.GObject, old.FetchProgress): * status-changed(str: description, int: percent) * status-started() * status-finished() + + DEPRECATED. """ __gsignals__ = {"status-changed": mksig((str, int)), @@ -258,19 +246,19 @@ class GFetchProgress(gobject.GObject, old.FetchProgress): def pulse(self): old.FetchProgress.pulse(self) - current_item = self.current_items + 1 - if current_item > self.total_items: - current_item = self.total_items + current_item = self.currentItems + 1 + if current_item > self.totalItems: + current_item = self.totalItems if self.current_cps > 0: text = (_("Downloading file %(current)li of %(total)li with " "%(speed)s/s") % \ {"current": current_item, - "total": self.total_items, - "speed": apt_pkg.size_to_str(self.current_cps)}) + "total": self.totalItems, + "speed": apt_pkg.size_to_str(self.currentCPS)}) else: text = (_("Downloading file %(current)li of %(total)li") % \ {"current": current_item, - "total": self.total_items}) + "total": self.totalItems}) self.emit("status-changed", text, self.percent) while self._context.pending(): self._context.iteration() @@ -328,19 +316,6 @@ class GtkAptProgress(gtk.VBox): self._on_status_timeout) self._progress_install.connect("status-conffile", self._on_status_timeout) - self._progress_dpkg_install = GDpkgInstallProgress(self._terminal) - self._progress_dpkg_install.connect("status-changed", - self._on_status_changed) - self._progress_dpkg_install.connect("status-started", - self._on_status_started) - self._progress_dpkg_install.connect("status-finished", - self._on_status_finished) - self._progress_dpkg_install.connect("status-timeout", - self._on_status_timeout) - self._progress_dpkg_install.connect("status-error", - self._on_status_timeout) - self._progress_dpkg_install.connect("status-conffile", - self._on_status_timeout) def clear(self): """Reset all status information.""" @@ -361,7 +336,7 @@ class GtkAptProgress(gtk.VBox): @property def dpkg_install(self): """Return the install progress handler for dpkg.""" - return self._dpkg_progress_install + return self._progress_install @property def fetch(self): @@ -383,7 +358,7 @@ class GtkAptProgress(gtk.VBox): def _on_status_changed(self, progress, status, percent): """Called when the status changed.""" self._label.set_text(status) - if percent is None: + if percent is None or percent == -1: self._progressbar.pulse() else: self._progressbar.set_fraction(percent/100.0) @@ -431,6 +406,7 @@ def _test(): """Test function""" import sys + import apt from apt.debfile import DebPackage win = gtk.Window() diff --git a/apt/progress/old.py b/apt/progress/old.py index 6b6e21de..c2d95b85 100644 --- a/apt/progress/old.py +++ b/apt/progress/old.py @@ -20,72 +20,51 @@ # USA """Deprecated progress reporting classes. -This module provides classes for progress reporting. They can be used with -e.g., for reporting progress on the cache opening process, the cache update -progress, or the package install progress. +This module provides classes for compatibility with python-apt 0.7. They are +completely deprecated and should not be used anymore. """ -import errno -import fcntl + import os -import re -import select import sys import apt_pkg from apt.deprecation import AttributeDeprecatedBy, function_deprecated_by +import warnings from apt.progress import base, text - __all__ = [] class OpProgress(base.OpProgress): - """Abstract class to implement reporting on cache opening. - - Subclass this class to implement simple Operation progress reporting. - """ + """Abstract class to implement reporting on cache opening.""" - if apt_pkg._COMPAT_0_7: - subOp = AttributeDeprecatedBy('subop') - Op = AttributeDeprecatedBy('op') + subOp = AttributeDeprecatedBy('subop') + Op = AttributeDeprecatedBy('op') -class OpTextProgress(text.OpProgress): +class OpTextProgress(OpProgress, text.OpProgress): """A simple text based cache open reporting class.""" - if apt_pkg._COMPAT_0_7: - subOp = AttributeDeprecatedBy('subop') - Op = AttributeDeprecatedBy('op') - class FetchProgress(object): - """Report the download/fetching progress. - - Subclass this class to implement fetch progress reporting - """ + """Report the download/fetching progress.""" # download status constants - dl_done = 0 - dl_queued = 1 - dl_failed = 2 - dl_hit = 3 - dl_ignored = 4 - dl_status_str = {dl_done: "Done", - dl_queued: "Queued", - dl_failed: "Failed", - dl_hit: "Hit", - dl_ignored: "Ignored"} + (dlDone, dlQueued, dlFailed, dlHit, dlIgnored) = range(5) + dlStatusStr = {dlDone: "Done", dlQueued: "Queued", dlFailed: "Failed", + dlHit: "Hit", dlIgnored: "Ignored"} def __init__(self): self.eta = 0.0 self.percent = 0.0 # Make checking easier - self.current_bytes = 0 - self.current_items = 0 - self.total_bytes = 0 - self.total_items = 0 - self.current_cps = 0 + self.currentBytes = 0 + self.currentItems = 0 + self.totalBytes = 0 + self.totalItems = 0 + self.currentCPS = 0 + warnings.warn("FetchProgress() is deprecated.", DeprecationWarning) def start(self): """Called when the fetching starts.""" @@ -93,7 +72,7 @@ class FetchProgress(object): def stop(self): """Called when all files have been fetched.""" - def update_status(self, uri, descr, short_descr, status): + def updateStatus(self, uri, descr, short_descr, status): """Called when the status of an item changes. This happens eg. when the downloads fails or is completed. @@ -112,11 +91,11 @@ class FetchProgress(object): Return True to continue or False to cancel. """ - self.percent = (((self.current_bytes + self.current_items) * 100.0) / - float(self.total_bytes + self.total_items)) - if self.current_cps > 0: - self.eta = ((self.total_bytes - self.current_bytes) / - float(self.current_cps)) + self.percent = (((self.currentBytes + self.currentItems) * 100.0) / + float(self.totalBytes + self.totalItems)) + if self.currentCPS > 0: + self.eta = ((self.totalBytes - self.currentBytes) / + float(self.currentCPS)) return True def pulse_items(self, items): @@ -125,31 +104,16 @@ class FetchProgress(object): Return True to continue or False to cancel. """ - self.percent = (((self.current_bytes + self.current_items) * 100.0) / - float(self.total_bytes + self.total_items)) - if self.current_cps > 0: - self.eta = ((self.total_bytes - self.current_bytes) / - float(self.current_cps)) + self.percent = (((self.currentBytes + self.currentItems) * 100.0) / + float(self.totalBytes + self.totalItems)) + if self.currentCPS > 0: + self.eta = ((self.totalBytes - self.currentBytes) / + float(self.currentCPS)) return True - def media_change(self, medium, drive): + def mediaChange(self, medium, drive): """react to media change events.""" - if apt_pkg._COMPAT_0_7: - dlDone = AttributeDeprecatedBy('dl_done') - dlQueued = AttributeDeprecatedBy('dl_queued') - dlFailed = AttributeDeprecatedBy('dl_failed') - dlHit = AttributeDeprecatedBy('dl_hit') - dlIgnored = AttributeDeprecatedBy('dl_ignored') - dlStatusStr = AttributeDeprecatedBy('dl_status_str') - currentBytes = AttributeDeprecatedBy('current_bytes') - currentItems = AttributeDeprecatedBy('current_items') - totalBytes = AttributeDeprecatedBy('total_bytes') - totalItems = AttributeDeprecatedBy('total_items') - currentCPS = AttributeDeprecatedBy('current_cps') - updateStatus = function_deprecated_by(update_status) - mediaChange = function_deprecated_by(media_change) - class TextFetchProgress(FetchProgress): """ Ready to use progress object for terminal windows """ @@ -158,13 +122,13 @@ class TextFetchProgress(FetchProgress): FetchProgress.__init__(self) self.items = {} - def update_status(self, uri, descr, short_descr, status): + def updateStatus(self, uri, descr, short_descr, status): """Called when the status of an item changes. This happens eg. when the downloads fails or is completed. """ - if status != self.dl_queued: - print "\r%s %s" % (self.dl_status_str[status], descr) + if status != self.dlQueued: + print "\r%s %s" % (self.dlStatusStr[status], descr) self.items[uri] = status def pulse(self): @@ -173,9 +137,9 @@ class TextFetchProgress(FetchProgress): Return True to continue or False to cancel. """ FetchProgress.pulse(self) - if self.current_cps > 0: + if self.currentCPS > 0: s = "[%2.f%%] %sB/s %s" % (self.percent, - apt_pkg.size_to_str(int(self.current_cps)), + apt_pkg.size_to_str(int(self.currentCPS)), apt_pkg.time_to_str(int(self.eta))) else: s = "%2.f%% [Working]" % (self.percent) @@ -187,16 +151,23 @@ class TextFetchProgress(FetchProgress): """Called when all files have been fetched.""" print "\rDone downloading " - def media_change(self, medium, drive): + def mediaChange(self, medium, drive): """react to media change events.""" print ("Media change: please insert the disc labeled " "'%s' in the drive '%s' and press enter") % (medium, drive) return raw_input() not in ('c', 'C') - if apt_pkg._COMPAT_0_7: - updateStatus = function_deprecated_by(update_status) - mediaChange = function_deprecated_by(media_change) + +class CdromProgress(base.CdromProgress): + """Report the cdrom add progress. + + This class has been replaced by apt_pkg.CdromProgress. + """ + _basetype = base.CdromProgress + askCdromName = function_deprecated_by(_basetype.ask_cdrom_name) + changeCdrom = function_deprecated_by(_basetype.change_cdrom) + del _basetype class DumbInstallProgress(base.InstallProgress): @@ -208,127 +179,19 @@ class DumbInstallProgress(base.InstallProgress): startUpdate = function_deprecated_by(base.InstallProgress.start_update) finishUpdate = function_deprecated_by(base.InstallProgress.finish_update) updateInterface = function_deprecated_by( - base.InstallProgress.update_interface) + base.InstallProgress.update_interface) -class InstallProgress(DumbInstallProgress): +class InstallProgress(DumbInstallProgress, base.InstallProgress): """An InstallProgress that is pretty useful. It supports the attributes 'percent' 'status' and callbacks for the dpkg errors and conffiles and status changes. """ - def __init__(self): - DumbInstallProgress.__init__(self) - self.select_timeout = 0.1 - (read, write) = os.pipe() - self.writefd = write - self.statusfd = os.fdopen(read, "r") - fcntl.fcntl(self.statusfd.fileno(), fcntl.F_SETFL, os.O_NONBLOCK) - self.read = "" - self.percent = 0.0 - self.status = "" - - def error(self, pkg, errormsg): - """Called when a error is detected during the install.""" - - def conffile(self, current, new): - """Called when a conffile question from dpkg is detected.""" - - def status_change(self, pkg, percent, status): - """Called when the status changed.""" - - def update_interface(self): - """Called periodically to update the interface.""" - if self.statusfd is None: - return - try: - while not self.read.endswith("\n"): - self.read += os.read(self.statusfd.fileno(), 1) - except OSError, (errno_, errstr): - # resource temporarly unavailable is ignored - if errno_ != errno.EAGAIN and errno_ != errno.EWOULDBLOCK: - print errstr - if not self.read.endswith("\n"): - return - - s = self.read - #print s - try: - (status, pkg, percent, status_str) = s.split(":", 3) - except ValueError: - # silently ignore lines that can't be parsed - self.read = "" - return - #print "percent: %s %s" % (pkg, float(percent)/100.0) - if status == "pmerror": - self.error(pkg, status_str) - elif status == "pmconffile": - # we get a string like this: - # 'current-conffile' 'new-conffile' useredited distedited - match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", status_str) - if match: - self.conffile(match.group(1), match.group(2)) - elif status == "pmstatus": - if float(percent) != self.percent or status_str != self.status: - self.status_change(pkg, float(percent), - status_str.strip()) - self.percent = float(percent) - self.status = status_str.strip() - self.read = "" - - def fork(self): - """Fork.""" - return os.fork() - - def wait_child(self): - """Wait for child progress to exit.""" - while True: - try: - select.select([self.statusfd], [], [], self.select_timeout) - except select.error, (errno_, errstr): - if errno_ != errno.EINTR: - raise - - self.update_interface() - try: - (pid, res) = os.waitpid(self.child_pid, os.WNOHANG) - if pid == self.child_pid: - break - except OSError, (errno_, errstr): - if errno_ != errno.EINTR: - raise - if errno_ == errno.ECHILD: - break - return res - - def run(self, pm): - """Start installing.""" - pid = self.fork() - if pid == 0: - # child - res = pm.do_install(self.writefd) - os._exit(res) - self.child_pid = pid - res = self.wait_child() - return os.WEXITSTATUS(res) - - if apt_pkg._COMPAT_0_7: - selectTimeout = AttributeDeprecatedBy('select_timeout') - statusChange = function_deprecated_by(status_change) - waitChild = function_deprecated_by(wait_child) - updateInterface = function_deprecated_by(update_interface) - - -class CdromProgress(base.CdromProgress): - """Report the cdrom add progress. - - This class has been replaced by apt_pkg.CdromProgress. - """ - _basetype = base.CdromProgress - askCdromName = function_deprecated_by(_basetype.ask_cdrom_name) - changeCdrom = function_deprecated_by(_basetype.change_cdrom) - del _basetype + selectTimeout = AttributeDeprecatedBy('select_timeout') + statusChange = function_deprecated_by(base.InstallProgress.status_change) + waitChild = function_deprecated_by(base.InstallProgress.wait_child) class DpkgInstallProgress(InstallProgress): @@ -336,54 +199,7 @@ class DpkgInstallProgress(InstallProgress): def run(self, debfile): """Start installing the given Debian package.""" - if apt_pkg._COMPAT_0_7: # Deprecated stuff - self.debfile = debfile - self.debname = os.path.basename(debfile).split("_")[0] - - pid = self.fork() - if pid == 0: - # child - res = os.system("/usr/bin/dpkg --status-fd %s -i %s" % \ - (self.writefd, debfile)) - os._exit(os.WEXITSTATUS(res)) - self.child_pid = pid - res = self.wait_child() - return res - - def update_interface(self): - """Process status messages from dpkg.""" - if self.statusfd is None: - return - while True: - try: - self.read += os.read(self.statusfd.fileno(), 1) - except OSError, (errno_, errstr): - # resource temporarly unavailable is ignored - if errno_ != 11: - print errstr - break - if not self.read.endswith("\n"): - continue - - statusl = self.read.split(":") - if len(statusl) < 3: - print "got garbage from dpkg: '%s'" % self.read - self.read = "" - break - pkg_name = statusl[1].strip() - status = statusl[2].strip() - #print status - if status == "error": - self.error(pkg_name, status) - elif status == "conffile-prompt": - # we get a string like this: - # 'current-conffile' 'new-conffile' useredited distedited - match = re.match("\s*\'(.*)\'\s*\'(.*)\'.*", statusl[3]) - if match: - self.conffile(match.group(1), match.group(2)) - else: - self.status = status - self.read = "" - - if apt_pkg._COMPAT_0_7: - updateInterface = function_deprecated_by(update_interface) + # Deprecated stuff + self.debfile = debfile + self.debname = os.path.basename(debfile).split("_")[0] + return base.InstallProgress(self, debfile) diff --git a/apt/progress/text.py b/apt/progress/text.py index eb474d6d..3a6d3e65 100644 --- a/apt/progress/text.py +++ b/apt/progress/text.py @@ -257,3 +257,5 @@ class CdromProgress(base.CdromProgress, TextProgress): return (raw_input() == '') except KeyboardInterrupt: return False + +InstallProgress = base.InstallProgress -- cgit v1.2.3