10 from caldav.elements import dav, cdav
12 nimbus_password = '7TS3L-xABPz-8PJwn-zxAz7-ZY2Y5'
13 database_filename = "list_of_databases.csv"
15 current_timestamp = datetime.datetime.now()
16 data_original = pd.read_csv(database_filename)
18 def get_flags_for_maildir (maildir_name):
19 mb_counts = { 'unread' : 0, 'flagged' : 0 }
21 mb = mailbox.Maildir(maildir_name)
24 flags = msg.get_flags()
26 mb_counts['unread'] += 1
28 mb_counts['flagged'] += 1
32 def rows_from_mb_counts (source_string, mb_counts):
33 return pd.DataFrame({'time' : current_timestamp,
34 'source' : source_string,
35 'feature' : list(mb_counts.keys()),
36 'count' : list(mb_counts.values())})
38 data_email_personal = rows_from_mb_counts("default inbox",
39 get_flags_for_maildir("~/incoming/mail/default"))
41 data_email_uw = rows_from_mb_counts("UW inbox",
42 get_flags_for_maildir("~/incoming/mail/uw-inbox"))
45 caldav_client = caldav.DAVClient("https://mako:{pw}@nimbus.mako.cc/remote.php/dav/calendars/mako/personal/".format(pw=nimbus_password))
46 cal = caldav_client.principal().calendars()[0]
48 caldav_count = np.sum(["PERCENT-COMPLETE:100" not in c.data
49 for c in cal.todos(include_completed=True)])
51 data_nextcloud = pd.DataFrame({'time' : [current_timestamp],
52 'source' : ['nextcloud tasks'],
54 'count' : [caldav_count]})
56 ## write things out to the data file
57 pd.concat([data_original,
60 data_nextcloud]).to_csv(database_filename, index=False)