Show
Ignore:
Timestamp:
07/21/04 00:19:45 (20 years ago)
Author:
jalet
Message:

Sanitized a bit + use of gettext

Files:
1 modified

Legend:

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

    r1601 r1606  
    2222# 
    2323# $Log$ 
     24# Revision 1.114  2004/07/20 22:19:45  jalet 
     25# Sanitized a bit + use of gettext 
     26# 
    2427# Revision 1.113  2004/07/17 20:37:27  jalet 
    2528# Missing file... Am I really stupid ? 
     
    940943        signal.signal(signal.SIGTERM, self.sigterm_handler) 
    941944         
    942     def sendBackChannelData(self, message) :     
     945    def sendBackChannelData(self, message, level="info") :     
    943946        """Sends an informational message to CUPS via back channel stream (stderr).""" 
    944         self.printInfo("PyKota (PID %s) : %s" % (os.getpid(), message.strip())) 
     947        sys.stderr.write("%s: PyKota (PID %s) : %s\n" % (level.upper(), os.getpid(), message.strip())) 
     948        sys.stderr.flush() 
    945949         
    946950    def openJobDataStream(self) :     
     
    950954            # seekable and complexifies our task, so create 
    951955            # a temporary file and use it instead 
    952             self.sendBackChannelData("Duplicating data stream from stdin to temporary file") 
     956            self.logdebug("Duplicating data stream from stdin to temporary file") 
    953957            dummy = 0 
    954958            MEGABYTE = 1024*1024 
     
    961965                self.jobSizeBytes += len(data)     
    962966                if not (dummy % 10) : 
    963                     self.sendBackChannelData("%s bytes read..." % self.jobSizeBytes) 
     967                    self.logdebug("%s bytes read..." % self.jobSizeBytes) 
    964968                dummy += 1     
    965969                infile.write(data) 
    966             self.sendBackChannelData("%s bytes read total." % self.jobSizeBytes) 
     970            self.logdebug("%s bytes read total." % self.jobSizeBytes) 
    967971            infile.flush()     
    968972            infile.seek(0) 
     
    970974        else :     
    971975            # real file, just open it 
    972             self.sendBackChannelData("Opening data stream %s" % self.preserveinputfile) 
     976            self.logdebug("Opening data stream %s" % self.preserveinputfile) 
    973977            self.jobSizeBytes = os.stat(self.preserveinputfile)[6] 
    974978            return open(self.preserveinputfile, "rb") 
     
    976980    def closeJobDataStream(self) :     
    977981        """Closes the file which contains the job's datas.""" 
    978         self.sendBackChannelData("Closing data stream.") 
     982        self.logdebug("Closing data stream.") 
    979983        try : 
    980984            self.jobdatastream.close() 
     
    11001104        else :     
    11011105            # Try to detect LPRng 
    1102             # TODO : try to extract filename, job's title, and options if available 
    1103             jseen = Pseen = nseen = rseen = Kseen = None 
     1106            # TODO : try to extract filename, options if available 
     1107            jseen = Jseen = Pseen = nseen = rseen = Kseen = None 
    11041108            for arg in sys.argv : 
    11051109                if arg.startswith("-j") : 
     
    11111115                elif arg.startswith("-r") :     
    11121116                    rseen = arg[2:].strip() 
     1117                elif arg.startswith("-J") :     
     1118                    Jseen = arg[2:].strip() 
    11131119                elif arg.startswith("-K") or arg.startswith("-#") :     
    11141120                    Kseen = int(arg[2:].strip()) 
     
    11251131                inputfile = os.path.join(os.environ.get("SPOOL_DIR", "."), df_name) 
    11261132            if jseen and Pseen and nseen and rseen :         
    1127                 return ("LPRNG", rseen, Pseen, nseen, jseen, inputfile, Kseen, None, None, None) 
     1133                options = os.environ.get("HF", "") 
     1134                return ("LPRNG", rseen, Pseen, nseen, jseen, inputfile, Kseen, Jseen, options, None) 
    11281135        self.printInfo(_("Printing system unknown, args=%s") % " ".join(sys.argv), "warn") 
    11291136        return (None, None, None, None, None, None, None, None, None, None)   # Unknown printing system