Changeset 3298 for pykota/trunk/bin

Show
Ignore:
Timestamp:
01/24/08 10:12:48 (16 years ago)
Author:
jerome
Message:

It seems that the lead developer can eat his own food again...
More testing needs to be done but printing should now work again at
least with the PostgreSQL backend.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/cupspykota

    r3295 r3298  
    435435                self.Action = action 
    436436                self.Reason = (reason or _("Print job cancelled.")) 
    437                 os.environ["PYKOTASTATUS"] = "CANCELLED" 
     437                setenv("PYKOTASTATUS", "CANCELLED", self.charset) 
    438438            else : 
    439439                # don't overwrite anything unless job authorized 
     
    530530        """Exports the actual job's attributes to the environment.""" 
    531531        self.logdebug("Exporting job information to the environment...") 
    532         os.environ["DEVICE_URI"] = self.DeviceURI       # WARNING ! 
    533         os.environ["PYKOTAPRINTERNAME"] = self.PrinterName 
    534         os.environ["PYKOTADIRECTORY"] = self.Directory 
    535         os.environ["PYKOTADATAFILE"] = self.DataFile 
    536         os.environ["PYKOTAJOBSIZEBYTES"] = str(self.JobSizeBytes) 
    537         os.environ["PYKOTAMD5SUM"] = self.JobMD5Sum 
    538         os.environ["PYKOTAJOBORIGINATINGHOSTNAME"] = self.Ticket.OriginatingHostName or "" 
    539         os.environ["PYKOTAJOBID"] = self.Ticket.JobId 
    540         os.environ["PYKOTAUSERNAME"] = self.UserName 
    541         os.environ["PYKOTAORIGINALUSERNAME"] = self.Ticket.OriginalUserName 
    542         os.environ["PYKOTATITLE"] = self.Ticket.Title 
    543         os.environ["PYKOTACOPIES"] = str(self.Ticket.Copies) 
    544         os.environ["PYKOTAOPTIONS"] = self.Ticket.Options 
    545         os.environ["PYKOTAFILENAME"] = self.Ticket.FileName or "" 
    546         os.environ["PYKOTAJOBBILLING"] = self.Ticket.BillingCode or "" 
    547         os.environ["PYKOTAORIGINALJOBBILLING"] = self.OriginalJobBillingCode or "" 
    548         os.environ["PYKOTAPRINTERHOSTNAME"] = self.PrinterHostName 
    549         os.environ["PYKOTAPRECOMPUTEDJOBSIZE"] = str(self.softwareJobSize) 
     532        setenv("DEVICE_URI", self.DeviceURI, self.charset) # WARNING ! 
     533        setenv("PYKOTACHARSET", self.charset, self.charset) 
     534        setenv("PYKOTALANG", self.language, self.charset) 
     535        setenv("PYKOTAPRINTERNAME", self.PrinterName, self.charset) 
     536        setenv("PYKOTADIRECTORY", self.Directory, self.charset) 
     537        setenv("PYKOTADATAFILE", self.DataFile, self.charset) 
     538        setenv("PYKOTAJOBSIZEBYTES", str(self.JobSizeBytes), self.charset) 
     539        setenv("PYKOTAMD5SUM", self.JobMD5Sum, self.charset) 
     540        setenv("PYKOTAJOBORIGINATINGHOSTNAME", self.Ticket.OriginatingHostName or "", self.charset) 
     541        setenv("PYKOTAJOBID", self.Ticket.JobId, self.charset) 
     542        setenv("PYKOTAUSERNAME", self.UserName, self.charset) 
     543        setenv("PYKOTAORIGINALUSERNAME", self.Ticket.OriginalUserName, self.charset) 
     544        setenv("PYKOTATITLE", self.Ticket.Title, self.charset) 
     545        setenv("PYKOTACOPIES", str(self.Ticket.Copies), self.charset) 
     546        setenv("PYKOTAOPTIONS", self.Ticket.Options, self.charset) 
     547        setenv("PYKOTAFILENAME", self.Ticket.FileName or "", self.charset) 
     548        setenv("PYKOTAJOBBILLING", self.Ticket.BillingCode or "", self.charset) 
     549        setenv("PYKOTAORIGINALJOBBILLING", self.OriginalJobBillingCode or "", self.charset) 
     550        setenv("PYKOTAPRINTERHOSTNAME", self.PrinterHostName, self.charset) 
     551        setenv("PYKOTAPRECOMPUTEDJOBSIZE", str(self.softwareJobSize), self.charset) 
    550552        self.logdebug("Environment updated.") 
    551553         
     
    553555        """Exports user information to the environment.""" 
    554556        self.logdebug("Exporting user information to the environment...") 
    555         os.environ["PYKOTAOVERCHARGE"] = str(self.User.OverCharge) 
    556         os.environ["PYKOTALIMITBY"] = str(self.User.LimitBy) 
    557         os.environ["PYKOTABALANCE"] = str(self.User.AccountBalance or 0.0) 
    558         os.environ["PYKOTALIFETIMEPAID"] = str(self.User.LifeTimePaid or 0.0) 
    559         os.environ["PYKOTAUSERDESCRIPTION"] = str(self.User.Description or "") 
    560          
    561         os.environ["PYKOTAPAGECOUNTER"] = str(self.UserPQuota.PageCounter or 0) 
    562         os.environ["PYKOTALIFEPAGECOUNTER"] = str(self.UserPQuota.LifePageCounter or 0) 
    563         os.environ["PYKOTASOFTLIMIT"] = str(self.UserPQuota.SoftLimit) 
    564         os.environ["PYKOTAHARDLIMIT"] = str(self.UserPQuota.HardLimit) 
    565         os.environ["PYKOTADATELIMIT"] = str(self.UserPQuota.DateLimit) 
    566         os.environ["PYKOTAWARNCOUNT"] = str(self.UserPQuota.WarnCount) 
     557        setenv("PYKOTAOVERCHARGE", str(self.User.OverCharge), self.charset) 
     558        setenv("PYKOTALIMITBY", str(self.User.LimitBy), self.charset) 
     559        setenv("PYKOTABALANCE", str(self.User.AccountBalance or 0.0), self.charset) 
     560        setenv("PYKOTALIFETIMEPAID", str(self.User.LifeTimePaid or 0.0), self.charset) 
     561        setenv("PYKOTAUSERDESCRIPTION", str(self.User.Description or ""), self.charset) 
     562         
     563        setenv("PYKOTAPAGECOUNTER", str(self.UserPQuota.PageCounter or 0), self.charset) 
     564        setenv("PYKOTALIFEPAGECOUNTER", str(self.UserPQuota.LifePageCounter or 0), self.charset) 
     565        setenv("PYKOTASOFTLIMIT", str(self.UserPQuota.SoftLimit), self.charset) 
     566        setenv("PYKOTAHARDLIMIT", str(self.UserPQuota.HardLimit), self.charset) 
     567        setenv("PYKOTADATELIMIT", str(self.UserPQuota.DateLimit), self.charset) 
     568        setenv("PYKOTAWARNCOUNT", str(self.UserPQuota.WarnCount), self.charset) 
    567569         
    568570        # TODO : move this elsewhere once software accounting is done only once. 
    569         os.environ["PYKOTAPRECOMPUTEDJOBPRICE"] = str(self.softwareJobPrice) 
     571        setenv("PYKOTAPRECOMPUTEDJOBPRICE", str(self.softwareJobPrice), self.charset) 
    570572         
    571573        self.logdebug("Environment updated.") 
     
    576578        # exports the list of printers groups the current 
    577579        # printer is a member of 
    578         os.environ["PYKOTAPGROUPS"] = ",".join([p.Name for p in self.storage.getParentPrinters(self.Printer)]) 
    579         os.environ["PYKOTAPRINTERDESCRIPTION"] = str(self.Printer.Description or "") 
    580         os.environ["PYKOTAPRINTERMAXJOBSIZE"] = str(self.Printer.MaxJobSize or _("Unlimited")) 
    581         os.environ["PYKOTAPRINTERPASSTHROUGHMODE"] = (self.Printer.PassThrough and _("ON")) or _("OFF") 
    582         os.environ["PYKOTAPRICEPERPAGE"] = str(self.Printer.PricePerPage or 0) 
    583         os.environ["PYKOTAPRICEPERJOB"] = str(self.Printer.PricePerJob or 0) 
     580        setenv("PYKOTAPGROUPS", ",".join([p.Name for p in self.storage.getParentPrinters(self.Printer)]), self.charset) 
     581        setenv("PYKOTAPRINTERDESCRIPTION", str(self.Printer.Description or ""), self.charset) 
     582        setenv("PYKOTAPRINTERMAXJOBSIZE", str(self.Printer.MaxJobSize or _("Unlimited")), self.charset) 
     583        setenv("PYKOTAPRINTERPASSTHROUGHMODE", (self.Printer.PassThrough and _("ON")) or _("OFF"), self.charset) 
     584        setenv("PYKOTAPRICEPERPAGE", str(self.Printer.PricePerPage or 0), self.charset) 
     585        setenv("PYKOTAPRICEPERJOB", str(self.Printer.PricePerJob or 0), self.charset) 
    584586        self.logdebug("Environment updated.") 
    585587         
     
    587589        """Exports phase information to the environment.""" 
    588590        self.logdebug("Exporting phase information [%s] to the environment..." % phase) 
    589         os.environ["PYKOTAPHASE"] = phase 
     591        setenv("PYKOTAPHASE", phase, self.charset) 
    590592        self.logdebug("Environment updated.") 
    591593         
     
    593595        """Exports job's size and price information to the environment.""" 
    594596        self.logdebug("Exporting job's size and price information to the environment...") 
    595         os.environ["PYKOTAJOBSIZE"] = str(self.JobSize) 
    596         os.environ["PYKOTAJOBPRICE"] = str(self.JobPrice) 
     597        setenv("PYKOTAJOBSIZE", str(self.JobSize), self.charset) 
     598        setenv("PYKOTAJOBPRICE", str(self.JobPrice), self.charset) 
    597599        self.logdebug("Environment updated.") 
    598600         
     
    600602        """Exports the job's action status and optional reason.""" 
    601603        self.logdebug("Exporting job's action status...") 
    602         os.environ["PYKOTAACTION"] = str(self.Action) 
     604        setenv("PYKOTAACTION", str(self.Action), self.charset) 
    603605        if self.Reason : 
    604             os.environ["PYKOTAREASON"] = str(self.Reason) 
     606            setenv("PYKOTAREASON", str(self.Reason), self.charset) 
    605607        self.logdebug("Environment updated.") 
    606608         
     
    10781080                self.Action = "CANCEL" 
    10791081                self.Reason = _("Print job cancelled.") 
    1080                 os.environ["PYKOTASTATUS"] = "CANCELLED" 
     1082                setenv("PYKOTASTATUS", "CANCELLED", self.charset) 
    10811083                 
    10821084        # exports some new environment variables 
     
    12531255        originalbackend = os.path.join(os.path.split(sys.argv[0])[0], self.RealBackend) 
    12541256        if not isBanner : 
    1255             arguments = [os.environ["DEVICE_URI"]] + sys.argv[1:] 
     1257            arguments = [os.environ["DEVICE_URI"]] + [a.encode("UTF-8") for a in sys.argv[1:]] 
    12561258        else :     
    12571259            # For banners, we absolutely WANT 
    12581260            # to remove any filename from the command line ! 
    12591261            self.logdebug("It looks like we try to print a banner.") 
    1260             arguments = [os.environ["DEVICE_URI"]] + sys.argv[1:6] 
     1262            arguments = [os.environ["DEVICE_URI"]] + [a.encode("UTF-8") for a in sys.argv[1:6]] 
    12611263        arguments[2] = self.UserName # in case it was overwritten by external script 
    12621264        # TODO : do something about job-billing option, in case it was overwritten as well... 
     
    12641266        # TODO : uses the job's title to name an output file (cups-pdf:// for example), we're stuck ! 
    12651267         
    1266         self.logdebug("Starting original backend %s with args %s" % (originalbackend, " ".join(['"%s"' % a for a in arguments]))) 
     1268        self.logdebug("Starting original backend %s with args %s" % (originalbackend, " ".join(['"%s"' % a.decode("UTF-8") for a in arguments]))) 
    12671269        pid = os.fork() 
    12681270        self.logdebug("Forked !")