Changeset 1771 for pykota/trunk
- Timestamp:
- 10/04/04 23:25:29 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 6 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/dumpykota
r1724 r1771 24 24 # 25 25 # $Log$ 26 # Revision 1.7 2004/10/04 21:25:29 jalet 27 # dumpykota can now output datas in the XML format 28 # 26 29 # Revision 1.6 2004/09/15 18:28:41 jalet 27 30 # Updated help for dumpykota … … 51 54 import os 52 55 import pwd 56 57 try : 58 import jaxml 59 except ImportError : 60 sys.stderr.write("The jaxml Python module is not installed. XML output is disabled.\n") 61 sys.stderr.write("Download jaxml from http://www.librelogiciel.com/software/ or from your Debian archive of choice\n") 62 hasJAXML = 0 63 else : 64 hasJAXML = 1 53 65 54 66 from pykota import version … … 93 105 - ssv : separate datas with semicolons 94 106 - tsv : separate datas with tabs 107 - xml : dump data as XML 108 109 -o | --output fname All datas will be dumped to the file instead of 110 to the standard output. The special '-' filename 111 is the default value and means stdout. 112 WARNING : existing files are truncated ! 113 114 Examples : 115 116 $ dumpykota --data history --format csv >myfile.csv 117 118 This dumps the history in a comma separated values file, for possible 119 use in a spreadsheet. 120 121 $ dumpykota --data users --format xml -o users.xml 122 123 Dumps all users datas to the users.xml file. 95 124 96 125 This program is free software; you can redistribute it and/or modify … … 131 160 "ssv", 132 161 "tsv", 162 "xml", 133 163 ] : 134 164 raise PyKotaToolError, _("Invalid modifier [%s] for --format command line option, see help.") % datatype 135 165 166 if (format == "xml") and not hasJAXML : 167 raise PyKotaToolError, _("XML output is disabled because the jaxml module is not available.") 168 136 169 entries = getattr(self.storage, "extract%s" % datatype.title())() 137 if entries is not None : 138 return getattr(self, "dump%s" % format.title())(entries) 170 if entries : 171 mustclose = 0 172 if options["output"].strip() == "-" : 173 self.outfile = sys.stdout 174 else : 175 self.outfile = open(options["output"], "w") 176 mustclose = 1 177 178 retcode = getattr(self, "dump%s" % format.title())(entries, datatype) 179 180 if mustclose : 181 self.outfile.close() 182 183 return retcode 139 184 return 0 140 185 … … 144 189 line = separator.join([ '"%s"' % field for field in entry ]) 145 190 try : 146 print line191 self.outfile.write("%s\n" % line) 147 192 except IOError, msg : 148 193 sys.stderr.write("%s : %s\n" % (_("PyKota data dumper failed : I/O error"), msg)) … … 150 195 return 0 151 196 152 def dumpCsv(self, entries ) :197 def dumpCsv(self, entries, dummy) : 153 198 """Dumps datas with a comma as the separator.""" 154 199 return self.dumpWithSeparator(",", entries) 155 200 156 def dumpSsv(self, entries ) :201 def dumpSsv(self, entries, dummy) : 157 202 """Dumps datas with a comma as the separator.""" 158 203 return self.dumpWithSeparator(";", entries) 159 204 160 def dumpTsv(self, entries ) :205 def dumpTsv(self, entries, dummy) : 161 206 """Dumps datas with a comma as the separator.""" 162 207 return self.dumpWithSeparator("\t", entries) 208 209 def dumpXml(self, entries, datatype) : 210 """Dumps datas as XML.""" 211 x = jaxml.XML_document(encoding="UTF-8") 212 x.pykota(version=version.__version__) 213 x.dump(storage=self.config.getStorageBackend()["storagebackend"], type=datatype) 214 headers = entries[0] 215 for entry in entries[1:] : 216 x._push() 217 x.entry() 218 for i in range(len(entry)) : 219 value = entry[i] 220 strvalue = str(value).decode(self.getCharset()).encode("UTF-8") 221 x.attribute(strvalue, type=type(value).__name__, name=headers[i]) 222 x._pop() 223 x._output(self.outfile) 163 224 164 225 if __name__ == "__main__" : … … 167 228 defaults = { \ 168 229 "format" : "csv", \ 230 "output" : "-", \ 169 231 } 170 short_options = "vhd:f: "171 long_options = ["help", "version", "data=", "format=" ]232 short_options = "vhd:f:o:" 233 long_options = ["help", "version", "data=", "format=", "output="] 172 234 173 235 # Initializes the command line tool … … 182 244 options["data"] = options["d"] or options["data"] 183 245 options["format"] = options["f"] or options["format"] or defaults["format"] 246 options["output"] = options["o"] or options["output"] or defaults["output"] 184 247 185 248 if options["help"] : -
pykota/trunk/man/dumpykota.1
r1758 r1771 1 1 .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.33. 2 .TH DUMPYKOTA "1" " September 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands"2 .TH DUMPYKOTA "1" "October 2004" "C@LL - Conseil Internet & Logiciels Libres" "User Commands" 3 3 .SH NAME 4 dumpykota \- manual page for dumpykota 1.20alpha 18_unofficial4 dumpykota \- manual page for dumpykota 1.20alpha20_unofficial 5 5 .SH DESCRIPTION 6 dumpykota v1.20alpha 18_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres6 dumpykota v1.20alpha20_unofficial (c) 2003-2004 C@LL - Conseil Internet & Logiciels Libres 7 7 .PP 8 8 Dumps PyKota database's content. … … 45 45 - ssv : separate datas with semicolons 46 46 - tsv : separate datas with tabs 47 - xml : dump data as XML 48 .TP 49 \fB\-o\fR | \fB\-\-output\fR fname 50 All datas will be dumped to the file instead of 51 to the standard output. The special '-' filename 52 is the default value and means stdout. 53 WARNING : existing files are truncated ! 54 .PP 55 Examples : 56 .IP 57 \f(CW$ dumpykota --data history --format csv >myfile.csv\fR 58 .IP 59 This dumps the history in a comma separated values file, for possible 60 use in a spreadsheet. 61 .IP 62 \f(CW$ dumpykota --data users --format xml -o users.xml\fR 63 .IP 64 Dumps all users datas to the users.xml file. 47 65 .PP 48 66 This program is free software; you can redistribute it and/or modify -
pykota/trunk/NEWS
r1769 r1771 22 22 PyKota NEWS : 23 23 24 - 1.20alpha20 : 25 26 - dumpykota can now output XML. 27 24 28 - 1.20alpha19 : 25 29 -
pykota/trunk/pykota/version.py
r1761 r1771 22 22 # 23 23 24 __version__ = "1.20alpha 19_unofficial"24 __version__ = "1.20alpha20_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng.""" -
pykota/trunk/README
r1744 r1771 210 210 - Python v2.1 or above 211 211 - eGenix' mxDateTime Python extension 212 - SNMP tools (specifically the snmpget command) if you plan to 213 request your printer's lifetime page counter via SNMP. 212 - The JAXML Python module to be able to dump datas in the XML format. 213 - The Python-SNMP module to query printers for their page counter. 214 - The Python-OSD module to use the graphical print quota reminder. 215 - SNMP tools (specifically the snmpget command) if you prefer to 216 use your own script to request query printers. 214 217 - Netatalk (specifically the pap command) if you plan to 215 218 request your printer's lifetime page counter via AppleTalk. … … 221 224 if you plan to use OpenLDAP as the Quota Storage backend. 222 225 223 On Intel i386 architecture, and for performance reasons if you224 print in PCL5 or PCL6 format, it is strongly suggested that you225 install the Python accelerator Psyco,available at :226 On Intel i386 architecture, and for performance reasons, it is 227 strongly suggested that you install the Python accelerator Psyco, 228 available at : 226 229 227 230 http://psyco.sourceforge.net -
pykota/trunk/setup.py
r1758 r1771 24 24 # 25 25 # $Log$ 26 # Revision 1.53 2004/10/04 21:25:29 jalet 27 # dumpykota can now output datas in the XML format 28 # 26 29 # Revision 1.52 2004/09/30 09:52:45 jalet 27 30 # Initial release of autopykota. Reading help or manpage is greatly … … 429 432 ("Python-OSD", "pyosd", "Python-OSD is recommended if you plan to use the X Window On Screen Display\nprint quota reminder named pykosd."), 430 433 ("Python-SNMP", "pysnmp", "Python-SNMP is recommended if you plan to use hardware\naccounting with printers which support SNMP.\nSee http://pysnmp.sf.net"), 434 ("Python-JAXML", "jaxml", "Python-JAXML is recommended if you plan to dump datas in the XML format.\nSee http://www.librelogiciel.com/software/"), 431 435 ] 432 436 commandstocheck = [("SNMP Tools", "snmpget", "SNMP Tools are needed if you want to use SNMP enabled printers."), ("Netatalk", "pap", "Netatalk is needed if you want to use AppleTalk enabled printers.")]