diff options
author | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-01-19 14:00:50 +0100 |
---|---|---|
committer | Thomas Kriechbaumer <thomas@kriechbaumer.name> | 2017-01-19 20:27:29 +0100 |
commit | 72b753c60f7208ee536dc79bd20b3ba93563668b (patch) | |
tree | 1864d781b05ae2e564ced10659e9c425da00d209 /mitmproxy/utils | |
parent | ea20bfb233a9cad44755417ec0a353bfab116fda (diff) | |
download | mitmproxy-72b753c60f7208ee536dc79bd20b3ba93563668b.tar.gz mitmproxy-72b753c60f7208ee536dc79bd20b3ba93563668b.tar.bz2 mitmproxy-72b753c60f7208ee536dc79bd20b3ba93563668b.zip |
provide git information with --version
fixes #1848
Diffstat (limited to 'mitmproxy/utils')
-rw-r--r-- | mitmproxy/utils/__init__.py | 10 | ||||
-rw-r--r-- | mitmproxy/utils/bits.py | 2 | ||||
-rw-r--r-- | mitmproxy/utils/debug.py | 21 |
3 files changed, 26 insertions, 7 deletions
diff --git a/mitmproxy/utils/__init__.py b/mitmproxy/utils/__init__.py index e69de29b..86649864 100644 --- a/mitmproxy/utils/__init__.py +++ b/mitmproxy/utils/__init__.py @@ -0,0 +1,10 @@ +import os +from contextlib import contextmanager + + +@contextmanager +def chdir(dir): + orig_dir = os.getcwd() + os.chdir(dir) + yield + os.chdir(orig_dir) diff --git a/mitmproxy/utils/bits.py b/mitmproxy/utils/bits.py index ec0d40ef..2c89a999 100644 --- a/mitmproxy/utils/bits.py +++ b/mitmproxy/utils/bits.py @@ -1,5 +1,3 @@ - - def setbit(byte, offset, value): """ Set a bit in a byte to 1 if value is truthy, 0 if not. diff --git a/mitmproxy/utils/debug.py b/mitmproxy/utils/debug.py index ac8fedd7..93fefa9d 100644 --- a/mitmproxy/utils/debug.py +++ b/mitmproxy/utils/debug.py @@ -5,18 +5,29 @@ import threading import signal import platform import traceback +import subprocess from mitmproxy import version +from mitmproxy import utils from OpenSSL import SSL -def sysinfo(): +def dump_system_info(): + git_describe = 'release version' + with utils.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))): + try: + c = ['git', 'describe', '--tags', '--long'] + git_describe = subprocess.check_output(c, stderr=subprocess.STDOUT) + git_describe = git_describe.decode().strip() + except: + pass + data = [ - "Mitmproxy version: %s" % version.VERSION, - "Python version: %s" % platform.python_version(), - "Platform: %s" % platform.platform(), - "SSL version: %s" % SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode(), + "Mitmproxy version: {} ({})".format(version.VERSION, git_describe), + "Python version: {}".format(platform.python_version()), + "Platform: {}".format(platform.platform()), + "SSL version: {}".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()), ] d = platform.linux_distribution() t = "Linux distro: %s %s %s" % d |