Skip to content

Commit aec3fa6

Browse files
authored
Remove all Github update checks (#761)
These were nice-to-have, but as long as PyPi is updated and functioning properly, we don't need to check Github. Fixes #756
1 parent ab66024 commit aec3fa6

File tree

1 file changed

+1
-47
lines changed

1 file changed

+1
-47
lines changed

pwnlib/update.py

+1-47
Original file line numberDiff line numberDiff line change
@@ -34,34 +34,6 @@
3434
package_repo = 'Gallopsled/pwntools'
3535
update_freq = datetime.timedelta(days=7).total_seconds()
3636

37-
def available_on_github(prerelease=current_version.is_prerelease):
38-
"""Return True if an update is available on Github.
39-
40-
>>> available_on_github() # doctest: +ELLIPSIS
41-
<Version('...')>
42-
>>> available_on_github(prerelease=False).is_prerelease
43-
False
44-
"""
45-
url = 'https://api.github.com/repos/%s/tags' % package_repo
46-
47-
with context.quiet:
48-
tags = json.loads(wget(url, timeout = 60))
49-
50-
# 'pwntools-ancient' is a tag, but not a valid version.
51-
# Handle this here, and for all potential tags which cause
52-
# issues.
53-
versions = []
54-
for tag in [t['name'] for t in tags]:
55-
try:
56-
versions.append(packaging.version.Version(tag))
57-
except Exception:
58-
pass
59-
60-
if not prerelease:
61-
versions = filter(lambda v: not v.is_prerelease, versions)
62-
63-
return max(versions)
64-
6537
def available_on_pypi(prerelease=current_version.is_prerelease):
6638
"""Return True if an update is available on PyPI.
6739
@@ -120,35 +92,20 @@ def perform_check(prerelease=current_version.is_prerelease):
12092
['pip', 'install', '-U', ...]
12193
12294
>>> def bail(*a): raise Exception()
123-
>>> github = pwnlib.update.available_on_github
12495
>>> pypi = pwnlib.update.available_on_pypi
12596
126-
>>> pwnlib.update.available_on_github = bail
12797
>>> perform_check(prerelease=False)
12898
['pip', 'install', '-U', 'pwntools']
12999
>>> perform_check(prerelease=True) # doctest: +ELLIPSIS
130100
['pip', 'install', '-U', 'pwntools...']
131-
>>> pwnlib.update.available_on_github = github
132-
133-
>>> pwnlib.update.available_on_pypi = bail
134-
>>> perform_check(prerelease=False)
135-
['pip', 'install', '-U', 'git+https://github.com/Gallopsled/pwntools.git@...']
136-
>>> perform_check(prerelease=True) # doctest: +ELLIPSIS
137-
['pip', 'install', '-U', 'git+https://github.com/Gallopsled/pwntools.git@...']
138101
"""
139102
pypi = current_version
140103
try:
141104
pypi = available_on_pypi(prerelease)
142105
except Exception:
143106
log.warning("An issue occurred while checking PyPI")
144107

145-
github = current_version
146-
try:
147-
github = available_on_github(prerelease)
148-
except Exception:
149-
log.warning("An issue occurred while checking Github")
150-
151-
best = max(pypi, github, current_version)
108+
best = max(pypi, current_version)
152109
where = None
153110
command = None
154111

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

177131
command_str = ' '.join(command)
178132

0 commit comments

Comments
 (0)