Changeset 1608
- Timestamp:
- 07/21/04 00:42:26 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/pykosd
r1607 r1608 24 24 # 25 25 # $Log$ 26 # Revision 1.7 2004/07/20 22:42:26 jalet 27 # pykosd now supports setting color 28 # 26 29 # Revision 1.6 2004/07/20 22:29:49 jalet 27 30 # pykosd now supports setting the font … … 71 74 -h | --help Prints this message then exits. 72 75 76 -c | --color #rrggbb Sets the color to use for display as an hexadecimal 77 triplet, for example #FF0000 is 100%% red. 78 Defaults to 100%% green (#00FF00). 79 73 80 -d | --duration d Sets the duration of the display in seconds. 74 81 Defaults to 3 seconds. … … 127 134 raise PyKotaToolError, _("Invalid sleep option %s") % str(options["sleep"]) 128 135 136 color = options["color"] 137 if not color.startswith("#") : 138 color = "#%s" % color 139 if len(color) != 7 : 140 raise PyKotaToolError, _("Invalid color option %s") % str(color) 141 savecolor = color 142 129 143 uid = os.geteuid() 130 144 uname = pwd.getpwuid(uid)[0] 131 145 while 1 : 146 color = savecolor 132 147 user = cmd.storage.getUserFromBackend(uname) # don't use cache 133 148 if not user.Exists : … … 137 152 upquotas = [ cmd.storage.getUserPQuotaFromBackend(user, p) for p in printers ] # don't use cache 138 153 nblines = len(upquotas) 139 display = pyosd.osd(font=options["font"], colour= "#00FF00", timeout=duration, shadow=2, lines=nblines)154 display = pyosd.osd(font=options["font"], colour=color, timeout=duration, shadow=2, lines=nblines) 140 155 for line in range(nblines) : 141 156 upq = upquotas[line] … … 151 166 if user.AccountBalance <= 0 : 152 167 color = "#FF0000" 153 else :154 color = "#00FF00"155 168 display = pyosd.osd(font=options["font"], colour=color, timeout=duration, shadow=2) 156 169 display.display(_("PyKota Units left : %.2f") % user.AccountBalance, type=pyosd.TYPE_STRING) 170 157 171 time.sleep(duration + 1) 158 172 if loop : … … 168 182 try : 169 183 defaults = { \ 184 "color" : "#00FF00", \ 170 185 "duration" : "3", \ 171 186 "font" : pyosd.default_font, \ … … 173 188 "sleep" : "180", \ 174 189 } 175 short_options = "hv d:f:l:s:"176 long_options = ["help", "version", " duration=", "font=", "loop=", "sleep="]190 short_options = "hvc:d:f:l:s:" 191 long_options = ["help", "version", "color=", "colour=", "duration=", "font=", "loop=", "sleep="] 177 192 178 193 cmd = PyKOSD(doc=__doc__) … … 184 199 options["help"] = options["h"] or options["help"] 185 200 options["version"] = options["v"] or options["version"] 201 options["color"] = options["c"] or options["color"] or options["colour"] or defaults["color"] 186 202 options["duration"] = options["d"] or options["duration"] or defaults["duration"] 187 203 options["font"] = options["f"] or options["font"] or defaults["font"]