Changeset 3295 for pykota/trunk/pykota/tool.py
- Timestamp:
- 01/21/08 21:00:58 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pykota/trunk/pykota/tool.py
r3294 r3295 38 38 from mx import DateTime 39 39 40 from pykota import utils 40 41 from pykota.errors import PyKotaCommandLineError 41 42 from pykota import config, storage, logger 42 43 from pykota.version import __version__, __author__, __years__, __gplblurb__ 43 44 def N_(message) :45 """Fake translation marker for translatable strings extraction."""46 return message47 48 def crashed(message="Bug in PyKota") :49 """Minimal crash method."""50 import traceback51 lines = []52 for line in traceback.format_exception(*sys.exc_info()) :53 lines.extend([l for l in line.split("\n") if l])54 msg = "ERROR: ".join(["%s\n" % l for l in (["ERROR: PyKota v%s" % __version__, message] + lines)])55 sys.stderr.write(msg)56 sys.stderr.flush()57 return msg58 44 59 45 class Percent : … … 103 89 class Tool : 104 90 """Base class for tools with no database access.""" 105 def __init__(self, lang="", charset=None,doc="PyKota v%(__version__)s (c) %(__years__)s %(__author__)s") :91 def __init__(self, doc="PyKota v%(__version__)s (c) %(__years__)s %(__author__)s") : 106 92 """Initializes the command line tool.""" 107 93 self.debug = True # in case of early failure … … 110 96 # Saves a copy of the locale settings 111 97 (self.language, self.charset) = locale.getlocale() 98 if not self.charset : 99 self.charset = "UTF-8" 112 100 113 101 # pykota specific stuff … … 247 235 def crashed(self, message="Bug in PyKota") : 248 236 """Outputs a crash message, and optionally sends it to software author.""" 249 msg = crashed(message)237 msg = utils.crashed(message) 250 238 fullmessage = "========== Traceback :\n\n%s\n\n========== sys.argv :\n\n%s\n\n========== Environment :\n\n%s\n" % \ 251 239 (msg, \ … … 347 335 class PyKotaTool(Tool) : 348 336 """Base class for all PyKota command line tools.""" 349 def __init__(self, lang="", charset=None, doc="PyKota v%(__version__)s (c) %(__years__)s %(__author__)s") :350 """Initializes the command line tool and opens the database."""351 Tool.__init__(self, lang, charset, doc)352 353 337 def deferredInit(self) : 354 338 """Deferred initialization."""