aboutsummaryrefslogtreecommitdiffstats
path: root/mitmproxy/utils
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-10-23 18:24:06 +0200
committerMaximilian Hils <git@maximilianhils.com>2017-10-24 14:33:56 +0200
commita5d74356dda2f34d9bebf3a3276f5f7d1869985a (patch)
tree63cd310cea348e06647ffe196dd1182ba2ed75bd /mitmproxy/utils
parent569d275d763f499cce9673fcf118dcc8d59d2eeb (diff)
downloadmitmproxy-a5d74356dda2f34d9bebf3a3276f5f7d1869985a.tar.gz
mitmproxy-a5d74356dda2f34d9bebf3a3276f5f7d1869985a.tar.bz2
mitmproxy-a5d74356dda2f34d9bebf3a3276f5f7d1869985a.zip
simplify version output
Diffstat (limited to 'mitmproxy/utils')
-rw-r--r--mitmproxy/utils/__init__.py10
-rw-r--r--mitmproxy/utils/debug.py77
2 files changed, 33 insertions, 54 deletions
diff --git a/mitmproxy/utils/__init__.py b/mitmproxy/utils/__init__.py
index 86649864..e69de29b 100644
--- a/mitmproxy/utils/__init__.py
+++ b/mitmproxy/utils/__init__.py
@@ -1,10 +0,0 @@
-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/debug.py b/mitmproxy/utils/debug.py
index c2eee2b6..de01b12c 100644
--- a/mitmproxy/utils/debug.py
+++ b/mitmproxy/utils/debug.py
@@ -8,60 +8,49 @@ import traceback
import subprocess
from mitmproxy import version
-from mitmproxy import utils
from OpenSSL import SSL
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)
- last_tag, tag_dist, commit = git_describe.decode().strip().rsplit("-", 2)
-
- if last_tag.startswith('v'):
- # remove the 'v' prefix
- last_tag = last_tag[1:]
- if commit.startswith('g'):
- # remove the 'g' prefix added by recent git versions
- commit = commit[1:]
-
- # build the same version specifier as used for snapshots by rtool
- git_describe = "{version}dev{tag:04}-0x{commit}".format(
- version=last_tag,
- tag=int(tag_dist),
- commit=commit,
- )
- except:
- pass
+ mitmproxy_version = version.VERSION
+ here = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
+ try:
+ git_describe = subprocess.check_output(
+ ['git', 'describe', '--tags', '--long'],
+ stderr=subprocess.STDOUT,
+ cwd=here,
+ )
+ except:
+ pass
+ else:
+ last_tag, tag_dist, commit = git_describe.decode().strip().rsplit("-", 2)
- bin_indicator = "" # PyInstaller builds indicator, if using precompiled binary
- if getattr(sys, 'frozen', False):
- bin_indicator = "Precompiled Binary"
+ commit = commit.lstrip("g") # remove the 'g' prefix added by recent git versions
+ tag_dist = int(tag_dist)
- data = [
- "Mitmproxy version: {} ({}) {}".format(version.VERSION, git_describe, bin_indicator),
- "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
- if d[0]: # pragma: no cover
- data.append(t)
+ if tag_dist > 0:
+ tag_dist = "dev{:04}".format(tag_dist)
+ else:
+ tag_dist = ""
- d = platform.mac_ver()
- t = "Mac version: %s %s %s" % d
- if d[0]: # pragma: no cover
- data.append(t)
+ mitmproxy_version += "{tag_dist} ({commit})".format(
+ tag_dist=tag_dist,
+ commit=commit,
+ )
- d = platform.win32_ver()
- t = "Windows version: %s %s %s %s" % d
- if d[0]: # pragma: no cover
- data.append(t)
+ # PyInstaller builds indicator, if using precompiled binary
+ if getattr(sys, 'frozen', False):
+ bin_indicator = "binary"
+ else:
+ bin_indicator = ""
+ data = [
+ "Mitmproxy: {} {}".format(mitmproxy_version, bin_indicator),
+ "Python: {}".format(platform.python_version()),
+ "OpenSSL: {}".format(SSL.SSLeay_version(SSL.SSLEAY_VERSION).decode()),
+ "Platform: {}".format(platform.platform()),
+ ]
return "\n".join(data)