summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mcrute@gmail.com>2010-02-15 19:19:47 -0500
committerMike Crute <mcrute@gmail.com>2010-02-15 19:19:47 -0500
commit6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3 (patch)
tree4e802b77086c7e7d78cd488b396c21cc6ecb2582
parent8cfbd1b970870a0d2594e147cd9bcc223d0a33b9 (diff)
downloadcalendar_proxy-6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3.tar.bz2
calendar_proxy-6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3.tar.xz
calendar_proxy-6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3.zip
Cleaning up syntactic crap
-rw-r--r--exchange/__init__.py4
-rw-r--r--exchange/authenticators.py5
-rw-r--r--exchange/commands.py5
-rw-r--r--exchange/timezones.py5
-rw-r--r--server.py38
5 files changed, 20 insertions, 37 deletions
diff --git a/exchange/__init__.py b/exchange/__init__.py
index 429946a..a2a78ec 100644
--- a/exchange/__init__.py
+++ b/exchange/__init__.py
@@ -1,12 +1,10 @@
1# -*- coding: utf-8 -*- 1# vim: set filencoding=utf8
2""" 2"""
3Exchange Server Handling Code 3Exchange Server Handling Code
4 4
5@author: Mike Crute (mcrute@gmail.com) 5@author: Mike Crute (mcrute@gmail.com)
6@organization: SoftGroup Interactive, Inc. 6@organization: SoftGroup Interactive, Inc.
7@date: April 26, 2009 7@date: April 26, 2009
8
9$Id$
10""" 8"""
11 9
12 10
diff --git a/exchange/authenticators.py b/exchange/authenticators.py
index 12fb309..bcc2e38 100644
--- a/exchange/authenticators.py
+++ b/exchange/authenticators.py
@@ -1,13 +1,12 @@
1# -*- coding: utf-8 -*- 1# vim: set filencoding=utf8
2""" 2"""
3Exchange Server Authenticators 3Exchange Server Authenticators
4 4
5@author: Mike Crute (mcrute@gmail.com) 5@author: Mike Crute (mcrute@gmail.com)
6@organization: SoftGroup Interactive, Inc. 6@organization: SoftGroup Interactive, Inc.
7@date: April 26, 2009 7@date: April 26, 2009
8
9$Id$
10""" 8"""
9
11import urllib 10import urllib
12 11
13from copy import copy 12from copy import copy
diff --git a/exchange/commands.py b/exchange/commands.py
index 40446e2..8198ca6 100644
--- a/exchange/commands.py
+++ b/exchange/commands.py
@@ -1,4 +1,4 @@
1# -*- coding: utf-8 -*- 1# vim: set filencoding=utf8
2""" 2"""
3Exchange Commands 3Exchange Commands
4 4
@@ -9,9 +9,8 @@ This is a set of classes that starts to define a set of classes for
9fetching data using Exchange's WebDAV API. This is still pretty 9fetching data using Exchange's WebDAV API. This is still pretty
10development code but it does the trick. Watch out, it doesn't consider 10development code but it does the trick. Watch out, it doesn't consider
11many corner cases. 11many corner cases.
12
13$Id$
14""" 12"""
13
15import xml.etree.cElementTree as etree 14import xml.etree.cElementTree as etree
16 15
17from httplib import HTTPSConnection 16from httplib import HTTPSConnection
diff --git a/exchange/timezones.py b/exchange/timezones.py
index eefbe8e..b570e7b 100644
--- a/exchange/timezones.py
+++ b/exchange/timezones.py
@@ -1,13 +1,12 @@
1# -*- coding: utf-8 -*- 1# vim: set filencoding=utf8
2""" 2"""
3Timezone Definitions 3Timezone Definitions
4 4
5@author: Mike Crute (mcrute@gmail.com) 5@author: Mike Crute (mcrute@gmail.com)
6@organization: SoftGroup Interactive, Inc. 6@organization: SoftGroup Interactive, Inc.
7@date: April 26, 2009 7@date: April 26, 2009
8
9$Id$
10""" 8"""
9
11from datetime import tzinfo, timedelta 10from datetime import tzinfo, timedelta
12 11
13 12
diff --git a/server.py b/server.py
index cb101cd..0510b2b 100644
--- a/server.py
+++ b/server.py
@@ -1,13 +1,12 @@
1# -*- coding: utf-8 -*- 1# vim: set filencoding=utf8
2""" 2"""
3Exchange Calendar Proxy Server 3Exchange Calendar Proxy Server
4 4
5@author: Mike Crute (mcrute@gmail.com) 5@author: Mike Crute (mcrute@gmail.com)
6@organization: SoftGroup Interactive, Inc. 6@organization: SoftGroup Interactive, Inc.
7@date: April 26, 2009 7@date: April 26, 2009
8
9$Id$
10""" 8"""
9
11from getpass import getpass 10from getpass import getpass
12from ConfigParser import ConfigParser 11from ConfigParser import ConfigParser
13from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler 12from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
@@ -17,6 +16,7 @@ from exchange.authenticators import CookieAuthenticator
17 16
18 17
19class CalendarHandler(BaseHTTPRequestHandler): 18class CalendarHandler(BaseHTTPRequestHandler):
19
20 def do_GET(self): 20 def do_GET(self):
21 print('* Fetching Calendars') 21 print('* Fetching Calendars')
22 22
@@ -34,34 +34,22 @@ class CalendarHandler(BaseHTTPRequestHandler):
34 self.wfile.close() 34 self.wfile.close()
35 35
36 36
37def get_un_pass(config):
38 username = config.get('exchange', 'user')
39
40 if config.has_option('exchange', 'password'):
41 password = config.get('exchange', 'password')
42 else:
43 password = getpass('Exchange Password: ')
44
45 return username, password
46
47
48def get_host_port(config):
49 bind_address = config.get('local_server', 'address')
50 bind_port = int(config.get('local_server', 'port'))
51
52 return bind_address, bind_port
53
54
55def main(config_file='exchange.cfg'): 37def main(config_file='exchange.cfg'):
56 config = ConfigParser() 38 config = ConfigParser()
57 config.read(config_file) 39 config.read(config_file)
58 server_cfg = get_host_port(config) 40 bind_address = config.get('local_server', 'address')
41 bind_port = int(config.get('local_server', 'port'))
59 42
60 print('Exchange iCal Proxy Running on port {0:d}'.format(server_cfg[1])) 43 print('Exchange iCal Proxy Running on port {0:d}'.format(bind_port))
61 44
62 server = HTTPServer(server_cfg, CalendarHandler) 45 server = HTTPServer((bind_address, bind_port), CalendarHandler)
63 server.exchange_server = config.get('exchange', 'server') 46 server.exchange_server = config.get('exchange', 'server')
64 server.user, server.password = get_un_pass(config) 47 server.user = config.get('exchange', 'user')
48
49 if config.has_option('exchange', 'password'):
50 server.password = config.get('exchange', 'password')
51 else:
52 server.password = getpass('Exchange Password: ')
65 53
66 try: 54 try:
67 server.serve_forever() 55 server.serve_forever()