Changeset 2308

Show
Ignore:
Timestamp:
06/10/05 22:39:13 (19 years ago)
Author:
jerome
Message:

Extended syntax for the denyduplicates directive : it now
allows any external command to be launched, which will decide
if the dupes should be allowed or not.

Location:
pykota/trunk
Files:
19 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2303 r2308  
    239239            self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 
    240240             
     241            denyduplicates = self.config.getDenyDuplicates(printer.Name) 
    241242            if not self.jobSizeBytes : 
    242243                # if no data to pass to real backend, probably a filter 
     
    245246                self.printMoreInfo(user, printer, _("Job contains no data. Printing is denied."), "warn") 
    246247                action = "DENY" 
    247             elif self.config.getDenyDuplicates(printer.Name) \ 
     248            elif denyduplicates \ 
    248249                 and printer.LastJob.Exists \ 
    249250                 and (printer.LastJob.UserName == user.Name) \ 
    250251                 and (printer.LastJob.JobMD5Sum == self.checksum) : 
    251                 self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied."), "warn") 
    252                 action = "DENY"  
     252                if denyduplicates == 1 : 
     253                    self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied."), "warn") 
     254                    action = "DENY" 
     255                else :     
     256                    self.logdebug("Launching subprocess [%s] to see if dupes should be allowed or not." % denyduplicates) 
     257                    fanswer = os.popen(denyduplicates, "r") 
     258                    action = fanswer.read().strip().upper() 
     259                    fanswer.close() 
     260                    if action == "DENY" :      
     261                        self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is denied by subprocess."), "warn") 
     262                    else :     
     263                        self.printMoreInfo(user, printer, _("Job is a duplicate. Printing is allowed by subprocess."), "warn") 
     264                        action = "ALLOW" # just to be sure, in the case the external command returns something else... 
    253265            else :     
    254266                # checks the user's quota 
  • pykota/trunk/conf/pykota.conf.sample

    r2307 r2308  
    851851#      one just after the other. 
    852852# 
    853 # Possible values are 'yes' and 'no' 
    854 # 
     853# Possible values are 'yes', 'no', or any other string. 
     854# If the string is not recognized as a truth value, 
     855# it is considered to be a command to launch.  
     856# PyKota launches the command and parses its standard 
     857# output. The special keywords 'ALLOW' and 'DENY' are 
     858# recognized, allowing an external tool to decide if 
     859# the job is to be allowed or denied.  
     860# 
     861# denyduplicates : /usr/bin/myowncommand with some arguments 
     862# denyduplicates : yes 
    855863denyduplicates : no 
    856864 
  • pykota/trunk/NEWS

    r2307 r2308  
    2424    - 1.23alpha9 :    
    2525     
     26        - The denyduplicates directive now accepts a command line as an 
     27          argument beside yes/no. The command is launched and must 
     28          print either ALLOW or DENY to its standard output. Then the 
     29          job gets allowed or denied by PyKota. 
     30          This will allow user interaction in the near future. 
     31           
    2632        - Introduced the new 'striptitle' directive to remove ugly prefixes 
    2733          from print job's titles whenever a new print job is submitted. 
  • pykota/trunk/po/de/pykota.po

    r2303 r2308  
    23672367 
    23682368msgid "only for payments or history" 
     2369msgstr "" 
     2370 
     2371msgid "Job is a duplicate. Printing is denied by subprocess." 
     2372msgstr "" 
     2373 
     2374msgid "Job is a duplicate. Printing is allowed by subprocess." 
    23692375msgstr "" 
    23702376 
  • pykota/trunk/po/el_GR/pykota.po

    r2303 r2308  
    23372337 
    23382338msgid "only for payments or history" 
     2339msgstr "" 
     2340 
     2341msgid "Job is a duplicate. Printing is denied by subprocess." 
     2342msgstr "" 
     2343 
     2344msgid "Job is a duplicate. Printing is allowed by subprocess." 
    23392345msgstr "" 
    23402346 
  • pykota/trunk/po/es/pykota.po

    r2303 r2308  
    26912691 
    26922692msgid "only for payments or history" 
     2693msgstr "" 
     2694 
     2695msgid "Job is a duplicate. Printing is denied by subprocess." 
     2696msgstr "" 
     2697 
     2698msgid "Job is a duplicate. Printing is allowed by subprocess." 
    26932699msgstr "" 
    26942700 
  • pykota/trunk/po/fr/pykota.po

    r2303 r2308  
    28082808msgid "only for payments or history" 
    28092809msgstr "seulement pour les paiements ou l'historique" 
     2810 
     2811msgid "Job is a duplicate. Printing is denied by subprocess." 
     2812msgstr "" 
     2813"Le travail d'impression est un doublon. Impression interdite par le sous-" 
     2814"processus." 
     2815 
     2816msgid "Job is a duplicate. Printing is allowed by subprocess." 
     2817msgstr "" 
     2818"Le travail d'impression est un doublon. Impression autoris�par le sous-" 
     2819"processus." 
  • pykota/trunk/po/it/pykota.po

    r2303 r2308  
    19291929msgstr "" 
    19301930 
     1931msgid "Job is a duplicate. Printing is denied by subprocess." 
     1932msgstr "" 
     1933 
     1934msgid "Job is a duplicate. Printing is allowed by subprocess." 
     1935msgstr "" 
     1936 
    19311937#~ msgid "" 
    19321938#~ "Group           used    soft    hard    balance grace         total       " 
  • pykota/trunk/po/nb_NO/pykota.po

    r2303 r2308  
    22912291 
    22922292msgid "only for payments or history" 
     2293msgstr "" 
     2294 
     2295msgid "Job is a duplicate. Printing is denied by subprocess." 
     2296msgstr "" 
     2297 
     2298msgid "Job is a duplicate. Printing is allowed by subprocess." 
    22932299msgstr "" 
    22942300 
  • pykota/trunk/po/pt_BR/pykota.po

    r2303 r2308  
    19181918msgstr "" 
    19191919 
     1920msgid "Job is a duplicate. Printing is denied by subprocess." 
     1921msgstr "" 
     1922 
     1923msgid "Job is a duplicate. Printing is allowed by subprocess." 
     1924msgstr "" 
     1925 
    19201926#~ msgid "" 
    19211927#~ "Group           used    soft    hard    balance grace         total       " 
  • pykota/trunk/po/pt/pykota.po

    r2303 r2308  
    19261926msgstr "" 
    19271927 
     1928msgid "Job is a duplicate. Printing is denied by subprocess." 
     1929msgstr "" 
     1930 
     1931msgid "Job is a duplicate. Printing is allowed by subprocess." 
     1932msgstr "" 
     1933 
    19281934#~ msgid "" 
    19291935#~ "Group           used    soft    hard    balance grace         total       " 
  • pykota/trunk/po/pykota.pot

    r2303 r2308  
    18511851msgid "only for payments or history" 
    18521852msgstr "" 
     1853 
     1854msgid "Job is a duplicate. Printing is denied by subprocess." 
     1855msgstr "" 
     1856 
     1857msgid "Job is a duplicate. Printing is allowed by subprocess." 
     1858msgstr "" 
  • pykota/trunk/po/sv_SE/pykota.po

    r2303 r2308  
    19101910msgstr "" 
    19111911 
     1912msgid "Job is a duplicate. Printing is denied by subprocess." 
     1913msgstr "" 
     1914 
     1915msgid "Job is a duplicate. Printing is allowed by subprocess." 
     1916msgstr "" 
     1917 
    19121918#~ msgid "" 
    19131919#~ "Group           used    soft    hard    balance grace         total       " 
  • pykota/trunk/po/th/pykota.po

    r2303 r2308  
    18911891msgstr "" 
    18921892 
     1893msgid "Job is a duplicate. Printing is denied by subprocess." 
     1894msgstr "" 
     1895 
     1896msgid "Job is a duplicate. Printing is allowed by subprocess." 
     1897msgstr "" 
     1898 
    18931899#~ msgid "" 
    18941900#~ "Group           used    soft    hard    balance grace         total       " 
  • pykota/trunk/po/tr/pykota.po

    r2303 r2308  
    22542254msgstr "" 
    22552255 
     2256msgid "Job is a duplicate. Printing is denied by subprocess." 
     2257msgstr "" 
     2258 
     2259msgid "Job is a duplicate. Printing is allowed by subprocess." 
     2260msgstr "" 
     2261 
    22562262#~ msgid "" 
    22572263#~ "Internal SNMP accounting asked, but Python-SNMP is not available. Please " 
  • pykota/trunk/po/zh_TW/pykota.po

    r2303 r2308  
    18851885msgstr "" 
    18861886 
     1887msgid "Job is a duplicate. Printing is denied by subprocess." 
     1888msgstr "" 
     1889 
     1890msgid "Job is a duplicate. Printing is allowed by subprocess." 
     1891msgstr "" 
     1892 
    18871893#~ msgid "" 
    18881894#~ "Internal SNMP accounting asked, but Python-SNMP is not available. Please " 
  • pykota/trunk/pykota/config.py

    r2307 r2308  
    4949    def isTrue(self, option) :         
    5050        """Returns 1 if option is set to true, else 0.""" 
    51         if (option is not None) and (option.upper().strip() in ['Y', 'YES', '1', 'ON', 'T', 'TRUE']) : 
     51        if (option is not None) and (option.strip().upper() in ['Y', 'YES', '1', 'ON', 'T', 'TRUE']) : 
     52            return 1 
     53        else :     
     54            return 0 
     55                         
     56    def isFalse(self, option) :         
     57        """Returns 1 if option is set to false, else 0.""" 
     58        if (option is not None) and (option.strip().upper() in ['N', 'NO', '0', 'OFF', 'F', 'FALSE']) : 
    5259            return 1 
    5360        else :     
     
    394401         
    395402    def getDenyDuplicates(self, printername) :           
    396         """Returns 1 if we want to deny duplicate jobs, else 0.""" 
     403        """Returns 1 or a command if we want to deny duplicate jobs, else 0.""" 
    397404        try :  
    398             return self.isTrue(self.getPrinterOption(printername, "denyduplicates")) 
     405            denyduplicates = self.getPrinterOption(printername, "denyduplicates") 
    399406        except PyKotaConfigError :     
    400407            return 0 
     408        else :     
     409            if self.isTrue(denyduplicates) : 
     410                return 1 
     411            elif self.isFalse(denyduplicates) : 
     412                return 0 
     413            else :     
     414                # it's a command to run. 
     415                return denyduplicates 
    401416         
    402417    def getWinbindSeparator(self) :           
  • pykota/trunk/TODO

    r2307 r2308  
    2222TODO, in no particular order : 
    2323         
    24         - Allow 'external' syntax for denyduplicates : 
    25          
    26             in pykota.conf, if denyduplicates is set to : 
    27    
    28               - yes ==> then duplicates are denied silently (with a log) 
    29               - no (or unset) ==> then duplicates are allowed (without a log) 
    30               - external(some_command_here) then the command is launched 
    31                 and its output is parsed, it may contain only ALLOW or DENY. 
    32                 And it should handle the dialog with the user, if any. 
    33                  
    3424        - Add a new external hook to allow the overwriting of the job's ticket         
    3525          (mainly username and billing code) at startup time :