def handle_exception(self, inst): build = get_git_sha1_auto() stacktrace = "".join(_format_exc_info(*sys.exc_info())) msg = 'Build: {}\n{}'.format(build, stacktrace) p = ErrorPopup(details=msg) p.chain_open() return ExceptionManager.PASS
def check_libraries_requirements(): """Check if the required dependencies are met. Calling this function at the program start will allow the program to terminate gracefully in case of an unmet dependency instead of crashing while performing important tasks.""" file_path = paths.get_base_path('requirements.txt') try: # Skip the check if we are running in a |PyInstaller| bundle. Assume everything is all right. if not paths.is_pyinstaller_bundle(): with file(file_path) as req_file: requirements = req_file.readlines() require(requirements) # Libtorrent requirements try: # Workaround for libtorrent version (not available on pip so it cannot # be written inside requirements.txt). import libtorrent if LooseVersion(libtorrent.version) < LooseVersion( libtorrent_least_required_version): raise VersionConflict( 'libtorrent {}'.format(libtorrent.version), 'libtorrent >= {}'.format( libtorrent_least_required_version)) except ImportError: raise DistributionNotFound('libtorrent') # Kivy requirements try: import multiprocessing multiprocessing.freeze_support() import kivy kivy.require(kivy_least_required_version) except ImportError: raise DistributionNotFound('kivy') except Exception: # Kivy raises an Exception with a not-so-nicely formatted message # Just print it and exit msg = "".join(_format_exc_info(*sys.exc_info())) + \ "\nAvast DeepScreen is known to fail here." MessageBox(msg, 'Kivy error') sys.exit(1) except VersionConflict as ex: message = 'Wrong library version. Installed: {}. Required: {}'.format( ex.args[0], ex.args[1]) MessageBox(message, 'Error') sys.exit(1) except DistributionNotFound as ex: message = 'Missing python library. Required: {}'.format(ex.args[0]) MessageBox(message, 'Error') sys.exit(1)
def _protected_call(messagequeue, function, action_name, *args, **kwargs): try: Logger.info('Para: Starting new thread/process for: {}'.format(action_name)) return function(messagequeue, *args, **kwargs) except Exception: stacktrace = "".join(_format_exc_info(*sys.exc_info())) error = 'An error occurred in a subprocess:\nBuild: {}\n{}'.format(get_git_sha1_auto(), stacktrace).rstrip() messagequeue.reject({'details': error}) finally: Logger.info('Para: Closing thread/process for: {}'.format(action_name))
def wrapper(*args, **kwargs): try: try: func(*args, **kwargs) except (UnicodeEncodeError, UnicodeDecodeError) as ex: error_message = "{}. Original exception: {} Text: {}".format( unicode(ex), type(ex).__name__, repr(ex.args[1])) raise UnicodeError, UnicodeError( error_message), sys.exc_info()[2] except Exception: build = get_git_sha1_auto() stacktrace = "".join(_format_exc_info(*sys.exc_info())) msg = 'Build: {}\n{}'.format(build, stacktrace) # p = ErrorPopup(details=msg) # p.open() MessageBox(msg, CRITICAL_POPUP_TITLE)
from utils.critical_messagebox import MessageBox CRITICAL_POPUP_TITLE = """An error occurred. Copy it with Ctrl+C and submit a bug""" try: from utils.primitive_git import get_git_sha1_auto build = get_git_sha1_auto() except: build = 'N/A (exception occurred)\nBuild exception reason:\n{}'.format( repr(sys.exc_info()[1]) ) try: from utils.testtools_compat import _format_exc_info stacktrace = "".join(_format_exc_info(*exc_info)) except: try: import traceback last_chance_traceback = "\n".join(traceback.format_tb(exc_info[2])) except: last_chance_traceback = "Traceback parsing failed. Reason:\n{}\n\nLast chance parsing:\n{}".format( repr(sys.exc_info()[1]), repr(exc_info[1]) ) stacktrace = "Could not parse stacktrace. Emergency parsing:\n{}\nException while parsing stacktrace:\n{}".format( last_chance_traceback, repr(sys.exc_info()[1]) )