From a8074615c2bac880bf4fd7d5b15e621b88a20052 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 11 Apr 2005 14:19:44 +0000 Subject: * cdrom interface added --- doc/examples/cdrom.py | 27 +++++++++++++++++++++++++++ doc/examples/inst.py | 2 +- doc/examples/progress.py | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 doc/examples/cdrom.py (limited to 'doc/examples') 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 " + answer = sys.stdin.readline() + return True -- cgit v1.2.3