aboutsummaryrefslogtreecommitdiffstats
path: root/subreddit.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2020-07-26 22:00:04 +0100
committerjwansek <eddie.atten.ea29@gmail.com>2020-07-26 22:00:04 +0100
commit8f4c9d81a5c78f5f7fb86c1934ce31abd8290ad7 (patch)
treee767e1078f1ca3f5d2fd1e268f1b7a19129e0201 /subreddit.py
parent7677d95c729ab88080d742461fcb3b07c8b421f7 (diff)
downloadSmallYTChannelBot-8f4c9d81a5c78f5f7fb86c1934ce31abd8290ad7.tar.gz
SmallYTChannelBot-8f4c9d81a5c78f5f7fb86c1934ce31abd8290ad7.zip
started on MySQL development branch
Diffstat (limited to 'subreddit.py')
-rwxr-xr-xsubreddit.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/subreddit.py b/subreddit.py
index 205995b..4dc0d2c 100755
--- a/subreddit.py
+++ b/subreddit.py
@@ -21,8 +21,6 @@ FREE_FLAIRS = CONFIG["free_flairs"]
IMGUR = ImgurClient(**CONFIG["imgurapi"])
-db = Database()
-
logging.basicConfig(
format = "[%(asctime)s] %(message)s",
level = logging.INFO,
@@ -381,18 +379,19 @@ def add_times_to_lambdas():
def format_monthly_leaderboard():
- leaderboard = db.get_lambda_leaderboard()
- out = "**Username**|**Medal**|**Times Helped**|**Lambda**\n:-|:-|:-|:-\n"
- for username, times_helped, λ in leaderboard:
- out += "/u/%s|%1s|%s|%sλ\n" % (username, get_medal(λ)[:-1], times_helped, λ)
- return out + "\nLast updated: %s" % get_time()
+ with Database() as db:
+ leaderboard = db.get_lambda_leaderboard()
+ out = "**Username**|**Medal**|**Times Helped**|**Lambda**\n:-|:-|:-|:-\n"
+ for username, times_helped, λ in leaderboard:
+ out += "/u/%s|%1s|%s|%sλ\n" % (username, get_medal(λ)[:-1], times_helped, λ)
+ return out + "\nLast updated: %s" % get_time()
if __name__ == "__main__":
- file = open("pid.txt", "w")
- file.write(str(os.getpid()))
- file.close()
+ file_ = open("pid.txt", "w")
+ file_.write(str(os.getpid()))
+ file_.close()
display("\n####################\n[%s] RESTARTED\n####################\n" % get_time())
main()