Skip to content

Commit 96e79fc

Browse files
committed
Check return value of get_artifact_tarball()
Fixes PYDOTORG-STAGING-68
1 parent f17ceb8 commit 96e79fc

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

peps/management/commands/generate_pep_pages.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,10 @@ def verbose(msg):
5252

5353
with ExitStack() as stack:
5454
verbose(f"== Fetching PEP artifact from {settings.PEP_ARTIFACT_URL}")
55-
temp_file = self.get_artifact_tarball(stack, verbose)
55+
temp_file = self.get_artifact_tarball(stack)
56+
if not temp_file:
57+
verbose("== No update to artifacts, we're done here!")
58+
return
5659
temp_dir = stack.enter_context(TemporaryDirectory())
5760
tar_ball = stack.enter_context(TarFile.open(fileobj=temp_file, mode='r:gz'))
5861
tar_ball.extractall(path=temp_dir, numeric_owner=False)
@@ -117,7 +120,7 @@ def verbose(msg):
117120

118121
verbose("== Finished")
119122

120-
def get_artifact_tarball(self, stack, verbose):
123+
def get_artifact_tarball(self, stack):
121124
artifact_url = settings.PEP_ARTIFACT_URL
122125
if not artifact_url.startswith(('http://', 'https://')):
123126
return stack.enter_context(open(artifact_url, 'rb'))
@@ -126,7 +129,6 @@ def get_artifact_tarball(self, stack, verbose):
126129
with requests.get(artifact_url, stream=True) as r:
127130
artifact_last_modified = parsedate(r.headers['last-modified'])
128131
if peps_last_updated > artifact_last_modified:
129-
verbose(f"== No update to artifacts, we're done here!")
130132
return
131133

132134
temp_file = stack.enter_context(TemporaryFile())

0 commit comments

Comments
 (0)