Show
Ignore:
Timestamp:
09/17/05 16:29:43 (19 years ago)
Author:
jerome
Message:

Upgraded database schema.
Added -i | --ingroups command line option to repykota.
Added -C | --comment command line option to edpykota.
Added 'noquota', 'noprint', and 'nochange' as switches for edpykota's
-l | --limitby command line option.
Severity : entirely new features, in need of testers :-)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/edpykota

    r2344 r2452  
    100100                        
    101101  -n | --noquota       Doesn't set a quota but only does accounting. 
     102                       This is the same as --limitby noquota. 
    102103   
    103104  -r | --reset         Resets the actual page counter for the user 
     
    112113                       by its account balance or by its page quota. 
    113114                       The default value is 'quota'. Allowed values 
    114                        are 'quota' 'balance' 'quota-then-balance' and 
    115                        'balance-then-quota'. 
    116                        WARNING : quota-then-balance and balance-then-quota 
    117                        are not yet implemented. 
     115                       are 'quota' 'balance' 'noquota' 'noprint'  
     116                       and 'nochange' : 
     117                        
     118                         - quota : limit by number of pages per printer. 
     119                         - balance : limit by number of credits in account. 
     120                         - noquota : no limit, accounting still done. 
     121                         - nochange : no limit, accounting not done.  
     122                         - noprint : printing is denied.  
     123                       NB : nochange and noprint are not supported for groups. 
    118124                        
    119125  -b | --balance b     Sets the user's account balance to b.                      
     
    125131                       Groups don't have a real balance, but the 
    126132                       sum of their users' account balance. 
     133                        
     134  -C | --comment txt   Defines some informational text to be associated 
     135                       with a change to an user's account balance. 
     136                       Only meaningful if -b | --balance is also used. 
    127137                        
    128138  -S | --softlimit sl  Sets the quota soft limit to sl pages.                        
     
    237247         
    238248        softlimit = hardlimit = None 
     249         
     250        if options["noquota"] : 
     251            options["limitby"] = "noquota" 
     252             
     253        limitby = options["limitby"] 
     254        if limitby : 
     255            limitby = limitby.strip().lower() 
     256        if limitby : 
     257            if limitby not in ('quota', 'balance', 'noquota', \ 
     258                                        'noprint', 'nochange') : 
     259                raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 
     260            if limitby in ('noquota', 'nochange') :     
     261                options["noquota"] = 1 
     262            if (limitby in ('nochange', 'noprint')) and options["groups"] :     
     263                raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 
    239264 
    240265        used = options["used"] 
     
    288313                    charges = [charges[0], None] 
    289314                     
    290         limitby = options["limitby"] 
    291         if limitby : 
    292             limitby = limitby.strip().lower() 
    293         if limitby and (limitby not in ('quota', 'balance', 'quota-then-balance', 'balance-then-quota')) :     
    294             raise PyKotaToolError, _("Invalid limitby value %s") % options["limitby"] 
    295              
    296315        if options["ingroups"] :     
    297316            groupnames = [gname.strip() for gname in options["ingroups"].split(',')] 
     
    474493                                    newbalance = float(entry.AccountBalance or 0.0) + balancevalue 
    475494                                    newlifetimepaid = float(entry.LifeTimePaid or 0.0) + balancevalue 
    476                                     entry.setAccountBalance(newbalance, newlifetimepaid) 
     495                                    entry.setAccountBalance(newbalance, newlifetimepaid, options["comment"]) 
    477496                                else : 
    478497                                    diff = balancevalue - float(entry.AccountBalance or 0.0) 
    479498                                    newlifetimepaid = float(entry.LifeTimePaid or 0.0) + diff 
    480                                     entry.setAccountBalance(balancevalue, newlifetimepaid) 
     499                                    entry.setAccountBalance(balancevalue, newlifetimepaid, options["comment"]) 
    481500                                changed[entry.Name]["balance"] = balance 
    482501                                 
     
    506525        defaults = { \ 
    507526                     "printer" : "*", \ 
     527                     "comment" : "", \ 
    508528                   } 
    509         short_options = "vhdo:c:l:b:i:naugrp:P:S:H:G:RU:" 
    510         long_options = ["help", "version", "overcharge=", "charge=", "delete", "limitby=", "balance=", "ingroups=", "noquota", "add", "users", "groups", "reset", "hardreset", "prototype=", "printer=", "softlimit=", "hardlimit=", "pgroups=", "used="] 
     529        short_options = "vhdo:c:C:l:b:i:naugrp:P:S:H:G:RU:" 
     530        long_options = ["help", "version", "comment=", \ 
     531                        "overcharge=", "charge=", "delete", "limitby=", \ 
     532                        "balance=", "ingroups=", "noquota", "add", "users", \ 
     533                        "groups", "reset", "hardreset", "prototype=", \ 
     534                        "printer=", "softlimit=", "hardlimit=", "pgroups=", \ 
     535                        "used="] 
    511536         
    512537        # Initializes the command line tool 
     
    538563        options["used"] = options["U"] or options["used"] 
    539564        options["overcharge"] = options["o"] or options["overcharge"] 
     565        options["comment"] = options["C"] or options["comment"] or defaults["comment"] 
    540566         
    541567        if options["help"] : 
     
    553579        elif options["groups"] and (options["balance"] or options["ingroups"] or options["used"] or options["overcharge"]) : 
    554580            raise PyKotaToolError, _("incompatible options, see help.") 
     581        elif options["comment"] and not options["balance"] :     
     582            raise PyKotaToolError, _("incompatible options, see help.") 
    555583        else : 
    556584            retcode = editor.main(args, options)