diff options
author | Mike Crute <mcrute@gmail.com> | 2010-02-15 19:19:47 -0500 |
---|---|---|
committer | Mike Crute <mcrute@gmail.com> | 2010-02-15 19:19:47 -0500 |
commit | 6ac707f8ab6ccc551bb0bf1a92aee4ce5329d4f3 (patch) | |
tree | 4e802b77086c7e7d78cd488b396c21cc6ecb2582 /server.py | |
parent | 8cfbd1b970870a0d2594e147cd9bcc223d0a33b9 (diff) | |
download | calendar_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.py | 38 |
1 files changed, 13 insertions, 25 deletions
@@ -1,13 +1,12 @@ | |||
1 | # -*- coding: utf-8 -*- | 1 | # vim: set filencoding=utf8 |
2 | """ | 2 | """ |
3 | Exchange Calendar Proxy Server | 3 | Exchange 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 | |||
11 | from getpass import getpass | 10 | from getpass import getpass |
12 | from ConfigParser import ConfigParser | 11 | from ConfigParser import ConfigParser |
13 | from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler | 12 | from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler |
@@ -17,6 +16,7 @@ from exchange.authenticators import CookieAuthenticator | |||
17 | 16 | ||
18 | 17 | ||
19 | class CalendarHandler(BaseHTTPRequestHandler): | 18 | class 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 | ||
37 | def 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 | |||
48 | def 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 | |||
55 | def main(config_file='exchange.cfg'): | 37 | def 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() |