diff options
| -rw-r--r-- | debian/changelog | 2 | ||||
| -rw-r--r-- | tests/old/apt-test.py | 18 | ||||
| -rw-r--r-- | tests/old/cache.py | 32 | ||||
| -rw-r--r-- | tests/old/depcache.py | 46 | ||||
| -rw-r--r-- | tests/old/lock.py | 12 | ||||
| -rw-r--r-- | tests/old/memleak.py | 8 | ||||
| -rw-r--r-- | tests/old/pkgproblemresolver.py | 58 | ||||
| -rw-r--r-- | tests/old/pkgrecords.py | 22 | ||||
| -rw-r--r-- | tests/old/pkgsrcrecords.py | 10 | ||||
| -rwxr-xr-x | tests/old/refcount.py | 6 | ||||
| -rwxr-xr-x | tests/old/test_debextract.py | 4 | ||||
| -rw-r--r-- | tests/old/test_enhances.py | 4 |
12 files changed, 112 insertions, 110 deletions
diff --git a/debian/changelog b/debian/changelog index f9233c3a..5bbaa6e8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -30,6 +30,8 @@ python-apt (0.9.0) UNRELEASED; urgency=low - Use apt_inst.DebFile (Closes: #671784) * doc/examples/*.py: - Update examples to the new API (Closes: #639022) + * tests/old/*.py: + - Update to new API as well [ Jeremy Bicha ] * data/templates/Ubuntu.info.in: add 'devel' series (Closes: #722961) diff --git a/tests/old/apt-test.py b/tests/old/apt-test.py index fac2ff43..423fb03a 100644 --- a/tests/old/apt-test.py +++ b/tests/old/apt-test.py @@ -8,19 +8,19 @@ if __name__ == "__main__": cache = apt.Cache(progress) print cache for pkg in cache: - if pkg.isUpgradable: - pkg.markInstall() - for pkg in cache.getChanges(): - #print pkg.Name() + if pkg.is_upgradable: + pkg.mark_install() + for pkg in cache.get_changes(): + #print pkg.name() pass - print "Broken: %s " % cache._depcache.BrokenCount - print "InstCount: %s " % cache._depcache.InstCount + print "Broken: %s " % cache._depcache.broken_count + print "inst_count: %s " % cache._depcache.inst_count # get a new cache cache = apt.Cache(progress) for name in cache.keys(): import random if random.randint(0, 1) == 1: - cache[name].markDelete() - print "Broken: %s " % cache._depcache.BrokenCount - print "DelCount: %s " % cache._depcache.DelCount + cache[name].mark_delete() + print "Broken: %s " % cache._depcache.broken_count + print "del_count: %s " % cache._depcache.del_count diff --git a/tests/old/cache.py b/tests/old/cache.py index f0bf6761..11156c00 100644 --- a/tests/old/cache.py +++ b/tests/old/cache.py @@ -11,22 +11,22 @@ def main(): apt_pkg.init() cache = apt_pkg.Cache() depcache = apt_pkg.DepCache(cache) - depcache.Init() + depcache.init() i=0 - all=cache.PackageCount + all=cache.package_count print "Running Cache test on all packages:" # first, get all pkgs - for pkg in cache.Packages: + for pkg in cache.packages: i += 1 - x = pkg.Name + x = pkg.name # then get each version - for ver in pkg.VersionList: + for ver in pkg.version_list: # get some version information - a = ver.FileList - b = ver.VerStr - c = ver.Arch - d = ver.DependsListStr - dl = ver.DependsList + a = ver.file_list + b = ver.ver_str + c = ver.arch + d = ver.depends_listStr + dl = ver.depends_list # get all dependencies (a dict of string->list, # e.g. "depends:" -> [ver1,ver2,..] for dep in dl.keys(): @@ -35,12 +35,12 @@ def main(): for z in depVerList: # get all TargetVersions of # the dependency object - for j in z.AllTargets(): - f = j.FileList - g = ver.VerStr - h = ver.Arch - k = ver.DependsListStr - j = ver.DependsList + for j in z.all_targets(): + f = j.file_list + g = ver.ver_str + h = ver.arch + k = ver.depends_listStr + j = ver.depends_list pass print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)), diff --git a/tests/old/depcache.py b/tests/old/depcache.py index 0d59648e..cc030ed0 100644 --- a/tests/old/depcache.py +++ b/tests/old/depcache.py @@ -11,42 +11,42 @@ def main(): apt_pkg.init() cache = apt_pkg.Cache() depcache = apt_pkg.DepCache(cache) - depcache.Init() + depcache.init() i=0 - all=cache.PackageCount + all=cache.package_count print "Running DepCache test on all packages" print "(trying to install each and then mark it keep again):" # first, get all pkgs - for pkg in cache.Packages: + for pkg in cache.packages: i += 1 - x = pkg.Name + x = pkg.name # then get each version - ver =depcache.GetCandidateVer(pkg) + ver =depcache.get_candidate_ver(pkg) if ver is not None: - depcache.MarkInstall(pkg) - if depcache.InstCount == 0: - if depcache.IsUpgradable(pkg): + depcache.mark_install(pkg) + if depcache.inst_count == 0: + if depcache.is_upgradable(pkg): print "Error marking %s for install" % x - for p in cache.Packages: - if depcache.MarkedInstall(p): - depcache.MarkKeep(p) - if depcache.InstCount != 0: - print "Error undoing the selection for %s (InstCount: %s)" % ( - x, depcache.InstCount) + for p in cache.packages: + if depcache.marked_install(p): + depcache.mark_keep(p) + if depcache.inst_count != 0: + print "Error undoing the selection for %s (inst_count: %s)" % ( + x, depcache.inst_count) print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)), print - print "Trying Upgrade:" - depcache.Upgrade() - print "To install: %s " % depcache.InstCount - print "To remove: %s " % depcache.DelCount - print "Kept back: %s " % depcache.KeepCount + print "Trying upgrade:" + depcache.upgrade() + print "To install: %s " % depcache.inst_count + print "To remove: %s " % depcache.del_count + print "Kept back: %s " % depcache.keep_count print "Trying DistUpgrade:" - depcache.Upgrade(True) - print "To install: %s " % depcache.InstCount - print "To remove: %s " % depcache.DelCount - print "Kept back: %s " % depcache.KeepCount + depcache.upgrade(True) + print "To install: %s " % depcache.inst_count + print "To remove: %s " % depcache.del_count + print "Kept back: %s " % depcache.keep_count if __name__ == "__main__": diff --git a/tests/old/lock.py b/tests/old/lock.py index f19d3e43..71812918 100644 --- a/tests/old/lock.py +++ b/tests/old/lock.py @@ -14,27 +14,27 @@ if __name__ == "__main__": apt_pkg.init() # system-lock - apt_pkg.PkgSystemLock() + apt_pkg.pkgsystem_lock() pid = os.fork() if pid == 0: try: - apt_pkg.PkgSystemLock() + apt_pkg.pkgsystem_lock() except SystemError as s: print "Can't get lock: (error text:\n%s)" % s sys.exit(0) - apt_pkg.PkgSystemUnLock() + apt_pkg.pkgsystem_unlock() # low-level lock - fd = apt_pkg.GetLock(lock, True) + fd = apt_pkg.get_lock(lock, True) print "Lockfile fd: %s" % fd # try to get lock without error flag pid = os.fork() if pid == 0: # child - fd = apt_pkg.GetLock(lock, False) + fd = apt_pkg.get_lock(lock, False) print "Lockfile fd (child): %s" % fd sys.exit(0) @@ -42,6 +42,6 @@ if __name__ == "__main__": pid = os.fork() if pid == 0: # child - fd = apt_pkg.GetLock(lock, True) + fd = apt_pkg.get_lock(lock, True) print "Lockfile fd (child): %s" % fd sys.exit(0) diff --git a/tests/old/memleak.py b/tests/old/memleak.py index 5299f35f..1b7ec5d8 100644 --- a/tests/old/memleak.py +++ b/tests/old/memleak.py @@ -33,11 +33,11 @@ for i in range(100): depcache = apt_pkg.DepCache(cache) records = apt_pkg.PackageRecords(cache) list = apt_pkg.SourceList() - list.ReadMainList() + list.read_main_list() dict = {} - for pkg in cache.Packages: - if len(pkg.VersionList) > 0: - dict[pkg.Name] = apt.Package(cache, depcache, + for pkg in cache.packages: + if len(pkg.version_list) > 0: + dict[pkg.name] = apt.package(cache, depcache, records, list, None, pkg) print cache["apt"] diff --git a/tests/old/pkgproblemresolver.py b/tests/old/pkgproblemresolver.py index 0d6d0611..7714c882 100644 --- a/tests/old/pkgproblemresolver.py +++ b/tests/old/pkgproblemresolver.py @@ -11,58 +11,58 @@ def main(): apt_pkg.init() cache = apt_pkg.Cache() depcache = apt_pkg.DepCache(cache) - depcache.Init() + depcache.init() i=0 - all=cache.PackageCount + all=cache.package_count print "Running DepCache test on all packages" print "(trying to install each and then mark it keep again):" # first, get all pkgs - for pkg in cache.Packages: + for pkg in cache.packages: i += 1 - x = pkg.Name + x = pkg.name # then get each version - ver =depcache.GetCandidateVer(pkg) + ver =depcache.get_candidate_ver(pkg) if ver is not None: - depcache.MarkInstall(pkg) - if depcache.BrokenCount > 0: + depcache.mark_install(pkg) + if depcache.broken_count > 0: fixer = apt_pkg.ProblemResolver(depcache) - fixer.Clear(pkg) - fixer.Protect(pkg) + fixer.clear(pkg) + fixer.protect(pkg) # we first try to resolve the problem # with the package that should be installed # protected try: - fixer.Resolve(True) + fixer.resolve(True) except SystemError: # the pkg seems to be broken, the # returns a exception - fixer.Clear(pkg) - fixer.Resolve(True) - if not depcache.MarkedInstall(pkg): - print "broken in archive: %s " % pkg.Name + fixer.clear(pkg) + fixer.resolve(True) + if not depcache.marked_install(pkg): + print "broken in archive: %s " % pkg.name fixer = None - if depcache.InstCount == 0: - if depcache.IsUpgradable(pkg): + if depcache.inst_count == 0: + if depcache.is_upgradable(pkg): print "Error marking %s for install" % x - for p in cache.Packages: - if depcache.MarkedInstall(p) or depcache.MarkedUpgrade(p): - depcache.MarkKeep(p) - if depcache.InstCount != 0: + for p in cache.packages: + if depcache.marked_install(p) or depcache.marked_upgrade(p): + depcache.mark_keep(p) + if depcache.inst_count != 0: print "Error undoing the selection for %s" % x print "\r%i/%i=%.3f%% " % (i, all, (float(i) / float(all) * 100)), print - print "Trying Upgrade:" - depcache.Upgrade() - print "To install: %s " % depcache.InstCount - print "To remove: %s " % depcache.DelCount - print "Kept back: %s " % depcache.KeepCount + print "Trying upgrade:" + depcache.upgrade() + print "To install: %s " % depcache.inst_count + print "To remove: %s " % depcache.del_count + print "Kept back: %s " % depcache.keep_count print "Trying DistUpgrade:" - depcache.Upgrade(True) - print "To install: %s " % depcache.InstCount - print "To remove: %s " % depcache.DelCount - print "Kept back: %s " % depcache.KeepCount + depcache.upgrade(True) + print "To install: %s " % depcache.inst_count + print "To remove: %s " % depcache.del_count + print "Kept back: %s " % depcache.keep_count if __name__ == "__main__": diff --git a/tests/old/pkgrecords.py b/tests/old/pkgrecords.py index 2fe6ad20..9e06d44c 100644 --- a/tests/old/pkgrecords.py +++ b/tests/old/pkgrecords.py @@ -12,27 +12,27 @@ def main(): apt_pkg.init() cache = apt_pkg.Cache() depcache = apt_pkg.DepCache(cache) - depcache.Init() + depcache.init() i=0 print "Running PkgRecords test on all packages:" - for pkg in cache.Packages: + for pkg in cache.packages: i += 1 records = apt_pkg.PackageRecords(cache) - if len(pkg.VersionList) == 0: + if len(pkg.version_list) == 0: #print "no available version, cruft" continue - version = depcache.GetCandidateVer(pkg) + version = depcache.get_candidate_ver(pkg) if not version: continue - file, index = version.FileList.pop(0) - if records.Lookup((file, index)): - #print records.FileName - x = records.FileName - y = records.LongDesc + file, index = version.file_list.pop(0) + if records.lookup((file, index)): + #print records.filename + x = records.filename + y = records.long_desc pass print "\r%i/%i=%.3f%% " % ( - i, cache.PackageCount, - (float(i) / float(cache.PackageCount) * 100)), + i, cache.package_count, + (float(i) / float(cache.package_count) * 100)), if __name__ == "__main__": diff --git a/tests/old/pkgsrcrecords.py b/tests/old/pkgsrcrecords.py index 2ea9dd3a..36790eff 100644 --- a/tests/old/pkgsrcrecords.py +++ b/tests/old/pkgsrcrecords.py @@ -13,15 +13,15 @@ def main(): cache = apt_pkg.Cache() i=0 print "Running PkgSrcRecords test on all packages:" - for x in cache.Packages: + for x in cache.packages: i += 1 src = apt_pkg.SourceRecords() - if src.Lookup(x.Name): - #print src.Package + if src.lookup(x.name): + #print src.package pass print "\r%i/%i=%.3f%% " % ( - i, cache.PackageCount, - (float(i) / float(cache.PackageCount) * 100)), + i, cache.package_count, + (float(i) / float(cache.package_count) * 100)), if __name__ == "__main__": diff --git a/tests/old/refcount.py b/tests/old/refcount.py index a29744ae..a80595c9 100755 --- a/tests/old/refcount.py +++ b/tests/old/refcount.py @@ -41,13 +41,13 @@ print "refcount after second cache.update(): ", sys.gettotalrefcount() # test install() c.open(apt.progress.OpProgress()) gc.collect() -print "refcount before cache['hello'].markInstall(): ", sys.gettotalrefcount() -c["hello"].markInstall() +print "refcount before cache['hello'].mark_install(): ", sys.gettotalrefcount() +c["hello"].mark_install() c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress()) gc.collect() print "refcount after: ", sys.gettotalrefcount() c.open(apt.progress.OpProgress()) -c["hello"].markDelete() +c["hello"].mark_delete() c.commit(apt.progress.FetchProgress(), apt.progress.InstallProgress()) gc.collect() print "refcount after: ", sys.gettotalrefcount() diff --git a/tests/old/test_debextract.py b/tests/old/test_debextract.py index 4ba498ae..b80d4b1e 100755 --- a/tests/old/test_debextract.py +++ b/tests/old/test_debextract.py @@ -4,9 +4,9 @@ import sys import apt_inst -def Callback(What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor): +def Callback(What, name, Link, Mode, UID, GID, size, MTime, Major, Minor): print "%s '%s','%s',%u,%u,%u,%u,%u,%u,%u" % ( - What, Name, Link, Mode, UID, GID, Size, MTime, Major, Minor) + What, name, Link, Mode, UID, GID, size, MTime, Major, Minor) def main(): diff --git a/tests/old/test_enhances.py b/tests/old/test_enhances.py index 3eced9f9..74614674 100644 --- a/tests/old/test_enhances.py +++ b/tests/old/test_enhances.py @@ -10,8 +10,8 @@ for pkg in cache: for or_list in pkg.installed.enhances: for enhances in or_list.or_dependencies: s += " %s" % enhances.name - if (cache.has_key(enhances.name) and - not cache[enhances.name].isInstalled): + if (enhances.name in cache and + not cache[enhances.name].is_installed): s += "(*missing*) " s += "," print s[:-1] |
