Mercurial > code > home > repos > light9
annotate bin/run_local.py @ 833:bdfdfea84510
colored logs
Ignore-this: 74b7fb320ebca032b2976da3d00e05ca
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Tue, 04 Jun 2013 23:51:57 +0000 |
parents | 41830567a8d0 |
children | f3364e9f5c03 |
rev | line source |
---|---|
209
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
1 # allows bin/* to work without installation |
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
2 |
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
3 # this should be turned off when the programs are installed |
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
4 |
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
5 import sys,os |
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
6 sys.path.insert(0,os.path.join(os.path.dirname(sys.argv[0]),"..")) |
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
7 |
306
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
8 import cgitb |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
9 from twisted.python.failure import Failure |
209
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
10 |
306
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
11 import Tkinter |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
12 def rce(self, exc, val, tb): |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
13 sys.stderr.write("Exception in Tkinter callback\n") |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
14 if True: |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
15 sys.excepthook(exc, val, tb) |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
16 else: |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
17 Failure(val, exc, tb).printDetailedTraceback() |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
18 Tkinter.Tk.report_callback_exception = rce |
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
19 |
833 | 20 import coloredlogs, logging, time |
21 log = logging.getLogger() | |
22 | |
23 class CSH(coloredlogs.ColoredStreamHandler): | |
24 def render_timestamp(self, created): | |
25 return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(created)) + ( | |
26 "%.3f" % (created % 1)).lstrip('0') | |
27 | |
28 def render_name(self, name): | |
29 return name | |
30 | |
31 log.addHandler(CSH(show_hostname=False, show_name=True)) | |
32 | |
306
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
33 cgitb.enable(format='txt') |