Show
Ignore:
Timestamp:
03/01/04 12:23:25 (21 years ago)
Author:
jalet
Message:

Pre and Post hooks to external commands are available in the cupspykota
backend. Forthe pykota filter they will be implemented real soon now.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/tool.py

    r1365 r1372  
    2222# 
    2323# $Log$ 
     24# Revision 1.75  2004/03/01 11:23:25  jalet 
     25# Pre and Post hooks to external commands are available in the cupspykota 
     26# backend. Forthe pykota filter they will be implemented real soon now. 
     27# 
    2428# Revision 1.74  2004/02/26 14:18:07  jalet 
    2529# Should fix the remaining bugs wrt printers groups and users groups. 
     
    721725        self.preserveinputfile = self.inputfile  
    722726        self.accounter = accounter.openAccounter(self) 
     727        self.exportJobInfo() 
     728         
     729    def exportJobInfo(self) :     
     730        """Exports job information to the environment.""" 
     731        os.putenv("PYKOTAUSERNAME", self.username) 
     732        os.putenv("PYKOTAPRINTERNAME", self.printername) 
     733        os.putenv("PYKOTAJOBID", self.jobid) 
     734        os.putenv("PYKOTATITLE", self.title or "") 
     735        os.putenv("PYKOTAFILENAME", self.preserveinputfile or "") 
     736        os.putenv("PYKOTACOPIES", str(self.copies)) 
     737        os.putenv("PYKOTAOPTIONS", self.options or "") 
    723738     
     739    def exportUserInfo(self, userpquota) : 
     740        """Exports user information to the environment.""" 
     741        os.putenv("PYKOTABALANCE", str(userpquota.User.AccountBalance or 0.0)) 
     742        os.putenv("PYKOTALIFETIMEPAID", str(userpquota.User.LifeTimePaid or 0.0)) 
     743        os.putenv("PYKOTAPAGECOUNTER", str(userpquota.PageCounter or 0)) 
     744        os.putenv("PYKOTALIFEPAGECOUNTER", str(userpquota.LifePageCounter or 0)) 
     745        os.putenv("PYKOTASOFTLIMIT", str(userpquota.SoftLimit)) 
     746        os.putenv("PYKOTAHARDLIMIT", str(userpquota.HardLimit)) 
     747        os.putenv("PYKOTADATELIMIT", str(userpquota.DateLimit)) 
     748             
     749    def prehook(self, userpquota) : 
     750        """Allows pluging of an external hook before the job gets printed.""" 
     751        os.putenv("PYKOTAPHASE", "BEFORE") 
     752        prehook = self.config.getPreHook(userpquota.Printer.Name) 
     753        if prehook : 
     754            self.logdebug("Executing pre-hook [%s]" % prehook) 
     755            os.system(prehook) 
     756         
     757    def posthook(self, userpquota) : 
     758        """Allows pluging of an external hook after the job gets printed and/or denied.""" 
     759        os.putenv("PYKOTAPHASE", "AFTER") 
     760        posthook = self.config.getPostHook(userpquota.Printer.Name) 
     761        if posthook : 
     762            self.logdebug("Executing post-hook [%s]" % posthook) 
     763            os.system(posthook) 
     764         
    724765    def extractInfoFromCupsOrLprng(self) :     
    725766        """Returns a tuple (printingsystem, printerhostname, printername, username, jobid, filename, title, options, backend).