summaryrefslogtreecommitdiff
path: root/doc/examples
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2005-08-05 09:23:13 +0000
committerMichael Vogt <michael.vogt@ubuntu.com>2005-08-05 09:23:13 +0000
commitde457bf476143b1f617378c7215503b777a743cc (patch)
tree71fabade43f9add41f6f1423fe39418b06c0d5bf /doc/examples
parent698f8ba826e01386be5de57bc95b44a5f22454dd (diff)
downloadpython-apt-de457bf476143b1f617378c7215503b777a743cc.tar.gz
* improved the examples, added README too
Diffstat (limited to 'doc/examples')
-rw-r--r--doc/examples/action.py9
-rw-r--r--doc/examples/inst.py9
-rw-r--r--doc/examples/progress.py4
3 files changed, 13 insertions, 9 deletions
diff --git a/doc/examples/action.py b/doc/examples/action.py
index 3eb58d9e..a794317a 100644
--- a/doc/examples/action.py
+++ b/doc/examples/action.py
@@ -4,17 +4,18 @@
import apt_pkg
import sys
import copy
-from progress import OpProgress, FetchProgress
-
+from apt.progress import OpTextProgress
+from progress import TextFetchProgress
# init
apt_pkg.init()
-progress = OpProgress()
+progress = OpTextProgress()
cache = apt_pkg.GetCache(progress)
print "Available packages: %s " % cache.PackageCount
-progress = FetchProgress()
+print "Fetching"
+progress = TextFetchProgress()
cache.Update(progress)
print "Exiting"
diff --git a/doc/examples/inst.py b/doc/examples/inst.py
index 3cc4094e..b25cf542 100644
--- a/doc/examples/inst.py
+++ b/doc/examples/inst.py
@@ -5,13 +5,14 @@ import apt_pkg
import sys, os
import copy
-from apt.progress import OpProgress, FetchProgress, InstallProgress
+from progress import TextFetchProgress, TextInstallProgress
+from apt.progress import OpTextProgress
# init
apt_pkg.init()
-progress = OpProgress()
+progress = OpTextProgress()
cache = apt_pkg.GetCache(progress)
print "Available packages: %s " % cache.PackageCount
@@ -21,8 +22,8 @@ depcache.ReadPinFile()
depcache.Init(progress)
# do something
-fprogress = FetchProgress()
-iprogress = InstallProgress()
+fprogress = TextFetchProgress()
+iprogress = TextInstallProgress()
# can be used to set a custom fork method (like vte.Terminal.forkpty)
#iprogress.fork = os.fork
diff --git a/doc/examples/progress.py b/doc/examples/progress.py
index e2ff97e2..d820fcb2 100644
--- a/doc/examples/progress.py
+++ b/doc/examples/progress.py
@@ -1,4 +1,5 @@
import apt
+from apt import SizeToStr
import sys
import time
import string
@@ -32,7 +33,8 @@ class TextFetchProgress(apt.FetchProgress):
def updateStatus(self, uri, descr, shortDescr, status):
print "UpdateStatus: '%s' '%s' '%s' '%i'" % (uri,descr,shortDescr, status)
def pulse(self):
- print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (apt_pkg.SizeToStr(self.currentCPS), apt_pkg.SizeToStr(self.currentBytes), apt_pkg.SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
+ print "Pulse: CPS: %s/s; Bytes: %s/%s; Item: %s/%s" % (SizeToStr(self.currentCPS), SizeToStr(self.currentBytes), SizeToStr(self.totalBytes), self.currentItems, self.totalItems)
+ return True
def mediaChange(self, medium, drive):
print "Please insert medium %s in drive %s" % (medium, drive)