Changeset 2210 for pykota/trunk
- Timestamp:
- 04/19/05 23:36:31 (20 years ago)
- Location:
- pykota/trunk
- Files:
-
- 20 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/bin/autopykota
r2147 r2210 108 108 # Initializes the command line tool 109 109 automat = AutoPyKota(doc=__doc__) 110 automat.deferredInit() 110 111 111 112 # parse and checks the command line -
pykota/trunk/bin/cupspykota
r2177 r2210 705 705 else : 706 706 try : 707 try : 708 # Initializes the backend 709 kotabackend = PyKotaBackend() 710 except SystemExit : 711 retcode = -1 712 except : 713 crashed("cupspykota backend initialization failed") 714 retcode = 1 715 else : 716 retcode = kotabackend.mainWork() 717 kotabackend.storage.close() 718 kotabackend.closeJobDataStream() 707 # Initializes the backend 708 kotabackend = PyKotaBackend() 709 kotabackend.deferredInit() 710 retcode = kotabackend.mainWork() 711 kotabackend.storage.close() 712 kotabackend.closeJobDataStream() 713 except SystemExit : 714 retcode = -1 719 715 except : 720 716 try : -
pykota/trunk/bin/dumpykota
r2147 r2210 138 138 # Initializes the command line tool 139 139 dumper = DumPyKota(doc=__doc__) 140 dumper.deferredInit() 140 141 141 142 # parse and checks the command line -
pykota/trunk/bin/edpykota
r2147 r2210 506 506 # Initializes the command line tool 507 507 editor = EdPyKota(doc=__doc__) 508 editor.deferredInit() 508 509 509 510 # parse and checks the command line -
pykota/trunk/bin/lprngpykota
r2147 r2210 268 268 retcode = JSUCC 269 269 try : 270 try : 271 # Initializes the backend 272 kotabackend = PyKotaFilter() 273 except SystemExit : 274 retcode = JABORT 275 except : 276 crashed("lprngpykota filter initialization failed") 277 retcode = JABORT 278 else : 279 retcode = kotabackend.mainWork() 280 kotabackend.storage.close() 281 kotabackend.closeJobDataStream() 270 # Initializes the backend 271 kotabackend = PyKotaFilter() 272 kotabackend.deferredInit() 273 retcode = kotabackend.mainWork() 274 kotabackend.storage.close() 275 kotabackend.closeJobDataStream() 276 except SystemExit : 277 retcode = JABORT 282 278 except : 283 279 try : -
pykota/trunk/bin/pkbanner
r2193 r2210 303 303 # Initializes the command line tool 304 304 banner = PyKotaBanner(doc=__doc__) 305 banner.deferredInit() 305 306 306 307 # parse and checks the command line -
pykota/trunk/bin/pkhint
r2147 r2210 28 28 import os 29 29 30 from pykota.tool import PyKotaTool, PyKotaToolError, crashed, N_ 31 from pykota.config import PyKotaConfigError 32 from pykota.storage import PyKotaStorageError 30 from pykota.tool import Tool, PyKotaToolError, crashed, N_ 33 31 try : 34 32 import pysnmp … … 89 87 ] 90 88 91 class PKHint( PyKotaTool) :89 class PKHint(Tool) : 92 90 """A class to autodetect the best accounting method for printers.""" 93 91 def extractPrintersInformation(self) : … … 237 235 # Initializes the command line tool 238 236 manager = PKHint(doc=__doc__) 237 manager.deferredInit() 239 238 240 239 (options, args) = manager.parseCommandline(sys.argv[1:], short_options, long_options) … … 260 259 crashed("pkhint failed") 261 260 retcode = -1 262 263 try :264 manager.storage.close()265 except (TypeError, NameError, AttributeError) :266 pass267 261 268 262 sys.exit(retcode) -
pykota/trunk/bin/pkmail
r2147 r2210 158 158 # Initializes the command line tool 159 159 mailparser = PKMail(doc=__doc__) 160 mailparser.deferredInit() 160 161 161 162 # parse and checks the command line -
pykota/trunk/bin/pkprinters
r2147 r2210 206 206 # Initializes the command line tool 207 207 manager = PKPrinters(doc=__doc__) 208 manager.deferredInit() 208 209 209 210 # parse and checks the command line -
pykota/trunk/bin/pykosd
r2147 r2210 167 167 168 168 cmd = PyKOSD(doc=__doc__) 169 cmd.deferredInit() 169 170 170 171 # parse and checks the command line -
pykota/trunk/bin/pykotme
r2147 r2210 131 131 # Initializes the command line tool 132 132 sender = PyKotMe(doc=__doc__) 133 sender.deferredInit() 133 134 134 135 # parse and checks the command line -
pykota/trunk/bin/repykota
r2147 r2210 138 138 # Initializes the command line tool 139 139 reportTool = RePyKota(doc=__doc__) 140 reportTool.deferredInit() 140 141 141 142 # parse and checks the command line -
pykota/trunk/bin/warnpykota
r2147 r2210 153 153 # Initializes the command line tool 154 154 sender = WarnPyKota(doc=__doc__) 155 sender.deferredInit() 155 156 156 157 # parse and checks the command line -
pykota/trunk/cgi-bin/dumpykota.cgi
r2174 r2210 177 177 os.environ["LC_ALL"] = getLanguagePreference() 178 178 admin = PyKotaDumperGUI(lang=os.environ["LC_ALL"], charset=getCharsetPreference()) 179 admin.deferredInit() 179 180 admin.form = cgi.FieldStorage() 180 181 admin.options = { "output" : "-", -
pykota/trunk/cgi-bin/printquota.cgi
r2174 r2210 231 231 os.environ["LC_ALL"] = getLanguagePreference() 232 232 admin = PyKotaReportGUI(lang=os.environ["LC_ALL"], charset=getCharsetPreference()) 233 admin.deferredInit() 233 234 admin.form = cgi.FieldStorage() 234 235 admin.guiAction() -
pykota/trunk/cgi-bin/pykotme.cgi
r2174 r2210 137 137 os.environ["LC_ALL"] = getLanguagePreference() 138 138 admin = PyKotMeGUI(lang=os.environ["LC_ALL"], charset=getCharsetPreference()) 139 admin.deferredInit() 139 140 admin.form = cgi.FieldStorage() 140 141 admin.guiAction() -
pykota/trunk/NEWS
r2202 r2210 22 22 PyKota NEWS : 23 23 24 - 1.22alpha6 : 25 26 - Early errors now produce meaningful error messages (finally !) 27 24 28 - 1.22alpha5 : 25 29 -
pykota/trunk/pykota/storages/pgstorage.py
r2147 r2210 48 48 port = -1 # Use PostgreSQL's default tcp/ip port (5432). 49 49 50 try : 51 self.database = pg.connect(host=host, port=port, dbname=dbname, user=user, passwd=passwd) 52 except PGError, msg : 53 raise PyKotaStorageError, str(msg) 54 else : 55 self.closed = 0 56 self.tool.logdebug("Database opened (host=%s, port=%s, dbname=%s, user=%s)" % (host, port, dbname, user)) 50 self.database = pg.connect(host=host, port=port, dbname=dbname, user=user, passwd=passwd) 51 self.closed = 0 52 self.tool.logdebug("Database opened (host=%s, port=%s, dbname=%s, user=%s)" % (host, port, dbname, user)) 57 53 58 54 def close(self) : -
pykota/trunk/pykota/tool.py
r2195 r2210 74 74 75 75 # locale stuff 76 defaultToCLocale = 076 self.defaultToCLocale = 0 77 77 try : 78 78 locale.setlocale(locale.LC_ALL, lang) 79 79 except (locale.Error, IOError) : 80 80 locale.setlocale(locale.LC_ALL, "C") 81 defaultToCLocale = 181 self.defaultToCLocale = 1 82 82 try : 83 83 gettext.install("pykota") … … 109 109 self.documentation = doc 110 110 111 def deferredInit(self) : 112 """Deferred initialization.""" 111 113 # try to find the configuration files in user's 'pykota' home directory. 112 114 try : … … 120 122 missingUser = 0 121 123 122 try : 123 self.config = config.PyKotaConfig(confdir) 124 except ConfigParser.ParsingError, msg : 125 sys.stderr.write("ERROR: Problem encountered while parsing configuration file : %s\n" % msg) 126 sys.stderr.flush() 127 sys.exit(-1) 128 129 try : 130 self.debug = self.config.getDebug() 131 self.smtpserver = self.config.getSMTPServer() 132 self.maildomain = self.config.getMailDomain() 133 self.logger = logger.openLogger(self.config.getLoggingBackend()) 134 except (config.PyKotaConfigError, logger.PyKotaLoggingError, storage.PyKotaStorageError), msg : 135 self.crashed(msg) 136 raise 124 self.config = config.PyKotaConfig(confdir) 125 self.debug = self.config.getDebug() 126 self.smtpserver = self.config.getSMTPServer() 127 self.maildomain = self.config.getMailDomain() 128 self.logger = logger.openLogger(self.config.getLoggingBackend()) 137 129 138 130 # now drop priviledge if possible … … 143 135 self.softwareJobPrice = 0.0 144 136 145 if defaultToCLocale :137 if self.defaultToCLocale : 146 138 self.printInfo("Incorrect locale settings. PyKota falls back to the 'C' locale.", "warn") 147 139 if missingUser : … … 201 193 sys.stderr.flush() 202 194 195 def matchString(self, s, patterns) : 196 """Returns 1 if the string s matches one of the patterns, else 0.""" 197 for pattern in patterns : 198 if fnmatch.fnmatchcase(s, pattern) : 199 return 1 200 return 0 201 203 202 def display_version_and_quit(self) : 204 203 """Displays version number, then exists successfully.""" … … 302 301 """Initializes the command line tool and opens the database.""" 303 302 Tool.__init__(self, lang, charset, doc) 304 try : 305 self.storage = storage.openConnection(self) 306 except storage.PyKotaStorageError, msg : 307 self.crashed(msg) 308 raise 303 304 def deferredInit(self) : 305 """Deferred initialization.""" 306 Tool.deferredInit(self) 307 self.storage = storage.openConnection(self) 308 if self.config.isAdmin : # TODO : We don't know this before, fix this ! 309 self.logdebug("Beware : running as a PyKota administrator !") 309 310 else : 310 if self.config.isAdmin : # TODO : We don't know this before, fix this ! 311 self.logdebug("Beware : running as a PyKota administrator !") 312 else : 313 self.logdebug("Don't Panic : running as a mere mortal !") 311 self.logdebug("Don't Panic : running as a mere mortal !") 314 312 315 313 def clean(self) : … … 327 325 return 0 328 326 return 1 329 330 def matchString(self, s, patterns) :331 """Returns 1 if the string s matches one of the patterns, else 0."""332 for pattern in patterns :333 if fnmatch.fnmatchcase(s, pattern) :334 return 1335 return 0336 327 337 328 def sendMessage(self, adminmail, touser, fullmessage) : … … 655 646 self.originalbackend) = self.extractInfoFromCupsOrLprng() 656 647 648 def deferredInit(self) : 649 """Deferred initialization.""" 650 PyKotaTool.deferredInit(self) 651 657 652 arguments = " ".join(['"%s"' % arg for arg in sys.argv]) 658 653 self.logdebug(_("Printing system %s, args=%s") % (str(self.printingsystem), arguments)) -
pykota/trunk/pykota/version.py
r2202 r2210 22 22 # 23 23 24 __version__ = "1.22alpha 5_unofficial"24 __version__ = "1.22alpha6_unofficial" 25 25 26 26 __doc__ = """PyKota : a complete Printing Quota Solution for CUPS and LPRng."""