Added improved verbose logging

This commit is contained in:
¨J-onasJones¨ 2023-12-30 15:25:32 +01:00
parent 5cdd2b93e2
commit 11efc5ddb8

View file

@ -33,7 +33,7 @@ def get_default_branch(repo, access_token):
response.raise_for_status()
repo_data = response.json()
default_branch = repo_data["default_branch"]
verboseprint(f"Fdtched default branch for {BASE_URL}{repo}")
verboseprint(f"[{repo}] Fetched default branch", end="\r")
return default_branch
except Exception as e:
verboseprint(f"Error fetching default branch for {repo}: {str(e)}")
@ -55,7 +55,7 @@ def get_last_commit_timestamp(repo, access_token):
last_commit_date = commit_data["commit"]["author"]["date"]
# Convert last_commit_date to Unix timestamp
timestamp = datetime.strptime(last_commit_date, '%Y-%m-%dT%H:%M:%SZ').timestamp()
verboseprint(f"Fetched timestamp for {BASE_URL}{repo}")
verboseprint(f"[{repo}] Fetched last-commit-timestamp", end="\r")
return int(timestamp)
return None
@ -75,7 +75,7 @@ def get_last_release_version(repo, access_token):
response.raise_for_status()
release_data = response.json()
last_release_version = release_data["tag_name"]
verboseprint(f"Fetched release version for {BASE_URL}{repo}")
verboseprint(f"[{repo}] Fetched last project release version", end="\r")
return last_release_version
except Exception as e:
print(f"Error fetching last release version for {repo}: {str(e)}")
@ -91,7 +91,8 @@ def get_languagages(repo, access_token):
response = requests.get(url, headers=headers)
response.raise_for_status()
languages_data = response.json()
verboseprint(f"Fetched language data for {BASE_URL}{repo}")
verboseprint(f"[{repo}] Fetched repo language statistics ", end="\r")
verboseprint(f"[{repo}] Done! ")
return languages_data
except Exception as e:
print(f"Error fetching languages for {repo}: {str(e)}")
@ -113,6 +114,8 @@ verboseprint(f"Fetched projects.json file")
with open(projects_json_path, "r") as file:
projects_data = json.load(file)
print("Fetching Repo data...")
# Update the last_update (Unix timestamp) for each project
for project in projects_data:
gh_api = project.get("gh_api")