diff --git a/main.py b/main.py index b056db2..0203a68 100644 --- a/main.py +++ b/main.py @@ -124,18 +124,21 @@ def generate_commit_list(): for repository in repos: result = run_query( createCommittedDateQuery.substitute(owner=repository["owner"]["login"], name=repository["name"], id=id)) - committed_dates = result["data"]["repository"]["ref"]["target"]["history"]["edges"] - for committedDate in committed_dates: - date = datetime.datetime.strptime(committedDate["node"]["committedDate"], "%Y-%m-%dT%H:%M:%SZ") - hour = date.hour - if 6 <= hour < 12: - morning += 1 - if 12 <= hour < 18: - daytime += 1 - if 18 <= hour < 24: - evening += 1 - if 0 <= hour < 6: - night += 1 + try: + committed_dates = result["data"]["repository"]["ref"]["target"]["history"]["edges"] + for committedDate in committed_dates: + date = datetime.datetime.strptime(committedDate["node"]["committedDate"], "%Y-%m-%dT%H:%M:%SZ") + hour = date.hour + if 6 <= hour < 12: + morning += 1 + if 12 <= hour < 18: + daytime += 1 + if 18 <= hour < 24: + evening += 1 + if 0 <= hour < 6: + night += 1 + except Exception as ex: + print("Exception occured" + str(ex)); sumAll = morning + daytime + evening + night if morning + daytime >= evening + night: @@ -157,10 +160,7 @@ def get_stats(): stats = '' if showCommit.lower() in ['true', '1', 't', 'y', 'yes']: - try: - stats = stats + generate_commit_list() + '\n\n' - except Exception as ex: - print("GitHub Personal access token not configured properly or invalid" + str(ex)) + stats = stats + generate_commit_list() + '\n\n' try: request = requests.get(