# Path: pandasqt/compat.py

# 
# Path: pandasqt/excepthook.py
# def excepthook(excType, excValue, tracebackobj):
#     """
#     Global function to catch unhandled exceptions.
#     
#     @param excType exception type
#     @param excValue exception value
#     @param tracebackobj traceback object
#     """
#     separator = u'-' * 80
# 
#     logFile = os.path.join(tempfile.gettempdir(), "error.log")
#     notice = """An unhandled exception occurred. Please report the problem.\n"""
#     notice += """A log has been written to "{}".\n\nError information:""".format(logFile)
#     timeString = time.strftime("%Y-%m-%d, %H:%M:%S")
# 
#     tbinfofile = cStringIO.StringIO()
#     traceback.print_tb(tracebackobj, None, tbinfofile)
#     tbinfofile.seek(0)
#     tbinfo = tbinfofile.read()
#     tbinfo = tbinfo.decode('utf-8')
# 
#     try:
#         excValueStr = str(excValue).decode('utf-8')
#     except UnicodeEncodeError, e:
#         excValueStr = unicode(excValue)
#     
#     errmsg = u'{0}: \n{1}'.format(excType, excValueStr)
#     sections = [u'\n', separator, timeString, separator, errmsg, separator, tbinfo]
#     msg = u'\n'.join(sections)
#     try:
#         f = codecs.open(logFile, "a+", encoding='utf-8')
#         f.write(msg)
#         f.close()
#     except IOError, e:
#         msgbox(u"unable to write to {0}".format(logFile), u"Writing error")
# 
#     # always show an error message
#     try:
#         if not _isQAppRunning():
#             app = QtGui.QApplication([])
#         _showMessageBox(unicode(notice) + unicode(msg))
#     except:
#         msgbox(unicode(notice) + unicode(msg), u"Error")


from pandasqt.compat import Qt, QtCore, QtGui
from pandasqt.excepthook import excepthook
import pytest
import pytestqt
import sys
# -*- coding: utf-8 -*-



# TODO write it with pytest...

def exception():
    raise ValueError, "Test Test ä"

def exception2():
    raise ValueError, u"Test Test ä"

def exception3():
    raise ValueError, u"Test Test"

def exception4():
    raise ValueError, "Test Test"

app = QtGui.QApplication([])

# Path: pandasqt/compat.py

# 
# Path: pandasqt/excepthook.py
# def excepthook(excType, excValue, tracebackobj):
#     """
#     Global function to catch unhandled exceptions.
#     
#     @param excType exception type
#     @param excValue exception value
#     @param tracebackobj traceback object
#     """
#     separator = u'-' * 80
# 
#     logFile = os.path.join(tempfile.gettempdir(), "error.log")
#     notice = """An unhandled exception occurred. Please report the problem.\n"""
#     notice += """A log has been written to "{}".\n\nError information:""".format(logFile)
#     timeString = time.strftime("%Y-%m-%d, %H:%M:%S")
# 
#     tbinfofile = cStringIO.StringIO()
#     traceback.print_tb(tracebackobj, None, tbinfofile)
#     tbinfofile.seek(0)
#     tbinfo = tbinfofile.read()
#     tbinfo = tbinfo.decode('utf-8')
# 
#     try:
#         excValueStr = str(excValue).decode('utf-8')
#     except UnicodeEncodeError, e:
#         excValueStr = unicode(excValue)
#     
#     errmsg = u'{0}: \n{1}'.format(excType, excValueStr)
#     sections = [u'\n', separator, timeString, separator, errmsg, separator, tbinfo]
#     msg = u'\n'.join(sections)
#     try:
#         f = codecs.open(logFile, "a+", encoding='utf-8')
#         f.write(msg)
#         f.close()
#     except IOError, e:
#         msgbox(u"unable to write to {0}".format(logFile), u"Writing error")
# 
#     # always show an error message
#     try:
#         if not _isQAppRunning():
#             app = QtGui.QApplication([])
#         _showMessageBox(unicode(notice) + unicode(msg))
#     except:
#         msgbox(unicode(notice) + unicode(msg), u"Error")


# Path: tests/test_excepthook.py
from pandasqt.compat import Qt, QtCore, QtGui
from pandasqt.excepthook import excepthook
import pytest
import pytestqt
import sys

# -*- coding: utf-8 -*-



# TODO write it with pytest...

def exception():
    raise ValueError, "Test Test ä"

def exception2():
    raise ValueError, u"Test Test ä"

def exception3():
    raise ValueError, u"Test Test"

def exception4():
    raise ValueError, "Test Test"

app = QtGui.QApplication([])

sys.excepthook = excepthook