Changeset 1606 for pykota/trunk/pykota/tool.py
- Timestamp:
- 07/21/04 00:19:45 (20 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r1601 r1606 22 22 # 23 23 # $Log$ 24 # Revision 1.114 2004/07/20 22:19:45 jalet 25 # Sanitized a bit + use of gettext 26 # 24 27 # Revision 1.113 2004/07/17 20:37:27 jalet 25 28 # Missing file... Am I really stupid ? … … 940 943 signal.signal(signal.SIGTERM, self.sigterm_handler) 941 944 942 def sendBackChannelData(self, message ) :945 def sendBackChannelData(self, message, level="info") : 943 946 """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() 945 949 946 950 def openJobDataStream(self) : … … 950 954 # seekable and complexifies our task, so create 951 955 # 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") 953 957 dummy = 0 954 958 MEGABYTE = 1024*1024 … … 961 965 self.jobSizeBytes += len(data) 962 966 if not (dummy % 10) : 963 self. sendBackChannelData("%s bytes read..." % self.jobSizeBytes)967 self.logdebug("%s bytes read..." % self.jobSizeBytes) 964 968 dummy += 1 965 969 infile.write(data) 966 self. sendBackChannelData("%s bytes read total." % self.jobSizeBytes)970 self.logdebug("%s bytes read total." % self.jobSizeBytes) 967 971 infile.flush() 968 972 infile.seek(0) … … 970 974 else : 971 975 # real file, just open it 972 self. sendBackChannelData("Opening data stream %s" % self.preserveinputfile)976 self.logdebug("Opening data stream %s" % self.preserveinputfile) 973 977 self.jobSizeBytes = os.stat(self.preserveinputfile)[6] 974 978 return open(self.preserveinputfile, "rb") … … 976 980 def closeJobDataStream(self) : 977 981 """Closes the file which contains the job's datas.""" 978 self. sendBackChannelData("Closing data stream.")982 self.logdebug("Closing data stream.") 979 983 try : 980 984 self.jobdatastream.close() … … 1100 1104 else : 1101 1105 # Try to detect LPRng 1102 # TODO : try to extract filename, job's title, andoptions if available1103 jseen = Pseen = nseen = rseen = Kseen = None1106 # TODO : try to extract filename, options if available 1107 jseen = Jseen = Pseen = nseen = rseen = Kseen = None 1104 1108 for arg in sys.argv : 1105 1109 if arg.startswith("-j") : … … 1111 1115 elif arg.startswith("-r") : 1112 1116 rseen = arg[2:].strip() 1117 elif arg.startswith("-J") : 1118 Jseen = arg[2:].strip() 1113 1119 elif arg.startswith("-K") or arg.startswith("-#") : 1114 1120 Kseen = int(arg[2:].strip()) … … 1125 1131 inputfile = os.path.join(os.environ.get("SPOOL_DIR", "."), df_name) 1126 1132 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) 1128 1135 self.printInfo(_("Printing system unknown, args=%s") % " ".join(sys.argv), "warn") 1129 1136 return (None, None, None, None, None, None, None, None, None, None) # Unknown printing system