Changeset 2013

Show
Ignore:
Timestamp:
01/08/05 11:52:01 (20 years ago)
Author:
jalet
Message:

Now dumpykota can dump the history into CUPS' page_log format, allowing the
use of tools like PrintAnalyzer? or phpPrintAnalyzer along with PyKota

Location:
pykota/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/bin/dumpykota

    r2010 r2013  
    2424# 
    2525# $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# 
    2630# Revision 1.18  2005/01/07 12:40:53  jalet 
    2731# Fixed field type's name in XML dumps. 
     
    9296import os 
    9397import pwd 
     98from mx import DateTime 
    9499 
    95100try : 
     
    144149                         - tsv : separate datas with tabs 
    145150                         - xml : dump data as XML 
     151                         - cups : dump datas in CUPS' page_log format : 
     152                                  ONLY AVAILABLE WITH --data history 
    146153                          
    147154  -o | --output fname  All datas will be dumped to the file instead of 
     
    236243                     
    237244        format = options["format"] 
    238         if format not in [ "csv", 
     245        if (format not in [ "csv", 
    239246                           "ssv", 
    240247                           "tsv", 
    241248                           "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 
    244253             
    245254        if (format == "xml") and not hasJAXML : 
     
    285294        """Dumps datas with a comma as the separator.""" 
    286295        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)) 
    287315         
    288316    def dumpXml(self, entries, datatype) :     
  • pykota/trunk/NEWS

    r2011 r2013  
    2222PyKota NEWS : 
    2323 
     24    - 1.21alpha18 : 
     25     
     26        - Now dumpykota can dumps the job history into CUPS' page_log 
     27          format (even when the printing system is LPRng). This allows 
     28          people to use tools like PrintAnalyzer or phpPrintAnalyzer  
     29          (two completely different beasts) with PyKota. 
     30           
    2431    - 1.21alpha17 : 
    2532      
  • pykota/trunk/pykota/version.py

    r2002 r2013  
    2222# 
    2323 
    24 __version__ = "1.21alpha17_unofficial" 
     24__version__ = "1.21alpha18_unofficial" 
    2525 
    2626__doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""