67 | | if user.Exists : |
68 | | self.logdebug("User %s already exits." % username) |
69 | | if printer.Exists : |
70 | | userpquota = self.storage.getUserPQuota(user, printer) |
| 79 | if not user.Exists : |
| 80 | self.logdebug("Creating user %s which doesn't exist yet." % username) |
| 81 | os.system('pkusers --add --limitby balance --balance "%s" --description "user created from autopykota" "%s"' % (options["initbalance"], username)) |
| 82 | user = self.storage.getUserFromBackend(username) |
| 83 | if user.Exists : |
| 84 | self.logdebug("User %s created successfully." % username) |
| 85 | else : |
| 86 | self.logdebug("Impossible to create user %s." % username) |
| 87 | |
| 88 | if user.Exists and printer.Exists : |
| 89 | userpquota = self.storage.getUserPQuota(user, printer) |
| 90 | if not userpquota.Exists : |
| 91 | self.logdebug("Creating a print quota entry for user %s on printers %s" % (username, printernames)) |
| 92 | os.system('edpykota --add --printer "%s" "%s"' % (','.join(printernames), username)) |
| 93 | userpquota = self.storage.getUserPQuotaFromBackend(user, printer) |
80 | | self.logdebug("Printer %s doesn't exist. Creating printer %s and a quota entry for user %s on printer %s." % (printername, printername, username, printername)) |
81 | | return os.system('edpykota --add --printer "%s" "%s"' % (printername, username)) |
82 | | else : |
83 | | if printer.Exists : |
84 | | printersnames = [printer.Name] + [p.Name for p in self.storage.getParentPrinters(printer)] |
85 | | else : |
86 | | printersnames = [printer.Name] |
87 | | self.logdebug("User %s doesn't exist yet." % username) |
88 | | self.logdebug("Creating user %s's account with balance %s and quota entries on printers %s" % (username, options["initbalance"], printersnames)) |
89 | | return os.system('edpykota --add --limitby balance --balance "%s" --printer "%s" "%s"' % (options["initbalance"], ','.join(printersnames), username)) |
90 | | |
| 101 | self.logdebug("User %s's print quota entry on printer %s already exists. Nothing to do." % (username, printername)) |
| 102 | return 0 |
| 103 | else : |
| 104 | return -1 |
| 105 | |