summaryrefslogtreecommitdiff
path: root/server.py
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 /server.py
parent8cfbd1b970870a0d2594e147cd9bcc223d0a33b9 (diff)
downloadcalendar_proxy-6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3.tar.bz2
calendar_proxy-6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3.tar.xz
calendar_proxy-6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3.zip
Cleaning up syntactic crap
Diffstat (limited to 'server.py')
-rw-r--r--server.py38
1 files changed, 13 insertions, 25 deletions
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()