| 397 | | old_sys_stdout = sys.stdout |
|---|
| 398 | | |
|---|
| 399 | | import tractimevisualizerplugin |
|---|
| 400 | | if tractimevisualizerplugin.DEVELOPER_MODE: |
|---|
| 401 | | sys.stdout = StringIO.StringIO() |
|---|
| 402 | | else: |
|---|
| 403 | | sys.stdout = NullOut() |
|---|
| 404 | | try: |
|---|
| 405 | | req.send_response(200) |
|---|
| 406 | | req.send_header('Content-Type', "image/svg+xml") |
|---|
| 407 | | req.send_header('Last-Modified', trac.util.datefmt.http_date(time.time())) |
|---|
| 408 | | req.end_headers() |
|---|
| 409 | | |
|---|
| 410 | | if req.method != 'HEAD': |
|---|
| 411 | | db = plugin.env.get_db_cnx() |
|---|
| 412 | | args = req.args.copy() |
|---|
| 413 | | if not args.get('calc_fields'): |
|---|
| 414 | | args['calc_fields'] = plugin.env.config.get('timevisualizer','calc_fields','estimatedhours-totalhours') |
|---|
| 415 | | if not args.get('time_format'): |
|---|
| 416 | | args['time_format'] = plugin.env.config.get('timevisualizer','time_format', None) |
|---|
| 417 | | req.write(build_svg(db, args)) |
|---|
| 418 | | raise trac.web.RequestDone |
|---|
| 419 | | finally: |
|---|
| 420 | | log = sys.stdout |
|---|
| 421 | | sys.stdout = old_sys_stdout |
|---|
| 422 | | if isinstance(log, StringIO.StringIO): |
|---|
| 423 | | plugin.log.debug(log.getvalue()) |
|---|
| | 397 | req.send_response(200) |
|---|
| | 398 | req.send_header('Content-Type', "image/svg+xml") |
|---|
| | 399 | req.send_header('Last-Modified', trac.util.datefmt.http_date(time.time())) |
|---|
| | 400 | req.end_headers() |
|---|
| | 401 | |
|---|
| | 402 | if req.method != 'HEAD': |
|---|
| | 403 | db = plugin.env.get_db_cnx() |
|---|
| | 404 | args = req.args.copy() |
|---|
| | 405 | if not args.get('calc_fields'): |
|---|
| | 406 | args['calc_fields'] = plugin.env.config.get('timevisualizer','calc_fields','estimatedhours-totalhours') |
|---|
| | 407 | if not args.get('time_format'): |
|---|
| | 408 | args['time_format'] = plugin.env.config.get('timevisualizer','time_format', None) |
|---|
| | 409 | |
|---|
| | 410 | old_sys_stdout = sys.stdout |
|---|
| | 411 | import tractimevisualizerplugin |
|---|
| | 412 | if tractimevisualizerplugin.DEVELOPER_MODE: |
|---|
| | 413 | sys.stdout = StringIO.StringIO() |
|---|
| | 414 | else: |
|---|
| | 415 | sys.stdout = NullOut() |
|---|
| | 416 | |
|---|
| | 417 | svg = None |
|---|
| | 418 | try: |
|---|
| | 419 | svg = build_svg(db, args) |
|---|
| | 420 | finally: |
|---|
| | 421 | log = sys.stdout |
|---|
| | 422 | sys.stdout = old_sys_stdout |
|---|
| | 423 | if isinstance(log, StringIO.StringIO): |
|---|
| | 424 | plugin.log.debug(log.getvalue()) |
|---|
| | 425 | if svg: |
|---|
| | 426 | req.write(svg) |
|---|
| | 427 | raise trac.web.RequestDone |
|---|