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 Provides an extension to check remaining media capacity.
41
42 Some users have asked for advance warning that their media is beginning to fill
43 up. This is an extension that checks the current capacity of the media in the
44 writer, and prints a warning if the media is more than X% full, or has fewer
45 than X bytes of capacity remaining.
46
47 @author: Kenneth J. Pronovici <pronovic@ieee.org>
48 """
49
50
51
52
53
54
55 import logging
56
57
58 from CedarBackup2.util import displayBytes
59 from CedarBackup2.config import ByteQuantity, readByteQuantity, addByteQuantityNode
60 from CedarBackup2.xmlutil import createInputDom, addContainerNode, addStringNode
61 from CedarBackup2.xmlutil import readFirstChild, readString
62 from CedarBackup2.actions.util import createWriter, checkMediaState
63
64
65
66
67
68
69 logger = logging.getLogger("CedarBackup2.log.extend.capacity")
70
71
72
73
74
75
77
78 """
79 Class representing a percentage quantity.
80
81 The percentage is maintained internally as a string so that issues of
82 precision can be avoided. It really isn't possible to store a floating
83 point number here while being able to losslessly translate back and forth
84 between XML and object representations. (Perhaps the Python 2.4 Decimal
85 class would have been an option, but I want to stay compatible with Python
86 2.3.)
87
88 Even though the quantity is maintained as a string, the string must be in a
89 valid floating point positive number. Technically, any floating point
90 string format supported by Python is allowble. However, it does not make
91 sense to have a negative percentage in this context.
92
93 @sort: __init__, __repr__, __str__, __cmp__, quantity
94 """
95
97 """
98 Constructor for the C{PercentageQuantity} class.
99 @param quantity: Percentage quantity, as a string (i.e. "99.9" or "12")
100 @raise ValueError: If the quantity value is invaid.
101 """
102 self._quantity = None
103 self.quantity = quantity
104
106 """
107 Official string representation for class instance.
108 """
109 return "PercentageQuantity(%s)" % (self.quantity)
110
112 """
113 Informal string representation for class instance.
114 """
115 return self.__repr__()
116
118 """
119 Definition of equals operator for this class.
120 Lists within this class are "unordered" for equality comparisons.
121 @param other: Other object to compare to.
122 @return: -1/0/1 depending on whether self is C{<}, C{=} or C{&gle CedarBackup2.config.ExtensionsConfig.actions=CedarBackup2.config.ExtensionsConfig-class.html#actions">actions.util import createWriter, checkMediaState
63
64
65
66
67
68
69 logger = logging.getLogger("CedarBackup2.log.extend.capacity")
70
71
72
73
74
75
77
78 """
79 Class representing a percentage quantity.
80
81 The percentage is maintained internally as a string so that issues of
82 precision can be avoided. It really isn't possible to store a floating
83 point number here while being able to losslessly translate back and forth
84 between XML and object representations. (Perhaps the Python 2.4 Decimal
85 class would have been an option, but I want to stay compatible with Python
86 2.3.)
87
88 Even though the quantity is maintained as a string, the string must be in a
89 valid floating point positive number. Technically, any floating point
90 string format supported by Python is allowble. However, it does not make
91 sense to have a negative percentage in this context.
92
93 @sort: __init__, __repr__, __str__, __cmp__, quantity
94 """
95
97 """
98 Constructor for the C{PercentageQuantity} class.
99 @param quantity: Percentage quantity, as a string (i.e. "99.9" or "12")
100 @raise ValueError: If the quantity value is invaid.
101 """
102 self._quantity = None
103 self.quantity = quantity
104
106 """
107 Official string representation for class instance.
108 """
109 return "PercentageQuantity(%s)" % (self.quantity)
110
112 """
113 Informal string representation for class instance.
114 """
115 return self.__repr__()
116
118 """
119 Definition of equals operator for this class.
120 Lists within this class are "unordered" for equality comparisons.
121 @param other: Other object to compare to.
122 @return: -1/0/1 depending on whether self is C{<}, C{=} or C{&gle CedarBackup2.config.ExtensionsConfig.actions=CedarBackup2.config.ExtensionsConfig-class.html#actions">actions.util import createWriter, checkMediaState
63
64
65
66
67
68
69 logger = logging.getLogger("CedarBackup2.log.extend.capacity")
70
71
72
73
74
75
77
78 """
79 Class representing a percentage quantity.
80
81 The percentage is maintained internally as a string so that issues of
82 precision can be avoided. It really isn't possible to store a floating
83 point number here while being able to losslessly translate back and forth
84 between XML and object representations. (Perhaps the Python 2.4 Decimal
85 class would have been an option, but I want to stay compatible with Python
86 2.3.)
87
88 Even though the quantity is maintained as a string, the string must be in a
89 valid floating point positive number. Technically, any floating point
90 string format supported by Python is allowble. However, it does not make
91 sense to have a negative percentage in this context.
92
93 @sort: __init__, __repr__, __str__, __cmp__, quantity
94 """
95
97 """
98 Constructor for the C{PercentageQuantity} class.
99 @param quantity: Percentage quantity, as a string (i.e. "99.9" or "12")
100 @raise ValueError: If the quantity value is invaid.
101 """
102 self._quantity = None
103 self.quantity = quantity
104
106 """
107 Official string representation for class instance.
108 """
109 return "PercentageQuantity(%s)" % (self.quantity)
110
112 """
113 Informal string representation for class instance.
114 """
115 return self.__repr__()
116
118 """
119 Definition of equals operator for this class.
120 Lists within this class are "unordered" for equality comparisons.
121 @param other: Other object to compare to.
122 @return: -1/0/1 depending on whether self is C{<}, C{=} or C{&gle CedarBackup2.config.ExtensionsConfig.actions=CedarBackup2.config.ExtensionsConfig-class.html#actions">actions.util import createWriter, checkMediaState
63
64
65
66
67
68
69 logger = logging.getLogger("CedarBackup2.log.extend.capacity")
70
71
72
73
74
75
77
78 """
79 Class representing a percentage quantity.
80
81 The percentage is maintained internally as a string so that issues of
82 precision can be avoided. It really isn't possible to store a floating
83 point number here while being able to losslessly translate back and forth
84 between XML and object representations. (Perhaps the Python 2.4 Decimal
85 class would have been an option, but I want to stay compatible with Python
86 2.3.)
87
88 Even though the quantity is maintained as a string, the string must be in a
89 valid floating point positive number. Technically, any floating point
90 string format supported by Python is allowble. However, it does not make
91 sense to have a negative percentage in this context.
92
93 @sort: __init__, __repr__, __str__, __cmp__, quantity
94 """
95
97 """
98 Constructor for the C{PercentageQuantity} class.
99 @param quantity: Percentage quantity, as a string (i.e. "99.9" or "12")
100 @raise ValueError: If the quantity value is invaid.
101 """
102 self._quantity = None
103 self.quantity = quantity
104
106 """
107 Official string representation for class instance.
108 """
109 return "PercentageQuantity(%s)" % (self.quantity)
110
112 """
113 Informal string representation for class instance.
114 """
115 return self.__repr__()
116
118 """
119 Definition of equals operator for this class.
120 Lists within this class are "unordered" for equality comparisons.
121 @param other: Other object to compare to.
122 @return: -1/0/1 depending on whether self is C{<}, C{=} or C{&gle CedarBackup2.config.ExtensionsConfig.actions=CedarBackup2.config.ExtensionsConfig-class.html#actions">actions.util import createWriter, checkMediaState
63
64
65
66
67
68
69 logger = logging.getLogger("CedarBackup2.log.extend.capacity")
70
71
72
73
74
75
77
78 """
79 Class representing a percentage quantity.
80
81 The percentage is maintained internally as a string so that issues of
82 precision can be avoided. It really isn't possible to store a floating
83 point number here while being able to losslessly translate back and forth
84 between XML and object representations. (Perhaps the Python 2.4 Decimal
85 class would have been an option, but I want to stay compatible with Python
86 2.3.)
87
88 Even though the quantity is maintained as a string, the string must be in a
89 valid floating point positive number. Technically, any floating point
90 string format supported by Python is allowble. However, it does not make
91 sense to have a negative percentage in this context.
92
93 @sort: __init__, __repr__, __str__, __cmp__, quantity
94 """
95
97 """
98 Constructor for the C{PercentageQuantity} class.
99 @param quantity: Percentage quantity, as a string (i.e. "99.9" or "12")
100 @raise ValueError: If the quantity value is invaid.
101 """
102 self._quantity = None
103 self.quantity = quantity
104
106 """
107 Official string representation for class instance.
108 """
109 return "PercentageQuantity(%s)" % (self.quantity)
110
112 """
113 Informal string representation for class instance.
114 """
115 return self.__repr__()
116
118 """
119 Definition of equals operator for this class.
120 Lists within this class are "unordered" for equality comparisons.
121 @param other: Other object to compare to.
122 @return: -1/0/1 depending on whether self is C{<}, C{=} or C{&gle CedarBackup2.config.ExtensionsConfig.actions=CedarBackup2.config.ExtensionsConfig-class.html#actions">actions.util import createWriter, checkMediaState
63
64
65
66
67
68
69 logger = logging.getLogger("CedarBackup2.log.extend.capacity")
70
71
72
73
74
75
77
78 """
79 Class representing a percentage quantity.
80
81 The percentage is maintained internally as a string so that issues of
82 precision can be avoided. It really isn't possible to store a floating
83 point number here while being able to losslessly translate back and forth
84 between XML and object representations. (Perhaps the Python 2.4 Decimal
85 class would have been an option, but I want to stay compatible with Python
86 2.3.)
87
88 Even though the quantity is maintained as a string, the string must be in a
89 valid floating point positive number. Technically, any floating point
90 string format supported by Python is allowble. However, it does not make
91 sense to have a negative percentage in this context.
92
93 @sort: __init__, __repr__, __str__, __cmp__, quantity
94 """
95
97 """
98 Constructor for the C{PercentageQuantity} class.
99 @param quantity: Percentage quantity, as a string (i.e. "99.9" or "12")
100 @raise ValueError: If the quantity value is invaid.
101 """
102 self._quantity = None
103 self.quantity = quantity
104
106 """
107 Official string representation for class instance.
108 """
109 return "PercentageQuantity(%s)" % (self.quantity)
110
112 """
113 Informal string representation for class instance.
114 """
115 return self.__repr__()
116
118 """
119 Definition of equals operator for this class.
120 Lists within this class are "unordered" for equality comparisons.
121 @param other: Other object to compare to.
122 @return: -1/0/1 depending on whether self is C{<}, C{=} or C{&gle CedarBackup2.config.ExtensionsConfig.actions=CedarBackup2.config.ExtensionsConfig-class.html#actions">actions.util import createWriter, checkMediaState
63
64
65
66
67
68
69 logger = logging.getLogger("CedarBackup2.log.extend.capacity")
70
71
72
73
74
75
77
78 """
79 Class representing a percentage quantity.
80
81 The percentage is maintained internally as a string so that issues of
82 precision can be avoided. It really isn't possible to store a floating
83 point number here while being able to losslessly translate back and forth
84 between XML and object representations. (Perhaps the Python 2.4 Decimal
85 class would have been an option, but I want to stay compatible with Python
86 2.3.)
87
88 Even though the quantity is maintained as a string, the string must be in a
89 valid floating point positive number. Technically, any floating point
90 string format supported by Python is allowble. However, it does not make
91 sense to have a negative percentage in this context.
92
93 @sort: __init__, __repr__, __str__, __cmp__, quantity
94 """
95
97 """
98 Constructor for the C{PercentageQuantity} class.
99 @param quantity: Percentage quantity, as a string (i.e. "99.9" or "12")
100 @raise ValueError: If the quantity value is invaid.
101 """
102 self._quantity = None
103 self.quantity = quantity
104
106 """
107 Official string representation for class instance.
108 """
109 return "PercentageQuantity(%s)" % (self.quantity)
110
112 """
113 Informal string representation for class instance.
114 """
115 return self.