Skip to content

Commit

Permalink
Remove all Github update checks (#761)
Browse files Browse the repository at this point in the history
These were nice-to-have, but as long as PyPi is updated and functioning
properly, we don't need to check Github.

Fixes #756
  • Loading branch information
zachriggle authored Oct 7, 2016
1 parent ab66024 commit aec3fa6
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions pwnlib/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,6 @@
package_repo = 'Gallopsled/pwntools'
update_freq = datetime.timedelta(days=7).total_seconds()

def available_on_github(prerelease=current_version.is_prerelease):
"""Return True if an update is available on Github.
>>> available_on_github() # doctest: +ELLIPSIS
<Version('...')>
>>> available_on_github(prerelease=False).is_prerelease
False
"""
url = 'https://api.github.com/repos/%s/tags' % package_repo

with context.quiet:
tags = json.loads(wget(url, timeout = 60))

# 'pwntools-ancient' is a tag, but not a valid version.
# Handle this here, and for all potential tags which cause
# issues.
versions = []
for tag in [t['name'] for t in tags]:
try:
versions.append(packaging.version.Version(tag))
except Exception:
pass

if not prerelease:
versions = filter(lambda v: not v.is_prerelease, versions)

return max(versions)

def available_on_pypi(prerelease=current_version.is_prerelease):
"""Return True if an update is available on PyPI.
Expand Down Expand Up @@ -120,35 +92,20 @@ def perform_check(prerelease=current_version.is_prerelease):
['pip', 'install', '-U', ...]
>>> def bail(*a): raise Exception()
>>> github = pwnlib.update.available_on_github
>>> pypi = pwnlib.update.available_on_pypi
>>> pwnlib.update.available_on_github = bail
>>> perform_check(prerelease=False)
['pip', 'install', '-U', 'pwntools']
>>> perform_check(prerelease=True) # doctest: +ELLIPSIS
['pip', 'install', '-U', 'pwntools...']
>>> pwnlib.update.available_on_github = github
>>> pwnlib.update.available_on_pypi = bail
>>> perform_check(prerelease=False)
['pip', 'install', '-U', 'git+https://github.com/Gallopsled/pwntools.git@...']
>>> perform_check(prerelease=True) # doctest: +ELLIPSIS
['pip', 'install', '-U', 'git+https://github.com/Gallopsled/pwntools.git@...']
"""
pypi = current_version
try:
pypi = available_on_pypi(prerelease)
except Exception:
log.warning("An issue occurred while checking PyPI")

github = current_version
try:
github = available_on_github(prerelease)
except Exception:
log.warning("An issue occurred while checking Github")

best = max(pypi, github, current_version)
best = max(pypi, current_version)
where = None
command = None

Expand All @@ -170,9 +127,6 @@ def perform_check(prerelease=current_version.is_prerelease):
if best.is_prerelease:
pypi_package += '==%s' % (best)
command += [pypi_package]
else:
where = 'GitHub'
command += ['git+https://github.com/%s.git@%s' % (package_repo, github)]

command_str = ' '.join(command)

Expand Down

0 comments on commit aec3fa6

Please sign in to comment.