Show
Ignore:
Timestamp:
06/03/04 23:50:34 (20 years ago)
Author:
jalet
Message:

Improved error logging.
crashrecipient directive added.
Now exports the job's size in bytes too.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r1515 r1517  
    2424# 
    2525# $Log$ 
     26# Revision 1.58  2004/06/03 21:50:33  jalet 
     27# Improved error logging. 
     28# crashrecipient directive added. 
     29# Now exports the job's size in bytes too. 
     30# 
    2631# Revision 1.57  2004/06/02 22:18:07  jalet 
    2732# I think the bug when cancelling jobs should be fixed right now 
     
    330335            clienthost = self.getJobOriginatingHostname(printer.Name, user.Name, self.jobid) 
    331336            self.logdebug("Client Hostname : %s" % (clienthost or "Unknown"))     
    332             os.putenv("PYKOTAJOBORIGINATINGHOSTNAME", str(clienthost or "")) 
     337            os.environ["PYKOTAJOBORIGINATINGHOSTNAME"] = str(clienthost or "") 
    333338             
    334339            # enters first phase 
    335             os.putenv("PYKOTAPHASE", "BEFORE") 
     340            os.environ["PYKOTAPHASE"] = "BEFORE" 
    336341             
    337342            # checks the user's quota 
     
    340345                self.softwareJobPrice = userpquota.computeJobPrice(self.softwareJobSize) 
    341346                self.logdebug("Precomputed job's size is %s pages, price is %s units" % (self.softwareJobSize, self.softwareJobPrice)) 
    342             os.putenv("PYKOTAPRECOMPUTEDJOBSIZE", str(self.softwareJobSize))     
    343             os.putenv("PYKOTAPRECOMPUTEDJOBPRICE", str(self.softwareJobPrice))     
     347            os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize) 
     348            os.environ["PYKOTAPRECOMPUTEDJOBPRICE"] = str(self.softwareJobPrice) 
    344349            action = self.warnUserPQuota(userpquota) 
    345350             
    346351            # exports some new environment variables 
    347             os.putenv("PYKOTAACTION", action) 
     352            os.environ["PYKOTAACTION"] = action 
    348353             
    349354            # launches the pre hook 
     
    354359        else :     
    355360            action = "ALLOW" 
    356             os.putenv("PYKOTAACTION", action) 
     361            os.environ["PYKOTAACTION"] = action 
    357362             
    358363        # pass the job's data to the real backend     
     
    367372        if policy == "OK" :         
    368373            # indicate phase change 
    369             os.putenv("PYKOTAPHASE", "AFTER") 
     374            os.environ["PYKOTAPHASE"] = "AFTER" 
    370375             
    371376            # stops accounting.  
     
    390395             
    391396            # exports some new environment variables 
    392             os.putenv("PYKOTAJOBSIZE", str(jobsize)) 
    393             os.putenv("PYKOTAJOBPRICE", str(jobprice)) 
    394              
    395             # then re-export user information with new values 
     397            os.environ["PYKOTAJOBSIZE"] = str(jobsize) 
     398            os.environ["PYKOTAJOBPRICE"] = str(jobprice) 
     399             
     400            # then re-export user information with new value 
    396401            self.exportUserInfo(userpquota) 
    397402             
     
    660665            retcode = kotabackend.mainWork() 
    661666        except : 
    662             import traceback 
    663             lines = [] 
    664             for line in traceback.format_exception(*sys.exc_info()) : 
    665                 lines.extend([l for l in line.split("\n") if l]) 
    666             sys.stderr.write("ERROR : cupspykota backend failed : \n%s" % (msg, "ERROR : ".join(["%s\n" % l for l in lines]))) 
    667             sys.stderr.flush() 
     667            try : 
     668                kotabackend.crashed("cupspykota backend failed") 
     669            except :     
     670                pass 
    668671            retcode = 1 
    669672