-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from LLNL/checkver-hardening
Make Checkver more resilient to failures
- Loading branch information
Showing
1 changed file
with
22 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,28 @@ | ||
pkg = "uedge" | ||
|
||
import json | ||
try: | ||
import json | ||
import urllib.request | ||
|
||
pkg = 'uedge' | ||
try: | ||
import importlib.metadata | ||
|
||
try: | ||
import importlib.metadata | ||
thisver = importlib.metadata.version(pkg) | ||
except: | ||
import pkg_resources | ||
thisver = pkg_resources.get_distribution(pkg).version | ||
thisver = importlib.metadata.version(pkg) | ||
except: | ||
import pkg_resources | ||
|
||
try: | ||
import urllib.request | ||
contents = urllib.request.urlopen('https://pypi.org/pypi/'+pkg+'/json').read() | ||
data = json.loads(contents.decode()) | ||
thatver = data['info']['version'] | ||
except: | ||
import urllib | ||
contents = urllib.urlopen('https://pypi.org/pypi/'+pkg+'/json').read() | ||
data = json.loads(contents) | ||
thatver = str(data['info']['version']) | ||
thisver = pkg_resources.get_distribution(pkg).version | ||
|
||
contents = urllib.request.urlopen("https://pypi.org/pypi/" + pkg + "/json").read() | ||
data = json.loads(contents.decode()) | ||
thatver = data["info"]["version"] | ||
|
||
if thisver < thatver: | ||
print() | ||
print("Uedge version " + thisver + ", an update is available to " + thatver) | ||
print() | ||
|
||
if thisver > thatver: | ||
#print('Uedge version '+thisver+' is newer than available with pip ('+thatver+')') | ||
pass | ||
elif thisver == thatver: | ||
#print('Uedge version '+thisver+' is up-to-date') | ||
pass | ||
elif thisver < thatver: | ||
print() | ||
print('Uedge version '+thisver+', an update is available to '+thatver) | ||
print() | ||
else: | ||
print() | ||
print('Some error checking pypi version') | ||
print() | ||
except Exception as err: | ||
print() | ||
print("Error checking pypi version: {}".format(err)) | ||
print() |