Skip to content

Commit

Permalink
Generation script fix for 500 server exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
inferno-chromium committed Dec 16, 2020
1 parent 2da9e1b commit 23490a2
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions criticality_score/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ def main():
parser = argparse.ArgumentParser(
description=
'Generate a sorted criticality score list for particular language(s).')
parser.add_argument(
"--language",
nargs='+',
default=[],
required=True,
choices=LANGUAGE_SEARCH_MAP.keys(),
help="List of languages to use.")
parser.add_argument("--language",
nargs='+',
default=[],
required=True,
choices=LANGUAGE_SEARCH_MAP.keys(),
help="List of languages to use.")
parser.add_argument("--count",
type=int,
default=200,
Expand Down Expand Up @@ -76,7 +75,7 @@ def main():
sort='stars',
order='desc'):
# Forced sleep to avoid hitting rate limit.
time.sleep(0.05)
time.sleep(0.1)
repo_url = repo.html_url
if repo_url in parsed_urls:
# Github search can return duplicates, so skip if analyzed.
Expand All @@ -98,8 +97,14 @@ def main():
header = None
stats = []
for i, repo_url in enumerate(parsed_urls):
repo = run.get_repository(repo_url)
output = run.get_repository_stats(repo)
output = None
for _ in range(3):
try:
repo = run.get_repository(repo_url)
output = run.get_repository_stats(repo)
break
except Exception:
print(f'Exception occurred when reading repo: {repo_url}')
if not output:
continue
if not header:
Expand Down

0 comments on commit 23490a2

Please sign in to comment.