diff options
author | Clemens <cle1000.cb@gmail.com> | 2016-07-19 12:32:36 +0200 |
---|---|---|
committer | Clemens <cle1000.cb@gmail.com> | 2016-07-19 12:32:36 +0200 |
commit | 698fb11132598a38851383f805dde5ca4d2a046d (patch) | |
tree | 95fc0184735722ccd6e4697f884496d6852e13f6 /netlib/debug.py | |
parent | 48728af43ad746d70ef3e251dc28b75028dea1e6 (diff) | |
parent | 18dd84b9081fb5552d5b5b2560405496445e2110 (diff) | |
download | mitmproxy-698fb11132598a38851383f805dde5ca4d2a046d.tar.gz mitmproxy-698fb11132598a38851383f805dde5ca4d2a046d.tar.bz2 mitmproxy-698fb11132598a38851383f805dde5ca4d2a046d.zip |
Merge remote-tracking branch 'origin/master' into flow_editing
Diffstat (limited to 'netlib/debug.py')
-rw-r--r-- | netlib/debug.py | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/netlib/debug.py b/netlib/debug.py index a395afcb..29c7f655 100644 --- a/netlib/debug.py +++ b/netlib/debug.py @@ -7,8 +7,6 @@ import signal import platform import traceback -import psutil - from netlib import version from OpenSSL import SSL @@ -19,7 +17,7 @@ def sysinfo(): "Mitmproxy version: %s" % version.VERSION, "Python version: %s" % platform.python_version(), "Platform: %s" % platform.platform(), - "SSL version: %s" % SSL.SSLeay_version(SSL.SSLEAY_VERSION), + "SSL version: %s" % SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode(), ] d = platform.linux_distribution() t = "Linux distro: %s %s %s" % d @@ -40,15 +38,32 @@ def sysinfo(): def dump_info(sig, frm, file=sys.stdout): # pragma: no cover - p = psutil.Process() - print("****************************************************", file=file) print("Summary", file=file) print("=======", file=file) - print("num threads: ", p.num_threads(), file=file) - if hasattr(p, "num_fds"): - print("num fds: ", p.num_fds(), file=file) - print("memory: ", p.memory_info(), file=file) + + try: + import psutil + except: + print("(psutil not installed, skipping some debug info)", file=file) + else: + p = psutil.Process() + print("num threads: ", p.num_threads(), file=file) + if hasattr(p, "num_fds"): + print("num fds: ", p.num_fds(), file=file) + print("memory: ", p.memory_info(), file=file) + + print(file=file) + print("Files", file=file) + print("=====", file=file) + for i in p.open_files(): + print(i, file=file) + + print(file=file) + print("Connections", file=file) + print("===========", file=file) + for i in p.connections(): + print(i, file=file) print(file=file) print("Threads", file=file) @@ -63,18 +78,6 @@ def dump_info(sig, frm, file=sys.stdout): # pragma: no cover for i in bthreads: print(i._threadinfo(), file=file) - print(file=file) - print("Files", file=file) - print("=====", file=file) - for i in p.open_files(): - print(i, file=file) - - print(file=file) - print("Connections", file=file) - print("===========", file=file) - for i in p.connections(): - print(i, file=file) - print("****************************************************", file=file) |