Changeset 3413 for pykota/trunk/bin/autopykota
- Timestamp:
- 09/27/08 22:02:37 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/autopykota
r3411 r3413 9 9 # the Free Software Foundation, either version 3 of the License, or 10 10 # (at your option) any later version. 11 # 11 # 12 12 # This program is distributed in the hope that it will be useful, 13 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 # GNU General Public License for more details. 16 # 16 # 17 17 # You should have received a copy of the GNU General Public License 18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 61 61 if printer.Exists : 62 62 self.logdebug("Printer %s created successfully." % printername) 63 else : 63 else : 64 64 self.logdebug("Impossible to create printer %s." % printername) 65 65 printernames = [printername] 66 else : 66 else : 67 67 printernames = [printer.Name] + [p.Name for p in self.storage.getParentPrinters(printer)] 68 68 69 69 user = self.storage.getUser(username) 70 70 if not user.Exists : … … 72 72 if (options.email is None) : 73 73 os.system('pkusers --add --limitby balance --balance "%s" --description "%s" "%s"' \ 74 % (options.initbalance, 74 % (options.initbalance, 75 75 _("user created with autopykota").encode(self.charset, "replace"), 76 76 username.encode(self.charset))) 77 77 else : 78 78 os.system('pkusers --add --limitby balance --balance "%s" --email "%s" --description "%s" "%s"' \ 79 % (options.initbalance, 80 options.email.encode(self.charset), 79 % (options.initbalance, 80 options.email.encode(self.charset), 81 81 _("user created with autopykota").encode(self.charset, "replace"), 82 82 username.encode(self.charset))) 83 83 84 84 user = self.storage.getUserFromBackend(username) 85 85 if user.Exists : 86 86 self.logdebug("User %s created successfully." % username) 87 else : 87 else : 88 88 self.logdebug("Impossible to create user %s." % username) 89 90 if user.Exists and printer.Exists : 89 90 if user.Exists and printer.Exists : 91 91 userpquota = self.storage.getUserPQuota(user, printer) 92 92 if not userpquota.Exists : … … 94 94 % (username, printernames)) 95 95 os.system('edpykota --add --printer "%s" "%s"' \ 96 % (','.join(printernames).encode(self.charset), 96 % (','.join(printernames).encode(self.charset), 97 97 username.encode(self.charset))) 98 userpquota = self.storage.getUserPQuotaFromBackend(user, 98 userpquota = self.storage.getUserPQuotaFromBackend(user, 99 99 printer) 100 100 if userpquota.Exists : … … 102 102 % (username, printername)) 103 103 return 0 104 else : 104 else : 105 105 self.logdebug("Impossible to create user %s's print quota entry on printer %s." \ 106 106 % (username, printername)) … … 110 110 % (username, printername)) 111 111 return 0 112 else : 112 else : 113 113 return -1 114 115 if __name__ == "__main__" : 114 115 if __name__ == "__main__" : 116 116 parser = PyKotaOptionParser(description=_("A tool to automate user account creation and initial balance setting. THIS TOOL MUST NOT BE USED FROM THE COMMAND LINE BUT ONLY AS PART OF AN external policy IN pykota.conf, AND MUST NOT BE USED IF YOU WANT TO LIMIT YOUR USERS BY PAGE QUOTA !"), 117 117 usage="autopykota { -i | --initbalance value } [options]") … … 124 124 dest="email", 125 125 help=_("Set the user's email address.")) 126 126 127 127 parser.add_example('--email="@example.com" --initbalance=10.0', 128 128 _("This would set the current user's email address to $PYKOTAUSERNAME@example.com, and would set the initial value of his account balance to 10.0 credits.")) 129 129 130 130 run(parser, AutoPyKota)