Changeset 2961

Show
Ignore:
Timestamp:
06/27/06 23:47:26 (16 years ago)
Author:
jerome
Message:

Ensures no problem can occur during early cleanup, by moving
data initialization code upwards.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r2929 r2961  
    237237        # the environment before launching the real backend  
    238238        self.logdebug("Initializing backend...") 
     239         
     240        self.PrinterName = os.environ.get("PRINTER", "") 
     241        self.Directory = self.config.getPrinterDirectory(self.PrinterName) 
     242        self.Action = "ALLOW"   # job allowed by default 
     243        self.Reason = None 
     244        self.JobId = sys.argv[1].strip() 
     245        # use CUPS' user when printing test pages from CUPS' web interface 
     246        self.UserName = sys.argv[2].strip() or self.originalUserName or pwd.getpwuid(os.geteuid())[0] 
     247        self.Title = sys.argv[3].strip() 
     248        self.Copies = int(sys.argv[4].strip()) 
     249        self.Options = sys.argv[5].strip() 
     250        if len(sys.argv) == 7 : 
     251            self.InputFile = sys.argv[6] # read job's datas from file 
     252        else :     
     253            self.InputFile = None        # read job's datas from stdin 
     254        self.DataFile = os.path.join(self.Directory, "%s-%s-%s-%s" % \ 
     255                   (self.myname, self.PrinterName, self.UserName, self.JobId)) 
     256         
    239257        muststartwith = "%s:" % self.myname 
    240258        device_uri = os.environ.get("DEVICE_URI", "") 
     
    261279                destination = checkauth[1] 
    262280            printerhostname = destination.split("/")[0].split(":")[0] 
    263          
    264         self.Action = "ALLOW"   # job allowed by default 
    265         self.Reason = None 
    266         self.JobId = sys.argv[1].strip() 
    267         # use CUPS' user when printing test pages from CUPS' web interface 
    268         self.UserName = sys.argv[2].strip() or self.originalUserName or pwd.getpwuid(os.geteuid())[0] 
    269         self.Title = sys.argv[3].strip() 
    270         self.Copies = int(sys.argv[4].strip()) 
    271         self.Options = sys.argv[5].strip() 
    272         if len(sys.argv) == 7 : 
    273             self.InputFile = sys.argv[6] # read job's datas from file 
    274         else :     
    275             self.InputFile = None        # read job's datas from stdin 
    276281             
    277282        self.PrinterHostName = printerhostname     
    278283        self.RealBackend = backend 
    279284        self.DeviceURI = device_uri 
    280         self.PrinterName = os.environ.get("PRINTER", "") 
    281         self.Directory = self.config.getPrinterDirectory(self.PrinterName) 
    282         self.DataFile = os.path.join(self.Directory, "%s-%s-%s-%s" % \ 
    283                    (self.myname, self.PrinterName, self.UserName, self.JobId)) 
    284285         
    285286        connerror = False 
     
    497498            self.logdebug("Work file %s will be deleted." % self.DataFile) 
    498499            try : 
    499                 os.remove(self.DataFile) 
     500                if os.path.exists(self.DataFile) : 
     501                    os.remove(self.DataFile) 
    500502            except OSError, msg : 
    501503                self.logdebug("Problem while deleting work file %s : %s" % (self.DataFile, msg))