Changeset 2210 for pykota/trunk/pykota/tool.py
- Timestamp:
- 04/19/05 23:36:31 (19 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
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))