Changeset 1780 for pykota/trunk/bin
- Timestamp:
- 10/06/04 09:51:07 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/autopykota
r1759 r1780 24 24 # 25 25 # $Log$ 26 # Revision 1.3 2004/10/06 07:51:07 jalet 27 # Now autopykota uses 0.0 as the default value for initial account balance 28 # if the --initbalance command line option is not used. 29 # 26 30 # Revision 1.2 2004/09/30 11:22:30 jalet 27 31 # Extends the PATH and doesn't use absolute path anymore to launch edpykota. … … 50 54 OF AN external policy IN pykota.conf 51 55 52 THIS TOOL IS STILL EXPERIMENTAL. USE AT YOUR OWN RISK !!!53 54 56 autopykota { -i | --initbalance value } 55 57 … … 61 63 -i | --initbalance b Sets the user's account initial balance value to b. 62 64 If the user already exists, actual balance is left 63 unmodified. 65 unmodified. If unset, the default value is 0. 64 66 65 67 This program is free software; you can redistribute it and/or modify … … 91 93 user = self.storage.getUser(username) 92 94 if user.Exists : 95 self.logdebug("User %s already exits." % username) 93 96 printer = self.storage.getPrinter(printername) 94 97 if printer.Exists : … … 98 101 return 0 99 102 else : 100 self.logdebug(" User %s already exists. Creating a quota entry for user %s on printer %s." % (username,username, printername))103 self.logdebug("Creating a quota entry for user %s on printer %s." % (username, printername)) 101 104 return os.system('edpykota --add --printer "%s" "%s"' % (printername, username)) 102 105 else : 103 self.logdebug(" User %s already exists. Printer %s doesn't exist. Creating printer %s and a quota entry for user %s on printer %s." % (username,printername, printername, username, printername))106 self.logdebug("Printer %s doesn't exist. Creating printer %s and a quota entry for user %s on printer %s." % (printername, printername, username, printername)) 104 107 return os.system('edpykota --add --printer "%s" "%s"' % (printername, username)) 105 108 else : 106 if options["initbalance"] is None : 107 raise PyKotaToolError, "User %s doesn't exist yet, but no initial balance value is given. Fatal Error." % username 108 else : 109 self.logdebug("User %s doesn't exist yet. Creating user %s's account and quota entries on all existing printers." % (username, username)) 110 return os.system('edpykota --add --limitby balance --balance "%s" "%s"' % (options["initbalance"], username)) 109 self.logdebug("User %s doesn't exist yet." % username) 110 self.logdebug("Creating user %s's account with balance %.2f and quota entries on all existing printers." % (username, options["initbalance"])) 111 return os.system('edpykota --add --limitby balance --balance "%s" "%s"' % (options["initbalance"], username)) 111 112 112 113 if __name__ == "__main__" : … … 114 115 try : 115 116 defaults = { \ 117 "initbalance" : 0.0 116 118 } 117 119 short_options = "vhi:" … … 127 129 options["help"] = options["h"] or options["help"] 128 130 options["version"] = options["v"] or options["version"] 129 options["initbalance"] = options["i"] or options["initbalance"] 131 options["initbalance"] = options["i"] or options["initbalance"] or defaults["initbalance"] 130 132 131 133 if options["help"] :