From a54348514088370d40498aaa5047c10847a7dad8 Mon Sep 17 00:00:00 2001 From: Benjamin Mako Hill Date: Sat, 31 Aug 2019 11:22:26 -0700 Subject: [PATCH] several small improvements - altered to read password from a file - deactivated the hard-coded password - several other small rearrangements - added password file to .gitignore --- .gitignore | 1 + count_todo_items.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 0de3672..42a07dd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ mako_open_todos.csv +nextcloud_password_file diff --git a/count_todo_items.py b/count_todo_items.py index 2e13350..d12f249 100755 --- a/count_todo_items.py +++ b/count_todo_items.py @@ -1,5 +1,9 @@ #!/usr/bin/env python3 +# configuration options +database_filename = "mako_open_todos.csv" +caldav_url = "https://mako:{pw}@nimbus.mako.cc/remote.php/dav/calendars/mako/personal/" + import datetime import mailbox import numpy as np @@ -9,8 +13,9 @@ import pandas as pd import caldav from caldav.elements import dav, cdav -nimbus_password = '7TS3L-xABPz-8PJwn-zxAz7-ZY2Y5' -database_filename = "mako_open_todos.csv" +# read password from a file +with open("nextcloud_password_file", "r") as f: + nimbus_password = f.read().strip() current_timestamp = datetime.datetime.now() data_original = pd.read_csv(database_filename) @@ -42,7 +47,7 @@ data_email_uw = rows_from_mb_counts("UW inbox", get_flags_for_maildir("~/incoming/mail/uw-inbox")) # load calendar data -caldav_client = caldav.DAVClient("https://mako:{pw}@nimbus.mako.cc/remote.php/dav/calendars/mako/personal/".format(pw=nimbus_password)) +caldav_client = caldav.DAVClient(caldav_url.format(pw=nimbus_password)) cal = caldav_client.principal().calendars()[0] caldav_count = np.sum(["PERCENT-COMPLETE:100" not in c.data -- 2.39.5