34
34
package_repo = 'Gallopsled/pwntools'
35
35
update_freq = datetime .timedelta (days = 7 ).total_seconds ()
36
36
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
-
65
37
def available_on_pypi (prerelease = current_version .is_prerelease ):
66
38
"""Return True if an update is available on PyPI.
67
39
@@ -120,35 +92,20 @@ def perform_check(prerelease=current_version.is_prerelease):
120
92
['pip', 'install', '-U', ...]
121
93
122
94
>>> def bail(*a): raise Exception()
123
- >>> github = pwnlib.update.available_on_github
124
95
>>> pypi = pwnlib.update.available_on_pypi
125
96
126
- >>> pwnlib.update.available_on_github = bail
127
97
>>> perform_check(prerelease=False)
128
98
['pip', 'install', '-U', 'pwntools']
129
99
>>> perform_check(prerelease=True) # doctest: +ELLIPSIS
130
100
['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@...']
138
101
"""
139
102
pypi = current_version
140
103
try :
141
104
pypi = available_on_pypi (prerelease )
142
105
except Exception :
143
106
log .warning ("An issue occurred while checking PyPI" )
144
107
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 )
152
109
where = None
153
110
command = None
154
111
@@ -170,9 +127,6 @@ def perform_check(prerelease=current_version.is_prerelease):
170
127
if best .is_prerelease :
171
128
pypi_package += '==%s' % (best )
172
129
command += [pypi_package ]
173
- else :
174
- where = 'GitHub'
175
- command += ['git+https://github.com/%s.git@%s' % (package_repo , github )]
176
130
177
131
command_str = ' ' .join (command )
178
132
0 commit comments