-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_calendar.py
48 lines (35 loc) · 1.33 KB
/
get_calendar.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env python
# encoding: utf-8
"""
get_calendar.py
Created by David Kreitschmann on 2011-04-08.
Copyright (c) 2011 David Kreitschmann. All rights reserved.
"""
import re
import campusnet
import urllib2
import ConfigParser
from icalendar import Calendar, Event
def get_calender_for_month(cn_session, year, month):
"""docstring for get_calender"""
export_page = cn_session.request("SCHEDULER_EXPORT_START",("000272", "Y%dM%d"%(year,month)))
m=re.search(r"<a href=\"([0-9a-z/?]+)\">Kalenderdatei</a>",export_page)
file_url = url+m.group(1)
r = urllib2.urlopen(file_url)
cal = Calendar.from_string(r.read())
def get_calender_for_range(cn_session, ):
def main():
config = ConfigParser.SafeConfigParser(campusnet.DEFAULT_CONFIG)
config.read(campusnet.CONFIG_FILE)
user = config.get("Credentials","user")
password = config.get("Credentials", "password")
url = config.get("URL","server_url")
path = config.get("URL","campusnet_path")
cn = campusnet.CampusNetSession(url+path, user, password )
export_page = cn.request("SCHEDULER_EXPORT_START",("000272", "Y2011M04"))
m=re.search(r"<a href=\"([0-9a-z/?]+)\">Kalenderdatei</a>",export_page)
file_url = url+m.group(1)
r = urllib2.urlopen(file_url)
print r.read()
if __name__ == '__main__':
main()