1
0
Fork 0
mirror of https://github.com/borgbackup/borg.git synced 2025-03-04 02:28:34 +00:00

include system info below traceback, fixes #324

This commit is contained in:
Thomas Waldmann 2015-11-21 22:51:59 +01:00
parent b3b4db427c
commit adb35ab07f
2 changed files with 16 additions and 5 deletions

View file

@ -20,7 +20,7 @@ from .helpers import Error, location_validator, format_time, format_file_size, \
format_file_mode, ExcludePattern, IncludePattern, exclude_path, adjust_patterns, to_localtime, timestamp, \ format_file_mode, ExcludePattern, IncludePattern, exclude_path, adjust_patterns, to_localtime, timestamp, \
get_cache_dir, get_keys_dir, prune_within, prune_split, unhexlify, \ get_cache_dir, get_keys_dir, prune_within, prune_split, unhexlify, \
Manifest, remove_surrogates, update_excludes, format_archive, check_extension_modules, Statistics, \ Manifest, remove_surrogates, update_excludes, format_archive, check_extension_modules, Statistics, \
dir_is_tagged, bigint_to_int, ChunkerParams, CompressionSpec, is_slow_msgpack, yes, \ dir_is_tagged, bigint_to_int, ChunkerParams, CompressionSpec, is_slow_msgpack, yes, sysinfo, \
EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
from .logger import create_logger, setup_logging from .logger import create_logger, setup_logging
logger = create_logger() logger = create_logger()
@ -1224,16 +1224,16 @@ def main(): # pragma: no cover
except Error as e: except Error as e:
msg = e.get_message() msg = e.get_message()
if e.traceback: if e.traceback:
msg += "\n%s" % traceback.format_exc() msg += "\n%s\n%s" % (traceback.format_exc(), sysinfo())
exit_code = e.exit_code exit_code = e.exit_code
except RemoteRepository.RPCError as e: except RemoteRepository.RPCError as e:
msg = 'Remote Exception.\n%s' % str(e) msg = 'Remote Exception.\n%s\n%s' % (str(e), sysinfo())
exit_code = EXIT_ERROR exit_code = EXIT_ERROR
except Exception: except Exception:
msg = 'Local Exception.\n%s' % traceback.format_exc() msg = 'Local Exception.\n%s\n%s' % (traceback.format_exc(), sysinfo())
exit_code = EXIT_ERROR exit_code = EXIT_ERROR
except KeyboardInterrupt: except KeyboardInterrupt:
msg = 'Keyboard interrupt.\n%s' % traceback.format_exc() msg = 'Keyboard interrupt.\n%s\n%s' % (traceback.format_exc(), sysinfo())
exit_code = EXIT_ERROR exit_code = EXIT_ERROR
if msg: if msg:
logger.error(msg) logger.error(msg)

View file

@ -14,6 +14,7 @@ except ImportError:
TerminalSize = namedtuple('TerminalSize', ['columns', 'lines']) TerminalSize = namedtuple('TerminalSize', ['columns', 'lines'])
return TerminalSize(int(os.environ.get('COLUMNS', fallback[0])), int(os.environ.get('LINES', fallback[1]))) return TerminalSize(int(os.environ.get('COLUMNS', fallback[0])), int(os.environ.get('LINES', fallback[1])))
import sys import sys
import platform
import time import time
import unicodedata import unicodedata
@ -887,3 +888,13 @@ def yes(msg=None, retry_msg=None, false_msg=None, true_msg=None,
if retry_msg: if retry_msg:
print(retry_msg, file=ofile, end='') print(retry_msg, file=ofile, end='')
ofile.flush() ofile.flush()
def sysinfo():
info = []
info.append('Platform: %s' % (' '.join(platform.uname()), ))
if sys.platform.startswith('linux'):
info.append('Linux: %s %s %s LibC: %s %s' % (platform.linux_distribution() + platform.libc_ver()))
info.append('Python: %s %s' % (platform.python_implementation(), platform.python_version()))
info.append('')
return '\n'.join(info)