Mercurial > p > roundup > code
annotate roundup-server @ 167:a49c8a2ddd26
Added time logging and file uploading to the templates.
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Mon, 30 Jul 2001 08:12:17 +0000 |
| parents | 0791d13baea7 |
| children | 996eaf90c01e |
| rev | line source |
|---|---|
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
1 #!/usr/bin/python |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
2 """ HTTP Server that serves roundup. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
3 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
4 Stolen from CGIHTTPServer |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
5 |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
61
diff
changeset
|
6 $Id: roundup-server,v 1.6 2001-07-29 07:01:39 richard Exp $ |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
7 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
8 """ |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
9 import sys |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
10 if int(sys.version[0]) < 2: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
11 print "Content-Type: text/plain\n" |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
12 print "Roundup requires Python 2.0 or newer." |
|
32
b475e7d3ce52
actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
27
diff
changeset
|
13 sys.exit(0) |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
14 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
15 __version__ = "0.1" |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
16 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
17 __all__ = ["RoundupRequestHandler"] |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
18 |
|
61
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
19 import os, urllib, StringIO, traceback, cgi, binascii, string, getopt |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
20 import BaseHTTPServer |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
21 import SimpleHTTPServer |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
22 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
23 # Roundup modules of use here |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
24 from roundup import cgitb, cgi_client |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
25 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
26 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
27 ## Configuration |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
28 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
29 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
30 # This indicates where the Roundup instance lives |
|
52
33bfce110d1e
Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents:
32
diff
changeset
|
31 ROUNDUP_INSTANCE_HOMES = { |
|
54
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
32 'bar': '/tmp/bar', |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
33 } |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
34 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
35 # Where to log debugging information to. Use an instance of DevNull if you |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
36 # don't want to log anywhere. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
37 # TODO: actually use this stuff |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
38 #class DevNull: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
39 # def write(self, info): |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
40 # pass |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
41 #LOG = open('/var/log/roundup.cgi.log', 'a') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
42 #LOG = DevNull() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
43 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
44 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
45 ## end configuration |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
46 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
47 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
48 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
49 class RoundupRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler): |
|
61
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
50 ROUNDUP_INSTANCE_HOMES = ROUNDUP_INSTANCE_HOMES |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
51 def send_head(self): |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
52 """Version of send_head that support CGI scripts""" |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
53 # TODO: actually do the HEAD ... |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
54 return self.run_cgi() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
55 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
56 def run_cgi(self): |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
57 """ Execute the CGI command. Wrap an innner call in an error |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
58 handler so all errors can be caught. |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
59 """ |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
60 save_stdin = sys.stdin |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
61 sys.stdin = self.rfile |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
62 try: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
63 self.inner_run_cgi() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
64 except cgi_client.Unauthorised: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
65 self.wfile.write('Content-Type: text/html\n') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
66 self.wfile.write('Status: 403\n') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
67 self.wfile.write('Unauthorised') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
68 except: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
69 try: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
70 reload(cgitb) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
71 self.wfile.write("Content-Type: text/html\n\n") |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
72 self.wfile.write(cgitb.breaker()) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
73 self.wfile.write(cgitb.html()) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
74 except: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
75 self.wfile.write("Content-Type: text/html\n\n") |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
76 self.wfile.write("<pre>") |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
77 s = StringIO.StringIO() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
78 traceback.print_exc(None, s) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
79 self.wfile.write(cgi.escape(s.getvalue())) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
80 self.wfile.write("</pre>\n") |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
81 sys.stdin = save_stdin |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
82 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
83 def inner_run_cgi(self): |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
84 ''' This is the inner part of the CGI handling |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
85 ''' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
86 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
87 rest = self.path |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
88 i = rest.rfind('?') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
89 if i >= 0: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
90 rest, query = rest[:i], rest[i+1:] |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
91 else: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
92 query = '' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
93 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
94 # figure the instance |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
95 if rest == '/': |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
96 raise ValueError, 'No instance specified' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
97 l_path = string.split(rest, '/') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
98 instance = urllib.unquote(l_path[1]) |
|
61
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
99 if self.ROUNDUP_INSTANCE_HOMES.has_key(instance): |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
100 instance_home = self.ROUNDUP_INSTANCE_HOMES[instance] |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
101 module_path, instance = os.path.split(instance_home) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
102 sys.path.insert(0, module_path) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
103 try: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
104 instance = __import__(instance) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
105 finally: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
106 del sys.path[0] |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
107 else: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
108 raise ValueError, 'No such instance "%s"'%instance |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
109 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
110 # figure out what the rest of the path is |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
111 if len(l_path) > 2: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
112 rest = '/'.join(l_path[2:]) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
113 else: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
114 rest = '/' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
115 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
116 # Set up the CGI environment |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
117 env = {} |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
118 env['REQUEST_METHOD'] = self.command |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
119 env['PATH_INFO'] = urllib.unquote(rest) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
120 if query: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
121 env['QUERY_STRING'] = query |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
122 host = self.address_string() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
123 if self.headers.typeheader is None: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
124 env['CONTENT_TYPE'] = self.headers.type |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
125 else: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
126 env['CONTENT_TYPE'] = self.headers.typeheader |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
127 length = self.headers.getheader('content-length') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
128 if length: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
129 env['CONTENT_LENGTH'] = length |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
130 co = filter(None, self.headers.getheaders('cookie')) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
131 if co: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
132 env['HTTP_COOKIE'] = ', '.join(co) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
133 env['SCRIPT_NAME'] = '' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
134 env['SERVER_NAME'] = self.server.server_name |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
135 env['SERVER_PORT'] = str(self.server.server_port) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
136 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
137 decoded_query = query.replace('+', ' ') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
138 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
139 # if root, setuid to nobody |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
140 # TODO why isn't this done much earlier? - say, in main()? |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
141 if not os.getuid(): |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
142 nobody = nobody_uid() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
143 os.setuid(nobody) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
144 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
145 # reload all modules |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
146 # TODO check for file timestamp changes and dependencies |
|
54
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
147 #reload(date) |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
148 #reload(hyperdb) |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
149 #reload(roundupdb) |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
150 #reload(htmltemplate) |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
151 #reload(cgi_client) |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
152 #sys.path.insert(0, module_path) |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
153 #try: |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
154 # reload(instance) |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
155 #finally: |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
156 # del sys.path[0] |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
157 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
158 # initialise the roundupdb, check for auth |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
159 db = instance.open('admin') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
160 message = 'Unauthorised' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
161 auth = self.headers.getheader('authorization') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
162 if auth: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
163 l = binascii.a2b_base64(auth.split(' ')[1]).split(':') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
164 user = l[0] |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
165 password = None |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
166 if len(l) > 1: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
167 password = l[1] |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
168 try: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
169 uid = db.user.lookup(user) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
170 except KeyError: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
171 auth = None |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
172 message = 'Username not recognised' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
173 else: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
174 if password != db.user.get(uid, 'password'): |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
175 message = 'Incorrect password' |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
176 auth = None |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
177 db.close() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
178 del db |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
179 if not auth: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
180 self.send_response(401) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
181 self.send_header('Content-Type', 'text/html') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
182 self.send_header('WWW-Authenticate', 'basic realm="Roundup"') |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
183 self.end_headers() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
184 self.wfile.write(message) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
185 return |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
186 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
187 self.send_response(200, "Script output follows") |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
188 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
189 # do the roundup thang |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
190 db = instance.open(user) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
191 client = instance.Client(self.wfile, db, env, user) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
192 client.main() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
193 do_POST = run_cgi |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
194 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
195 nobody = None |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
196 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
197 def nobody_uid(): |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
198 """Internal routine to get nobody's uid""" |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
199 global nobody |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
200 if nobody: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
201 return nobody |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
202 try: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
203 import pwd |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
204 except ImportError: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
205 return -1 |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
206 try: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
207 nobody = pwd.getpwnam('nobody')[2] |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
208 except KeyError: |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
209 nobody = 1 + max(map(lambda x: x[2], pwd.getpwall())) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
210 return nobody |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
211 |
|
61
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
212 def usage(message=''): |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
213 if message: message = 'Error: %s\n'%message |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
214 print '''%sUsage: |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
215 roundup-server [-n hostname] [-p port] [name=instance home]* |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
216 |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
217 -n: sets the host name |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
218 -p: sets the port to listen on |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
219 |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
220 name=instance home |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
221 Sets the instance home(s) to use. The name is how the instance is |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
222 identified in the URL (it's the first part of the URL path). The |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
223 instance home is the directory that was identified when you did |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
224 "roundup-admin init". You may specify any number of these name=home |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
225 pairs on the command-line. For convenience, you may edit the |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
226 ROUNDUP_INSTANCE_HOMES variable in the roundup-server file instead. |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
227 '''%message |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
228 sys.exit(0) |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
229 |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
230 def main(): |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
231 hostname = '' |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
232 port = 8080 |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
233 try: |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
234 # handle the command-line args |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
235 optlist, args = getopt.getopt(sys.argv[1:], 'n:p:') |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
236 for (opt, arg) in optlist: |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
237 if opt == '-n': hostname = arg |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
238 elif opt == '-p': port = int(arg) |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
239 elif opt == '-h': usage() |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
240 |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
241 # handle instance specs |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
242 if args: |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
243 d = {} |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
244 for arg in args: |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
245 name, home = string.split(arg, '=') |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
246 d[name] = home |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
247 RoundupRequestHandler.ROUNDUP_INSTANCE_HOMES = d |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
248 except: |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
249 type, value = sys.exc_info()[:2] |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
250 usage('%s: %s'%(type, value)) |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
251 |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
252 # we don't want the cgi module interpreting the command-line args ;) |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
253 sys.argv = sys.argv[:1] |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
254 address = (hostname, port) |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
255 httpd = BaseHTTPServer.HTTPServer(address, RoundupRequestHandler) |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
256 print 'Roundup server started on', address |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
257 httpd.serve_forever() |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
258 |
|
61
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
259 if __name__ == '__main__': |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
260 main() |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
261 |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
262 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
263 # $Log: not supported by cvs2svn $ |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
61
diff
changeset
|
264 # Revision 1.5 2001/07/24 01:07:59 richard |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
61
diff
changeset
|
265 # Added command-line arg handling to roundup-server so it's more useful |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
61
diff
changeset
|
266 # out-of-the-box. |
|
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
61
diff
changeset
|
267 # |
|
61
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
268 # Revision 1.4 2001/07/23 10:31:45 richard |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
269 # disabled the reloading until it can be done properly |
|
820c8bb1b71a
Added command-line arg handling to roundup-server...
Richard Jones <richard@users.sourceforge.net>
parents:
54
diff
changeset
|
270 # |
|
54
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
271 # Revision 1.3 2001/07/23 08:53:44 richard |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
272 # Fixed the ROUNDUPS decl in roundup-server |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
273 # Move the installation notes to INSTALL |
|
b68bcb176d1a
disabled the reloading until it can be done properly
Richard Jones <richard@users.sourceforge.net>
parents:
52
diff
changeset
|
274 # |
|
52
33bfce110d1e
Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents:
32
diff
changeset
|
275 # Revision 1.2 2001/07/23 04:05:05 anthonybaxter |
|
33bfce110d1e
Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents:
32
diff
changeset
|
276 # actually quit if python version wrong |
|
33bfce110d1e
Fixed the ROUNDUPS decl in roundup-server
Richard Jones <richard@users.sourceforge.net>
parents:
32
diff
changeset
|
277 # |
|
32
b475e7d3ce52
actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
27
diff
changeset
|
278 # Revision 1.1 2001/07/23 03:46:48 richard |
|
b475e7d3ce52
actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
27
diff
changeset
|
279 # moving the bin files to facilitate out-of-the-boxness |
|
b475e7d3ce52
actually quit if python version wrong
Anthony Baxter <anthonybaxter@users.sourceforge.net>
parents:
27
diff
changeset
|
280 # |
|
27
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
281 # Revision 1.1 2001/07/22 11:15:45 richard |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
282 # More Grande Splite stuff |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
283 # |
|
e5e9ea306a09
moving the bin files to facilitate out-of-the-boxness
Richard Jones <richard@users.sourceforge.net>
parents:
diff
changeset
|
284 # |
|
127
0791d13baea7
Added vim command to all source so that we don't get no steenkin' tabs :)
Richard Jones <richard@users.sourceforge.net>
parents:
61
diff
changeset
|
285 # vim: set filetype=python ts=4 sw=4 et si |
