Skip to content

Commit

Permalink
check online
Browse files Browse the repository at this point in the history
  • Loading branch information
MP3Martin committed Oct 23, 2021
1 parent 55054d8 commit 5d90268
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/input_num.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions input_num/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,26 @@ def __getattr__(self, attr):

sys.modules[__name__] = CallableModule(sys.modules[__name__])

def online():
try:
# connect to the host -- tells us if the host is actually
# reachable
sock = socket.create_connection(("www.google.com", 80))
if sock is not None:
sock.close
return True
except OSError:
pass
return False

def checkver():
packagenm = 'input_num'
responseinfl = requests.get(f'https://pypi.org/pypi/{packagenm}/json')
latest_version = responseinfl.json()['info']['version']
if latest_version != __version__:
print("You are not using latest version, run 'python3 -m pip install --upgrade input_num' three times")

if online() == True:
packagenm = 'input_num'
latest_version = "ERR"
responseinfl = requests.get(f'https://pypi.org/pypi/{packagenm}/json')
latest_version = responseinfl.json()['info']['version']
if latest_version != __version__:
print("[{}] New update is here, run 'python3 -m pip install --upgrade input_num' THREE TIMES in normal terminal".format(packagenm))

checkver()

Expand Down

0 comments on commit 5d90268

Please sign in to comment.