Skip to content

Commit

Permalink
Use log instead of print
Browse files Browse the repository at this point in the history
  • Loading branch information
bsquizz committed Oct 27, 2021
1 parent 6776f31 commit 482b453
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
21 changes: 10 additions & 11 deletions bonfire/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,21 +429,21 @@ def _compare_version(pypi_version):
try:
my_version = StrictVersion(local_version)
except ValueError:
print(f"Version {local_version} seems to be a dev version, assuming up-to-date")
log.info(f"version {local_version} seems to be a dev version, assuming up-to-date")
my_version = StrictVersion("999.999.999")
return

if my_version < pypi_version:
print(
log.info(
"\n"
"There is a new bonfire version available! (yours: {}, available: {})"
"there is a new bonfire version available! (yours: {}, available: {})"
"\n"
"Upgrade with:\n"
"upgrade with:\n"
f" pip install --upgrade {PKG_NAME}"
" ".format(my_version, pypi_version)
)
else:
print("Up-to-date!")
log.info("up-to-date!")


def _update_ver_check_file():
Expand Down Expand Up @@ -479,24 +479,23 @@ def check_pypi():
if not _ver_check_needed():
return

print("\nChecking pypi for latest release...")
log.info("\nChecking pypi for latest release...")

pkg_data = {}
try:
response = requests.get(PYPI_URL, timeout=5)
response.raise_for_status()
pkg_data = response.json()
except requests.exceptions.Timeout:
print("Unable to reach pypi quickly, giving up.")
log.error("Unable to reach pypi quickly, giving up.")
except requests.exceptions.HTTPError as e:
print("Error response from pypi: ", e.errno, e.message)
log.error("Error response from pypi: ", e.errno, e.message)
except ValueError:
print("Response was not valid json, giving up.")
log.error("Response was not valid json, giving up.")

try:
pypi_version = pkg_data["info"]["version"]
except KeyError:
print("Unable to parse version info from pypi")
log.error("Unable to parse version info from pypi")
else:
_compare_version(pypi_version)
print("\n")
2 changes: 1 addition & 1 deletion cicd/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ python3 -m venv .bonfire_venv
source .bonfire_venv/bin/activate

pip install --upgrade pip 'setuptools<58' wheel
pip install --upgrade 'crc-bonfire>=2.17.1'
pip install --upgrade 'crc-bonfire>=2.17.2'

# clone repo to download cicd scripts
git clone https://github.com/RedHatInsights/bonfire.git $BONFIRE_ROOT
Expand Down

0 comments on commit 482b453

Please sign in to comment.