Mercurial > p > roundup > code
comparison frontends/roundup.cgi @ 8560:646ba821f63e
feat: add TIMING option, python install dir setting, more cleanups
Add commented out sys.path.append(...) for user to change location of
roundup libraries.
Add TIMING global to control output of timing information.
Some more ruff cleanups and remove from __future__ import
print_function. This is Python 3 for pete's sake.
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Wed, 08 Apr 2026 21:00:34 -0400 |
| parents | 5fbf6451a782 |
| children |
comparison
equal
deleted
inserted
replaced
| 8559:19670ecbad82 | 8560:646ba821f63e |
|---|---|
| 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 14 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 15 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 16 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 17 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 18 | 18 |
| 19 # python version check | |
| 20 from __future__ import print_function | |
| 21 | |
| 22 import sys | 19 import sys |
| 23 import time | 20 import time |
| 24 | 21 |
| 25 from roundup import version_check | 22 # If roundup is not on your normal path, add it here. |
| 23 # sys.path.append('/home/username/develop/roundup_dev') | |
| 24 from roundup import version_check # noqa: F401 | |
| 26 from roundup.anypy.html import html_escape | 25 from roundup.anypy.html import html_escape |
| 27 from roundup.anypy.strings import StringIO, s2b | 26 from roundup.anypy.strings import StringIO, s2b |
| 28 from roundup.i18n import _ | 27 from roundup.i18n import _ |
| 29 | 28 |
| 30 # | 29 # |
| 47 # logging is turned off (unless you changed the default below). | 46 # logging is turned off (unless you changed the default below). |
| 48 | 47 |
| 49 # DEBUG_TO_CLIENT specifies whether debugging goes to the HTTP server (via | 48 # DEBUG_TO_CLIENT specifies whether debugging goes to the HTTP server (via |
| 50 # stderr) or to the web client (via cgitb). | 49 # stderr) or to the web client (via cgitb). |
| 51 DEBUG_TO_CLIENT = False | 50 DEBUG_TO_CLIENT = False |
| 51 | |
| 52 # Return timing information to the client. | |
| 53 # Set TIMING to: | |
| 54 # "" - Do not sent timing info to client. (Default) | |
| 55 # "COMMENT" - Hide timing in html comment, view source to see it. | |
| 56 # "INLINE" - Display timing at bottom of web page | |
| 57 TIMING = "" | |
| 52 | 58 |
| 53 # This indicates where the Roundup tracker lives | 59 # This indicates where the Roundup tracker lives |
| 54 TRACKER_HOMES = { | 60 TRACKER_HOMES = { |
| 55 # 'example': '/path/to/example', | 61 # 'example': '/path/to/example', |
| 56 } | 62 } |
| 158 def main(out, err): | 164 def main(out, err): |
| 159 import os | 165 import os |
| 160 | 166 |
| 161 import roundup.cgi.client | 167 import roundup.cgi.client |
| 162 import roundup.instance | 168 import roundup.instance |
| 169 | |
| 170 if TIMING: | |
| 171 os.environ["CGI_SHOW_TIMING"] = TIMING | |
| 163 | 172 |
| 164 request = RequestWrapper(out) | 173 request = RequestWrapper(out) |
| 165 problem_header = roundup.cgi.client.are_header_values_safe(os.environ) | 174 problem_header = roundup.cgi.client.are_header_values_safe(os.environ) |
| 166 if problem_header: | 175 if problem_header: |
| 167 error_body = """<!DOCTYPE HTML> | 176 error_body = """<!DOCTYPE HTML> |
| 183 request.send_header('Content-Type', 'text/html') | 192 request.send_header('Content-Type', 'text/html') |
| 184 request.send_header('Content-Length', '%s' % len(error_body)) | 193 request.send_header('Content-Length', '%s' % len(error_body)) |
| 185 request.end_headers() | 194 request.end_headers() |
| 186 out.write(s2b(error_body)) | 195 out.write(s2b(error_body)) |
| 187 return | 196 return |
| 188 | |
| 189 | 197 |
| 190 path = os.environ.get('PATH_INFO', '/').split('/') | 198 path = os.environ.get('PATH_INFO', '/').split('/') |
| 191 request.path = os.environ.get('PATH_INFO', '/') | 199 request.path = os.environ.get('PATH_INFO', '/') |
| 192 tracker = path[1] | 200 tracker = path[1] |
| 193 os.environ['TRACKER_NAME'] = tracker | 201 os.environ['TRACKER_NAME'] = tracker |
