diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2005-04-11 14:19:44 +0000 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2005-04-11 14:19:44 +0000 |
| commit | a8074615c2bac880bf4fd7d5b15e621b88a20052 (patch) | |
| tree | 4e929c12c6997452335d5620b5b5208affb83698 /doc/examples | |
| parent | 1b514e848902f609cba9b2247702fc6d714d2456 (diff) | |
| download | python-apt-a8074615c2bac880bf4fd7d5b15e621b88a20052.tar.gz | |
* cdrom interface added
Diffstat (limited to 'doc/examples')
| -rw-r--r-- | doc/examples/cdrom.py | 27 | ||||
| -rw-r--r-- | doc/examples/inst.py | 2 | ||||
| -rw-r--r-- | doc/examples/progress.py | 20 |
3 files changed, 48 insertions, 1 deletions
diff --git a/doc/examples/cdrom.py b/doc/examples/cdrom.py new file mode 100644 index 00000000..e1873093 --- /dev/null +++ b/doc/examples/cdrom.py @@ -0,0 +1,27 @@ +#!/usr/bin/python +# example how to deal with the depcache + +import apt_pkg +import sys, os +import copy + +from progress import CdromProgress + + +# init +apt_pkg.init() + +cdrom = apt_pkg.GetCdrom() +print cdrom + +progress = CdromProgress() +apt_pkg.Config.Set("APT::CDROM::Rename", "True") + +cdrom.Add(progress) + +print "Exiting" +sys.exit(0) + + + + diff --git a/doc/examples/inst.py b/doc/examples/inst.py index e4c96983..6b3ade25 100644 --- a/doc/examples/inst.py +++ b/doc/examples/inst.py @@ -27,7 +27,7 @@ iprogress = InstallProgress() # can be used to set a custom fork method (like vte.Terminal.forkpty) #iprogress.fork = os.fork -iter = cache["3dchess"] +iter = cache["base-config"] print "\n%s"%iter # install or remove, the importend thing is to keep us busy :) diff --git a/doc/examples/progress.py b/doc/examples/progress.py index c37de70d..67d39c9c 100644 --- a/doc/examples/progress.py +++ b/doc/examples/progress.py @@ -1,6 +1,7 @@ import apt_pkg import sys import time +import string class OpProgress: def __init__(self): @@ -36,6 +37,7 @@ class FetchProgress: def MediaChange(self, medium, drive): print "Please insert medium %s in drive %s" % (medium, drive) sys.stdin.readline() + #return False class InstallProgress: @@ -48,3 +50,21 @@ class InstallProgress: def UpdateInterface(self): # usefull to e.g. redraw a GUI time.sleep(0.1) + + +class CdromProgress: + def __init__(self): + pass + # update is called regularly so that the gui can be redrawn + def Update(self, text, step): + # check if we actually have some text to display + if text != "": + print "Update: %s %s" % (string.strip(text), step) + def AskCdromName(self): + print "Please enter cd-name: ", + cd_name = sys.stdin.readline() + return (True, string.strip(cd_name)) + def ChangeCdrom(self): + print "Please insert cdrom and press <ENTER>" + answer = sys.stdin.readline() + return True |
