summaryrefslogtreecommitdiff
path: root/doc/examples/acquire.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2009-01-13 17:49:44 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2009-01-13 17:49:44 +0100
commit9e13c9a669959cac7ff4983f36eeede8039cb6eb (patch)
tree3778f55d63c20956cbb7ddee790d6ef69d26e267 /doc/examples/acquire.py
parentc906abf5f25479483041636813117c48556f389b (diff)
parent85839f4f241c99f9e4ebb0a6a8847a2d433f1160 (diff)
downloadpython-apt-9e13c9a669959cac7ff4983f36eeede8039cb6eb.tar.gz
merge from the debian branch
Diffstat (limited to 'doc/examples/acquire.py')
-rw-r--r--doc/examples/acquire.py29
1 files changed, 13 insertions, 16 deletions
diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py
index eef6c1f7..58372961 100644
--- a/doc/examples/acquire.py
+++ b/doc/examples/acquire.py
@@ -4,15 +4,15 @@ import os
import sys
import tempfile
+
def get_file(fetcher, uri, destFile):
- # get the file
- af = apt_pkg.GetPkgAcqFile(fetcher,
- uri=uri,
- descr="sample descr", destFile=destFile)
- res = fetcher.Run()
- if res != fetcher.ResultContinue:
- return False
- return True
+ # get the file
+ af = apt_pkg.GetPkgAcqFile(fetcher, uri=uri, descr="sample descr",
+ destFile=destFile)
+ res = fetcher.Run()
+ if res != fetcher.ResultContinue:
+ return False
+ return True
apt_pkg.init()
@@ -27,12 +27,12 @@ recs = apt_pkg.GetPkgRecords(cache)
list = apt_pkg.GetPkgSourceList()
list.ReadMainList()
-# show the amount fetch needed for a dist-upgrade
+# show the amount fetch needed for a dist-upgrade
depcache.Upgrade(True)
progress = apt.progress.TextFetchProgress()
fetcher = apt_pkg.GetAcquire(progress)
pm = apt_pkg.GetPackageManager(depcache)
-pm.GetArchives(fetcher,list,recs)
+pm.GetArchives(fetcher, list, recs)
print "%s (%s)" % (apt_pkg.SizeToStr(fetcher.FetchNeeded), fetcher.FetchNeeded)
actiongroup = apt_pkg.GetPkgActionGroup(depcache)
for pkg in cache.Packages:
@@ -43,7 +43,7 @@ try:
os.mkdir("/tmp/pyapt-test/partial")
except OSError:
pass
-apt_pkg.Config.Set("Dir::Cache::archives","/tmp/pyapt-test")
+apt_pkg.Config.Set("Dir::Cache::archives", "/tmp/pyapt-test")
pkg = cache["3ddesktop"]
depcache.MarkInstall(pkg)
@@ -58,7 +58,7 @@ print fetcher
get_file(fetcher, "ftp://ftp.debian.org/debian/dists/README", "/tmp/lala")
-pm.GetArchives(fetcher,list,recs)
+pm.GetArchives(fetcher, list, recs)
for item in fetcher.Items:
print item
@@ -67,7 +67,7 @@ for item in fetcher.Items:
if item.Complete == False:
print "No error, still nothing downloaded (%s)" % item.ErrorText
print
-
+
res = fetcher.Run()
print "fetcher.Run() returned: %s" % res
@@ -75,6 +75,3 @@ print "fetcher.Run() returned: %s" % res
print "now runing pm.DoInstall()"
res = pm.DoInstall(1)
print "pm.DoInstall() returned: %s"% res
-
-
-