Show
Ignore:
Timestamp:
09/27/08 22:02:37 (16 years ago)
Author:
jerome
Message:

Removed unnecessary spaces at EOL.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/pykosd

    r3411 r3413  
    99# the Free Software Foundation, either version 3 of the License, or 
    1010# (at your option) any later version. 
    11 #  
     11# 
    1212# This program is distributed in the hope that it will be useful, 
    1313# but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1414# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1515# GNU General Public License for more details. 
    16 #  
     16# 
    1717# You should have received a copy of the GNU General Public License 
    1818# along with this program.  If not, see <http://www.gnu.org/licenses/>. 
     
    3131try : 
    3232    import pyosd 
    33 except ImportError :     
     33except ImportError : 
    3434    sys.stderr.write("Sorry ! You need both xosd and the Python OSD library (pyosd) for this software to work.\n") 
    3535    sys.exit(-1) 
     
    5353            if not user.Exists : 
    5454                raise PyKotaCommandLineError, _("You %(username)s don't have a PyKota printing account. Please contact your administrator.") % locals() 
    55             if user.LimitBy == "quota" :     
     55            if user.LimitBy == "quota" : 
    5656                printers = self.storage.getMatchingPrinters("*") 
    5757                upquotas = [ self.storage.getUserPQuotaFromBackend(user, p) for p in printers ] # don't use cache 
    5858                nblines = len(upquotas) 
    59                 display = pyosd.osd(font=options.font,  
    60                                     colour=color,  
    61                                     timeout=options.duration,  
    62                                     shadow=2,  
     59                display = pyosd.osd(font=options.font, 
     60                                    colour=color, 
     61                                    timeout=options.duration, 
     62                                    shadow=2, 
    6363                                    lines=nblines) 
    6464                for line in range(nblines) : 
     
    6767                        if upq.SoftLimit is None : 
    6868                            percent = "%i" % upq.PageCounter 
    69                         else :         
     69                        else : 
    7070                            percent = "%i%%" % min((upq.PageCounter * 100) / upq.SoftLimit, 100) 
    71                     else :         
     71                    else : 
    7272                        percent = "%i%%" % min((upq.PageCounter * 100) / upq.HardLimit, 100) 
    73                     printername = upq.Printer.Name     
     73                    printername = upq.Printer.Name 
    7474                    msg = _("Pages used on %(printername)s : %(percent)s") % locals() 
    75                     display.display(msg.encode(self.charset, "replace"),  
    76                                     type=pyosd.TYPE_STRING,  
     75                    display.display(msg.encode(self.charset, "replace"), 
     76                                    type=pyosd.TYPE_STRING, 
    7777                                    line=line) 
    7878            elif user.LimitBy == "balance" : 
    7979                if user.AccountBalance <= self.config.getBalanceZero() : 
    8080                    color = "#FF0000" 
    81                 display = pyosd.osd(font=options.font,  
    82                                     colour=color,  
    83                                     timeout=options.duration,  
     81                display = pyosd.osd(font=options.font, 
     82                                    colour=color, 
     83                                    timeout=options.duration, 
    8484                                    shadow=2) 
    85                 balance = user.AccountBalance                     
     85                balance = user.AccountBalance 
    8686                msg = _("PyKota Units left : %(balance).2f") % locals() 
    87                 display.display(msg.encode(self.charset, "replace"),  
     87                display.display(msg.encode(self.charset, "replace"), 
    8888                                type=pyosd.TYPE_STRING) 
    89             elif user.LimitBy == "noprint" :     
    90                 display = pyosd.osd(font=options.font,  
    91                                     colour="#FF0000",  
    92                                     timeout=options.duration,  
     89            elif user.LimitBy == "noprint" : 
     90                display = pyosd.osd(font=options.font, 
     91                                    colour="#FF0000", 
     92                                    timeout=options.duration, 
    9393                                    shadow=2) 
    9494                msg = _("Printing denied.") 
    95                 display.display(msg.encode(self.charset, "replace"),  
     95                display.display(msg.encode(self.charset, "replace"), 
    9696                                type=pyosd.TYPE_STRING) 
    97             elif user.LimitBy == "noquota" :     
    98                 display = pyosd.osd(font=options.font,  
    99                                     colour=savecolor,  
    100                                     timeout=options.duration,  
     97            elif user.LimitBy == "noquota" : 
     98                display = pyosd.osd(font=options.font, 
     99                                    colour=savecolor, 
     100                                    timeout=options.duration, 
    101101                                    shadow=2) 
    102102                msg = _("Printing not limited.") 
    103                 display.display(msg.encode(self.charset, "replace"),  
     103                display.display(msg.encode(self.charset, "replace"), 
    104104                                type=pyosd.TYPE_STRING) 
    105             elif user.LimitBy == "nochange" :     
    106                 display = pyosd.osd(font=options.font,  
    107                                     colour=savecolor,  
    108                                     timeout=options.duration,  
     105            elif user.LimitBy == "nochange" : 
     106                display = pyosd.osd(font=options.font, 
     107                                    colour=savecolor, 
     108                                    timeout=options.duration, 
    109109                                    shadow=2) 
    110110                msg = _("Printing not limited, no accounting.") 
    111                 display.display(msg.encode(self.charset, "replace"),  
     111                display.display(msg.encode(self.charset, "replace"), 
    112112                                type=pyosd.TYPE_STRING) 
    113             else :     
     113            else : 
    114114                limitby = repr(user.LimitBy) 
    115115                raise PyKotaToolError, "Incorrect limitation factor %(limitby)s for user %(username)s" % locals() 
    116                  
     116 
    117117            time.sleep(options.duration + 1) 
    118118            if loop : 
     
    120120                if not loop : 
    121121                    break 
    122             time.sleep(options.sleep)         
    123              
    124         return 0     
    125          
     122            time.sleep(options.sleep) 
     123 
     124        return 0 
     125 
    126126if __name__ == "__main__" : 
    127     def checkandset_positiveint(option, opt, value, optionparser) :     
     127    def checkandset_positiveint(option, opt, value, optionparser) : 
    128128        """Checks and sets positive integer values.""" 
    129129        if value < 0 : 
    130130            loginvalidparam(opt, value, option.default) 
    131131            setattr(optionparser.values, option.dest, option.default) 
    132         else :     
     132        else : 
    133133            setattr(optionparser.values, option.dest, value) 
    134              
    135     def checkandset_color(option, opt, value, optionparser) :     
     134 
     135    def checkandset_color(option, opt, value, optionparser) : 
    136136        """Checks and sets the color value.""" 
    137137        if not value.startswith("#") : 
    138138            value = "#%s" % value 
    139         try :     
     139        try : 
    140140            int(value[1:], 16) 
    141         except (ValueError, TypeError) :     
     141        except (ValueError, TypeError) : 
    142142            error = True 
    143         else :     
     143        else : 
    144144            error = False 
    145145        if (len(value) != 7) or error : 
    146146            loginvalidparam(opt, value, option.default) 
    147147            setattr(optionparser.values, option.dest, option.default) 
    148         else :     
     148        else : 
    149149            setattr(optionparser.values, option.dest, value) 
    150              
     150 
    151151    parser = PyKotaOptionParser(description=_("An On Screen Display (OSD) monitor for PyKota's end users.")) 
    152152    parser.add_option("-c", "--color", "--colour", 
     
    182182                            default=180, 
    183183                            help=_("Set the sleeping time in seconds between two refreshes. Defaults to %default seconds.")) 
    184                              
     184 
    185185    parser.add_example('-s 60 --loop 5', 
    186186                       _("This would tell pykosd to display the current user's status for 3 seconds (the default) every 60 seconds, and exit after 5 iterations.")) 
    187                         
     187 
    188188    run(parser, PyKOSD)