[Pymoul-svn] SF.net SVN: pymoul: [150] pymoul/trunk
Status: Alpha
Brought to you by:
tiran
|
From: <ti...@us...> - 2007-02-06 17:51:40
|
Revision: 150
http://pymoul.svn.sourceforge.net/pymoul/?rev=150&view=rev
Author: tiran
Date: 2007-02-06 09:51:25 -0800 (Tue, 06 Feb 2007)
Log Message:
-----------
Added run.bat to run the program under windows w/o build the py2exe version first
Fixed error handler
Fixed translation installer
Modified Paths:
--------------
pymoul/trunk/src/moul/qt/errorhandler.py
pymoul/trunk/src/moul/qt/i18n/__init__.py
pymoul/trunk/src/moul/qt/moulqt.py
Added Paths:
-----------
pymoul/trunk/run.bat
Added: pymoul/trunk/run.bat
===================================================================
--- pymoul/trunk/run.bat (rev 0)
+++ pymoul/trunk/run.bat 2007-02-06 17:51:25 UTC (rev 150)
@@ -0,0 +1,5 @@
+@echo off
+cls
+set PYTHONPATH=src
+python src\moul\qt\moulqt.py
+pause
Modified: pymoul/trunk/src/moul/qt/errorhandler.py
===================================================================
--- pymoul/trunk/src/moul/qt/errorhandler.py 2007-02-06 17:15:50 UTC (rev 149)
+++ pymoul/trunk/src/moul/qt/errorhandler.py 2007-02-06 17:51:25 UTC (rev 150)
@@ -32,7 +32,6 @@
from traceback import format_exception
from moul.log import getLogger
-
from moul.qt.utils import criticalMB
@@ -45,21 +44,20 @@
"""
# TODO: translation aware
LOG.critical("UNHANDLED ERROR", exc_info=(typ, value, traceback))
- if not getattr(sys, 'frozen', False):
- return
- try:
- title= QApplication.translate("excepthook",
- "An unhandled error has occured",
- None, QQApplication.UnicodeUTF8)
- msg = ("Please report the error:\n\n" +
- '\n'.join([line.strip() for line in
- format_exception(typ, value, traceback)])
- )
- mb = criticalMB(None, title, msg)
- mb.exec_()
- except Exception, msg:
- print msg
- #sys.exit(100)
+ if getattr(sys, 'frozen', False):
+ try:
+ title= QApplication.translate("excepthook",
+ "An unhandled error has occured",
+ None, QApplication.UnicodeUTF8)
+ msg = ("Please report the error:\n\n" +
+ '\n'.join([line.strip() for line in
+ format_exception(typ, value, traceback)])
+ )
+ mb = criticalMB(None, title, msg)
+ mb.exec_()
+ except Exception, msg:
+ print msg
+ sys.exit(100)
def setupQtExceptHook():
"""
Modified: pymoul/trunk/src/moul/qt/i18n/__init__.py
===================================================================
--- pymoul/trunk/src/moul/qt/i18n/__init__.py 2007-02-06 17:15:50 UTC (rev 149)
+++ pymoul/trunk/src/moul/qt/i18n/__init__.py 2007-02-06 17:51:25 UTC (rev 150)
@@ -36,11 +36,11 @@
# pkg_resources is incompatible with os.listdir()
LANGS = ('de', 'es', 'fr', 'it', 'nl')
PREFIX = "pymoul"
+TRANSLATIONS = {}
if not __FROZEN__:
# pkg_resources don't work under py2exe yet
import pkg_resources
- TRANSLATIONS = {}
for lang in LANGS:
name = "%s_%s" % (PREFIX, lang)
qm = pkg_resources.resource_string(__name__, "%s.qm" % name)
@@ -55,15 +55,21 @@
@return: binary file data or None
@rtype: str or None
"""
- if __FROZEN__:
- qm = os.path.join(sys.prefix, 'i18n', '%s.qm' % name)
+ global TRANSLATIONS
+ if True: #__FROZEN__:
+ basedir = os.path.dirname(os.path.abspath(sys.argv[0]))
+ #basedir = sys.prefix
+ qm = os.path.join(basedir, 'i18n', '%s.qm' % name)
if os.path.isfile(qm):
- return open(qm, 'rb').read()
+ # TRICKY: we have to make sure that the data is NEVER garbage
+ # collected! But the data in a global dict
+ data = open(qm, 'rb').read()
+ TRANSLATIONS[name] = data
else:
LOG.debug("QM file not found: %s" % qm)
- else:
- return TRANSLATIONS.get(name, None)
+ return TRANSLATIONS.get(name, None)
+
def installTranslator(app):
"""
Installs a translator for the ap
@@ -91,6 +97,6 @@
LOG.info("Loading translation %s" % longname)
if qm is not None:
- #LOG.debug("len(qm) %i" % len(qm))
+ LOG.debug("len(%i), type(%s)" % (len(qm), type(qm)))
translator.load(qm, len(qm))
app.installTranslator(translator)
Modified: pymoul/trunk/src/moul/qt/moulqt.py
===================================================================
--- pymoul/trunk/src/moul/qt/moulqt.py 2007-02-06 17:15:50 UTC (rev 149)
+++ pymoul/trunk/src/moul/qt/moulqt.py 2007-02-06 17:51:25 UTC (rev 150)
@@ -58,7 +58,7 @@
singleapp = SimpleSingleApp('pymoulqt', path=getPyMoulDataDir(check=True))
try:
singleapp.acquire()
- createLogfile()
+
except OSError:
mb = criticalMB(None,
app.trUtf8("pyMoul QT already running"),
@@ -67,6 +67,7 @@
mb.exec_()
sys.exit(1)
+ createLogfile()
setupQtExceptHook()
installTranslator(app)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|