blob: 0031fa182744dd27ab4d7b4ea644feea8ac1916a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import apt
import apt_pkg
import os
apt_pkg.init()
cache = apt_pkg.GetCache()
depcache = apt_pkg.GetDepCache(cache)
recs = apt_pkg.GetPkgRecords(cache)
list = apt_pkg.GetPkgSourceList()
list.ReadMainList()
try:
os.mkdir("/tmp/pyapt-test")
os.mkdir("/tmp/pyapt-test/partial")
except OSError:
pass
#apt_pkg.Config.Set("Dir::Cache::archives","/tmp/pyapt-test")
pkg = cache["3ddesktop"]
depcache.MarkInstall(pkg)
progress = apt.progress.TextFetchProgress()
fetcher = apt_pkg.GetAcquire(progress)
#fetcher = apt_pkg.GetAcquire()
pm = apt_pkg.GetPackageManager(depcache)
print pm
print fetcher
pm.GetArchives(fetcher,list,recs)
for item in fetcher.Items:
print "%s -> %s:\n Status: %s Complete: %s IsTrusted: %s" % (item.DescURI,
item.DestFile,
item.Status,
item.Complete,
item.IsTrusted)
if item.Status == item.StatError:
print "Some error ocured: '%s'" % item.ErrorText
if item.Complete == False:
print "No error, still nothing downloaded"
print
res = fetcher.Run()
print "fetcher.Run() returned: %s" % res
|