Log of time spends over a week using info from Outlook calendar through Google API or iCalendar API.
In this Git will be different script to make attempts to get events from Outlook Calendar (Exchange).
The idea is to track the time spent in each task over a week accordingly with defined categories where the time has bucket. E.g.
category_bucket = {'PSM': 'Project Specific Meetings',
'OM': 'Other Meetings',
'PW': 'Project Work',
'OW': 'Other Work',
'TR': 'Transformation',
'IN': 'Innovation',
'PD': 'Personal Development',
'MT': 'Mentoring',
'EH': 'Exempt Hours',
'AL': 'Annual Leave',
'UN': 'Unavailable',
'OT': 'Overtime',
'OTH': 'Other',
'OTHN': 'Other non mine'
}
At the end of the week, you can edit the starting text of each event with the corresponding category.
This script gets the information from Google Calendar or iCalendar (a .ics file is downloaded locally)
from the last Monday to the following Monday. The categories map the events and get the hours spend in
the week in each of them. It exports the results in a CSV, and each week it will append the new info
for the following week. Since there is a problem with the sync between Outlook and Google, it will
be used the syncal.py
which uses the iCalendar method (downloads a cal.ics in your local path).
The are other two script that tries to use the exchange libraries, but credential authentication was not successful:
CalendarExhange.py
and CalendarExcahngelib.py
.
By Getting the ics from Outlook calendar, we can get the events and duration of the events in the calendar accordingly with the defined categories.
- ics
- urllib2
- shutil
- json
- datetime
- timezone
- pandas
- os
- Template
1 . Sync Office 365 calendar (Outlook) to Google calendar. Follow the instructions in this link.
2 . Turn on the Google Calendar API and install the Google Client Library. In this link there is a python sample code which we used to in our code.
3 . More information about the API options.
More information about the Class Calendar events API. You can play with the API using java script in the next link.
- Python 2.7.x.
- httplib2.
- discovery.
- oauth2client.
- timezone.
- Template.
- argparse.
- os.
- ics.
Construct a json file with the credentials from Outlook calendarid.json
, they can be used for both,
syncal.py
and CalendarGoogleAPI.py
:
{"calendarId": [
{"id": "[email protected]",
"URL": "https://outlook.office365.com/owa/calendar/[email protected]/sdfd8f89d90s0dsdfsdff0s88dfs/calendar.ics"
}],
"exchange": [
{"email": "[email protected]",
"URL": "https://outlook.office365.com/EWS/Exchange.asmx"}
]}