aboutsummaryrefslogtreecommitdiffstats
path: root/database.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2023-02-12 21:34:35 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2023-02-12 21:34:35 +0000
commit988c90ce774d163a5aec17e18fd9c9c3c8bfb3b0 (patch)
treef17a2e8055d4f3015a9750eb990d15ebd4859785 /database.py
parentc334660d945c818eac02f22b1582d864ce3906bd (diff)
downloadboymoder.blog-988c90ce774d163a5aec17e18fd9c9c3c8bfb3b0.tar.gz
boymoder.blog-988c90ce774d163a5aec17e18fd9c9c3c8bfb3b0.zip
Added exception handling for when a github repo is empty
Diffstat (limited to 'database.py')
-rwxr-xr-xdatabase.py37
1 files changed, 21 insertions, 16 deletions
diff --git a/database.py b/database.py
index cf51922..c8bf5ff 100755
--- a/database.py
+++ b/database.py
@@ -339,23 +339,28 @@ def request_recent_commits(since = datetime.datetime.now() - datetime.timedelta(
out = []
for repo in g.get_user().get_repos():
# print(repo.name, list(repo.get_branches()))
- for commit in repo.get_commits(since = since):
- out.append({
- "repo": repo.name,
- "message": commit.commit.message,
- "url": commit.html_url,
- "datetime": commit.commit.author.date,
- "stats": {
- "additions": commit.stats.additions,
- "deletions": commit.stats.deletions,
- "total": commit.stats.total
- }
- })
+ try:
+ for commit in repo.get_commits(since = since):
+ out.append({
+ "repo": repo.name,
+ "message": commit.commit.message,
+ "url": commit.html_url,
+ "datetime": commit.commit.author.date,
+ "stats": {
+ "additions": commit.stats.additions,
+ "deletions": commit.stats.deletions,
+ "total": commit.stats.total
+ }
+ })
+ except Exception as e:
+ print(e)
+
return sorted(out, key = lambda a: a["datetime"], reverse = True)
if __name__ == "__main__":
- import app
- with Database() as db:
- print(app.get_sidebar_img(db))
- # print(db.get_sidebar_images())
+ print(request_recent_commits())
+ #import app
+ #with Database() as db:
+ # print(app.get_sidebar_img(db))
+ # # print(db.get_sidebar_images())