Changeset 2013 for pykota/trunk/bin/dumpykota
- Timestamp:
- 01/08/05 11:52:01 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/dumpykota
r2010 r2013 24 24 # 25 25 # $Log$ 26 # Revision 1.19 2005/01/08 10:52:01 jalet 27 # Now dumpykota can dump the history into CUPS' page_log format, allowing the 28 # use of tools like PrintAnalyzer or phpPrintAnalyzer along with PyKota 29 # 26 30 # Revision 1.18 2005/01/07 12:40:53 jalet 27 31 # Fixed field type's name in XML dumps. … … 92 96 import os 93 97 import pwd 98 from mx import DateTime 94 99 95 100 try : … … 144 149 - tsv : separate datas with tabs 145 150 - xml : dump data as XML 151 - cups : dump datas in CUPS' page_log format : 152 ONLY AVAILABLE WITH --data history 146 153 147 154 -o | --output fname All datas will be dumped to the file instead of … … 236 243 237 244 format = options["format"] 238 if format not in [ "csv",245 if (format not in [ "csv", 239 246 "ssv", 240 247 "tsv", 241 248 "xml", 242 ] : 243 raise PyKotaToolError, _("Invalid modifier [%s] for --format command line option, see help.") % datatype 249 "cups", 250 ]) \ 251 or ((format == "cups") and (datatype != "history")) : 252 raise PyKotaToolError, _("Invalid modifier [%s] for --format command line option, see help.") % format 244 253 245 254 if (format == "xml") and not hasJAXML : … … 285 294 """Dumps datas with a comma as the separator.""" 286 295 return self.dumpWithSeparator("\t", entries) 296 297 def dumpCups(self, entries, dummy) : 298 """Dumps history datas as CUPS' page_log format.""" 299 fieldnames = entries[0] 300 fields = {} 301 for i in range(len(fieldnames)) : 302 fields[fieldnames[i]] = i 303 sortindex = fields["jobdate"] 304 entries = entries[1:] 305 entries.sort(lambda m,n : cmp(m[sortindex], n[sortindex])) 306 for entry in entries[1:] : 307 printername = entry[fields["printername"]] 308 username = entry[fields["username"]] 309 jobid = entry[fields["jobid"]] 310 jobdate = DateTime.ISO.ParseDateTime(entry[fields["jobdate"]]).strftime("%d/%b/%Y:%H:%M:%S %z") 311 jobsize = entry[fields["jobsize"]] 312 copies = entry[fields["copies"]] 313 hostname = entry[fields["hostname"]] 314 self.outfile.write("%s %s %s [%s] %s %s - %s\n" % (printername, username, jobid, jobdate, jobsize, copies, hostname)) 287 315 288 316 def dumpXml(self, entries, datatype) :