summaryrefslogtreecommitdiff
path: root/apt/progress.py
blob: 70696b6ba0c4c3a27cbd1409856366e0618c8126 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Progress.py - progress reporting classes
#  
#  Copyright (c) 2005 Canonical
#  
#  Author: Michael Vogt <michael.vogt@ubuntu.com>
# 
#  This program is free software; you can redistribute it and/or 
#  modify it under the terms of the GNU General Public License as 
#  published by the Free Software Foundation; either version 2 of the
#  License, or (at your option) any later version.
# 
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
# 
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
#  USA

import sys

class OpProgress:
    """ Abstract class to implement reporting on cache opening
        Subclass this class to implement simple Operation progress reporting
    """
    def __init__(self):
        pass
    def update(self, percent):
        pass
    def done(self):
        pass

class OpTextProgress(OpProgress):
    """ A simple text based cache open reporting class """
    def __init__(self):
        OpProgress.__init__(self)
    def update(self, percent):
        sys.stdout.write("\r%s: %.2i  " % (self.subOp,percent))
        sys.stdout.flush()
    def done(self):
        sys.stdout.write("\r%s: Done\n" % self.op)



class FetchProgress:
    """ Report the download/fetching progress
        Subclass this class to implement fetch progress reporting
    """
    def __init__(self):
        pass
    
    def start(self):
        pass
    
    def stop(self):
        pass
    
    def updateStatus(self, uri, descr, shortDescr, status):
        pass

    def pulse(self):
        return True

    def mediaChange(self, medium, drive):
        pass



class InstallProgress:
    """ Report the install progress
        Subclass this class to implement install progress reporting
    """
    def __init__(self):
        pass
    def startUpdate(self):
        pass
    def finishUpdate(self):
        pass
    def updateInterface(self):
        pass


class CdromProgress:
    """ Report the cdrom add progress
        Subclass this class to implement cdrom add progress reporting
    """
    def __init__(self):
        pass
    def update(self, text, step):
        """ update is called regularly so that the gui can be redrawn """
        pass
    def askCdromName(self):
        pass
    def changeCdrom(self):
        pass

# module test code
if __name__ == "__main__":
    import apt_pkg
    apt_pkg.init()
    progress = OpTextProgress()
    cache = apt_pkg.GetCache(progress)
    depcache = apt_pkg.GetDepCache(cache)
    depcache.Init(progress)