diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-12-07 10:40:14 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-12-07 10:40:14 +0000 |
| commit | cce2b71c2fd64c8587238178c27a049ec450ce07 (patch) | |
| tree | 04e79ceab8ae37df0fea94b895ed7df7ec745bbf /doc/examples | |
| parent | b4141dda949890eaa50f0097b6fc6baeb3c489ac (diff) | |
| download | python-apt-cce2b71c2fd64c8587238178c27a049ec450ce07.tar.gz | |
* make pkgAcqFile use the old interface so that we don't depend on a new apt and still work with breezys apt
Diffstat (limited to 'doc/examples')
| -rw-r--r-- | doc/examples/acquire.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/doc/examples/acquire.py b/doc/examples/acquire.py index 516a3d6d..a0790c98 100644 --- a/doc/examples/acquire.py +++ b/doc/examples/acquire.py @@ -2,6 +2,28 @@ import apt import apt_pkg import os import sys +import tempfile + +def get_file(fetcher, uri, destFile): + cwd = os.getcwd() + # create a temp dir + dir = tempfile.mkdtemp() + os.chdir(dir) + # get the file + af = apt_pkg.GetPkgAcqFile(fetcher, + uri=uri, + descr="sample descr") + res = fetcher.Run() + if res != fetcher.ResultContinue: + os.rmdir(dir) + os.chdir(cwd) + return False + filename = os.path.basename(uri) + os.rename(dir+"/"+filename,destFile) + # cleanup + os.rmdir(dir) + os.chdir(cwd) + return True apt_pkg.init() @@ -45,11 +67,7 @@ pm = apt_pkg.GetPackageManager(depcache) print pm print fetcher -af = apt_pkg.GetPkgAcqFile(fetcher, - uri="ftp://ftp.debian.org/debian/dists/README", - descr="sample descr", - destFile="/tmp/lala2") -fetcher.Run() +get_file(fetcher, "ftp://ftp.debian.org/debian/dists/README", "/tmp/lala") sys.exit(1) pm.GetArchives(fetcher,list,recs) |
