From 1b94a4a74cbeaf6153e3d33539578279b72b3e27 Mon Sep 17 00:00:00 2001 From: ed Date: Mon, 8 Jul 2019 18:00:58 +0000 Subject: [PATCH] print version on startup --- copyparty/__main__.py | 6 +++++- copyparty/__version__.py | 4 ++-- copyparty/util.py | 13 +++++++++++++ 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/copyparty/__main__.py b/copyparty/__main__.py index 43604534..e3f2108f 100644 --- a/copyparty/__main__.py +++ b/copyparty/__main__.py @@ -18,6 +18,7 @@ from textwrap import dedent from .__init__ import E from .__version__ import S_VERSION, S_BUILD_DT from .svchub import SvcHub +from .util import py_desc class RiceFormatter(argparse.HelpFormatter): @@ -69,7 +70,7 @@ def ensure_cert(): try: if filecmp.cmp(cert_cfg, cert_insec): print( - "\033[33m\n using default TLS certificate; https will be insecure." + "\033[33m using default TLS certificate; https will be insecure." + "\033[36m\n certificate location: {}\033[0m\n".format(cert_cfg) ) except: @@ -80,6 +81,9 @@ def ensure_cert(): def main(): + f = "\033[36mcopyparty v{} ({})\n python v{}\033[0m\n" + print(f.format(S_VERSION, S_BUILD_DT, py_desc())) + ensure_locale() ensure_cert() diff --git a/copyparty/__version__.py b/copyparty/__version__.py index 2364f94a..9192b076 100644 --- a/copyparty/__version__.py +++ b/copyparty/__version__.py @@ -1,7 +1,7 @@ # coding: utf-8 -VERSION = (0, 1, 0) -BUILD_DT = (2019, 6, 13) +VERSION = (0, 2, 0) +BUILD_DT = (2019, 7, 8) S_VERSION = ".".join(map(str, VERSION)) S_BUILD_DT = "{0:04d}-{1:02d}-{2:02d}".format(*BUILD_DT) diff --git a/copyparty/util.py b/copyparty/util.py index d611c9e3..6367d780 100644 --- a/copyparty/util.py +++ b/copyparty/util.py @@ -6,6 +6,7 @@ import sys import base64 import struct import hashlib +import platform import threading import subprocess as sp # nosec @@ -469,6 +470,18 @@ def gzip_orig_sz(fn): return struct.unpack("I", f.read(4))[0] +def py_desc(): + py_ver = ".".join([str(x) for x in sys.version_info]) + ofs = py_ver.find(".final.") + if ofs > 0: + py_ver = py_ver[:ofs] + + bitness = struct.calcsize("P") * 8 + host_os = platform.system() + + return "{0} on {1}{2}".format(py_ver, host_os, bitness) + + class Pebkac(Exception): def __init__(self, code, msg=None): super(Pebkac, self).__init__(msg or HTTPCODE[code])