Changeset 2797 for pykota/trunk
- Timestamp:
- 03/20/06 16:45:50 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/cupspykota
r2786 r2797 49 49 from pykota.storage import PyKotaStorageError 50 50 51 class FakeObject : 52 def __init__(self, name) : 53 """Fake init.""" 54 self.Name = name 55 56 class FakePrinter(FakeObject) : 57 """Fake printer instance.""" 58 pass 59 60 class FakeUser(FakeObject) : 61 """Fake user instance.""" 62 def __init__(self, name) : 63 """Fake init.""" 64 self.Email = name 65 FakeObject.__init__(self, name) 66 51 67 class CUPSBackend(PyKotaTool) : 52 68 """Base class for tools with no database access.""" … … 256 272 self.logdebug("JobOriginatingHostName : %s" % self.ClientHost) 257 273 274 # fakes some entries to allow for external mailto 275 # before real entries are extracted from the database. 276 self.User = FakeUser(self.UserName) 277 self.Printer = FakePrinter(self.PrinterName) 278 258 279 self.enableSigInt() 259 280 self.logdebug("Backend initialized.") … … 849 870 msg["Subject"] = str(Header(_("Print Quota"), charset=self.charset)) 850 871 msg["From"] = adminmail 851 msg["To"] = usermail 852 msg["Cc"] = adminmail 872 if mailto in ("BOTH", "USER") : 873 msg["To"] = usermail 874 if mailto == "BOTH" : 875 msg["Cc"] = adminmail 876 else : 877 msg["To"] = adminmail 853 878 server.sendmail(adminmail, destination, msg.as_string()) 854 879 except smtplib.SMTPException, answer : … … 864 889 # higher in the chain failed because of a misconfiguration. 865 890 # we deny the job in this case (nothing to print anyway) 866 self.printInfo(_("Job contains no data. Printing is denied."), "error") 891 self.Reason = _("Job contains no data. Printing is denied.") 892 self.printInfo(self.Reason, "error") 893 self.tellUser() 867 894 return self.removeJob() 868 895 … … 870 897 if self.Policy == "EXTERNALERROR" : 871 898 # Policy was 'EXTERNAL' and the external command returned an error code 899 self.Reason = _("Error in external policy script. Printing is denied.") 900 self.printInfo(self.Reason, "error") 901 self.tellUser() 872 902 return self.removeJob() 873 903 elif self.Policy == "EXTERNAL" : 874 904 # Policy was 'EXTERNAL' and the external command wasn't able 875 905 # to add either the printer, user or user print quota 906 self.Reason = _("Still no print quota entry for user %s on printer %s after external policy. Printing is denied.") % (self.UserName, self.PrinterName) 907 self.printInfo(self.Reason, "warn") 908 self.tellUser() 876 909 return self.removeJob() 877 910 elif self.Policy == "DENY" : 878 911 # Either printer, user or user print quota doesn't exist, 879 912 # and the job should be rejected. 913 self.Reason = _("Printing is denied by printer policy.") 914 self.printInfo(self.Reason, "warn") 915 self.tellUser() 880 916 return self.removeJob() 881 917 elif self.Policy == "ALLOW" : 882 918 # ALLOW means : Either printer, user or user print quota doesn't exist, 883 919 # but the job should be allowed anyway. 884 self.printInfo(_("Job allowed by printer policy. No accounting will be done."), "warn") 920 self.Reason = _("Job allowed by printer policy. No accounting will be done.") 921 self.printInfo(self.Reason, "warn") 922 self.tellUser() 885 923 return self.printJobDatas() 886 924 elif self.Policy == "OK" : … … 889 927 return self.doWork() 890 928 else : 891 self.printInfo(_("Invalid policy %s for printer %s") % (self.Policy, self.PrinterName), "error") 929 self.Reason = _("Invalid policy %s for printer %s") % (self.Policy, self.PrinterName) 930 self.printInfo(self.Reason, "error") 931 self.tellUser() 892 932 return self.removeJob() 893 933