in importer.py [0:0]
def wait_for_issue_creation(self, status_url):
"""
Check the status of a GitHub issue import.
If the status is 'pending', it sleeps, then rechecks until the status is
either 'imported' or 'failed'.
"""
while True: # keep checking until status is something other than 'pending'
time.sleep(3)
response = requests.get(status_url, headers=self.headers,
timeout=Importer._DEFAULT_TIME_OUT)
if response.status_code == 404:
continue
elif response.status_code != 200:
raise RuntimeError(
"Failed to check GitHub issue import status url: {} due to unexpected HTTP status code: {}"
.format(status_url, response.status_code)
)
status = response.json()['status']
if status != 'pending':
break
if status == 'imported':
print("Imported Issue:", response.json()['issue_url'].replace('api.github.com/repos/', 'github.com/'))
elif status == 'failed':
raise RuntimeError(
"Failed to import GitHub issue due to the following errors:\n{}"
.format(response.json())
)
else:
raise RuntimeError(
"Status check for GitHub issue import returned unexpected status: '{}'"
.format(status)
)
return response