From 90a56a70abed2c6ba66feab2c54efe2e7a279ce6 Mon Sep 17 00:00:00 2001 From: iamdefinitelyahuman Date: Sun, 14 Jul 2019 16:18:52 +0800 Subject: [PATCH] allow no console output when changing solc version --- solcx/__init__.py | 2 +- solcx/install.py | 12 +++++++----- solcx/main.py | 1 - 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/solcx/__init__.py b/solcx/__init__.py index 48a4db6..e31621e 100644 --- a/solcx/__init__.py +++ b/solcx/__init__.py @@ -24,4 +24,4 @@ # default to latest version if get_installed_solc_versions(): - set_solc_version(get_installed_solc_versions()[-1]) + set_solc_version(get_installed_solc_versions()[-1], silent=True) diff --git a/solcx/install.py b/solcx/install.py index 660da68..a5cf5aa 100644 --- a/solcx/install.py +++ b/solcx/install.py @@ -98,15 +98,16 @@ def get_executable(version=None): return str(solc_bin) -def set_solc_version(version): +def set_solc_version(version, silent=False): version = _check_version(version) get_executable(version) global solc_version solc_version = version - print("Using solc version {}".format(solc_version)) + if not silent: + print("Using solc version {}".format(solc_version)) -def set_solc_version_pragma(version): +def set_solc_version_pragma(version, silent=False): version = version.strip() comparator_set_range = [i.strip() for i in version.split('||')] installed_versions = get_installed_solc_versions() @@ -126,14 +127,15 @@ def set_solc_version_pragma(version): if range_flag: set_version = installed_version newer_version = install_solc_pragma(version, install=False) - if _compare_versions(set_version, newer_version, '<'): + if not silent and _compare_versions(set_version, newer_version, '<'): print("Newer compatible solc version exists: {}".format(newer_version)) break if not set_version: set_version = install_solc_pragma(version) global solc_version solc_version = set_version - print("Using solc version {}".format(solc_version)) + if not silent: + print("Using solc version {}".format(solc_version)) def get_available_solc_versions(): diff --git a/solcx/main.py b/solcx/main.py index e252900..125713f 100644 --- a/solcx/main.py +++ b/solcx/main.py @@ -19,7 +19,6 @@ import semantic_version - VERSION_DEV_DATE_MANGLER_RE = re.compile(r'(\d{4})\.0?(\d{1,2})\.0?(\d{1,2})') strip_zeroes_from_month_and_day = functools.partial(VERSION_DEV_DATE_MANGLER_RE.sub, r'\g<1>.\g<2>.\g<3>')