From cce2b71c2fd64c8587238178c27a049ec450ce07 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 7 Dec 2005 10:40:14 +0000 Subject: * make pkgAcqFile use the old interface so that we don't depend on a new apt and still work with breezys apt --- doc/examples/acquire.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'doc/examples') 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) -- cgit v1.2.3