mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-22 09:18:18 +00:00
47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import sys
|
|
|
|
|
|
sys.path.insert(0, '.')
|
|
|
|
# This is needed to find resources when using pyinstaller
|
|
if getattr(sys, 'frozen', False):
|
|
basedir = getattr(sys, '_MEIPASS', '')
|
|
else:
|
|
basedir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
if sys.platform == 'win32':
|
|
os.environ['PATH'] = basedir + ';' + os.environ['PATH']
|
|
|
|
try:
|
|
from picard.tagger import main
|
|
main(os.path.join(basedir, 'locale'), %(autoupdate)s)
|
|
except SystemExit:
|
|
raise # Just continue with a normal application exit
|
|
except: # noqa: F722
|
|
# First try to get traceback information and write it to a log file
|
|
# with minimum chance to fail.
|
|
from tempfile import NamedTemporaryFile
|
|
import traceback
|
|
trace = traceback.format_exc()
|
|
try:
|
|
with NamedTemporaryFile(suffix='.log', prefix='picard-crash-', delete=False) as f:
|
|
f.write(trace.encode(errors="replace"))
|
|
logfile = f.name
|
|
except: # noqa: F722
|
|
print("Failed writing log file {0}".format(logfile), file=sys.stderr)
|
|
logfile = None
|
|
|
|
# Display the crash information to the user as a dialog. This requires#
|
|
# importing Qt5 and has some potential to fail if things are broken.
|
|
from PyQt5 import QtWidgets
|
|
app = QtWidgets.QApplication(sys.argv)
|
|
msg = []
|
|
if logfile:
|
|
msg.append("A logfile has been written to {0}".format(logfile))
|
|
msg.append("Error details: \n{0}".format(trace))
|
|
QtWidgets.QMessageBox.critical(None, "Picard terminated unexpectedly", "\n\n".join(msg))
|
|
raise
|