Mercurial > code > home > repos > light9
annotate bin/run_local.py @ 1608:faa62d5e84d8
colorpick crosshairs and chrome workarounds
Ignore-this: adb06d516e5709c2e0ddc9e7b5e8006e
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 05 Jun 2017 08:25:28 +0000 |
parents | 3693b226b0b8 |
children | 5c04a54df635 |
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 |
1156
f66586649ae3
show more process info in terminal title
drewp@bigasterisk.com
parents:
1155
diff
changeset
|
5 import sys, os, socket |
209
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 from twisted.python.failure import Failure |
209
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
9 |
1239 | 10 try: |
11 import Tkinter | |
12 except ImportError: | |
13 pass | |
14 else: | |
15 def rce(self, exc, val, tb): | |
16 sys.stderr.write("Exception in Tkinter callback\n") | |
17 if True: | |
18 sys.excepthook(exc, val, tb) | |
19 else: | |
20 Failure(val, exc, tb).printDetailedTraceback() | |
21 Tkinter.Tk.report_callback_exception = rce | |
306
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
22 |
1087
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
23 import coloredlogs, logging, time |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
24 try: |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
25 import faulthandler |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
26 faulthandler.enable() |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
27 except ImportError: |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
28 pass |
1210
8e8d778f9e21
use program name instead of 'root' for logger channel, so it's faster to see what a terminal is running
Drew Perttula <drewp@bigasterisk.com>
parents:
1156
diff
changeset
|
29 |
8e8d778f9e21
use program name instead of 'root' for logger channel, so it's faster to see what a terminal is running
Drew Perttula <drewp@bigasterisk.com>
parents:
1156
diff
changeset
|
30 progName = sys.argv[0].split('/')[-1] |
1221
3c78608a216a
don't break all non-root log channels
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
31 log = logging.getLogger() # this has to get the root logger |
3c78608a216a
don't break all non-root log channels
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
32 log.name = progName # but we can rename it for clarity |
3c78608a216a
don't break all non-root log channels
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
33 |
1512 | 34 class FractionTimeFilter(logging.Filter): |
35 def filter(self, record): | |
36 record.fractionTime = ( | |
37 time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(record.created)) + | |
38 ("%.3f" % (record.created % 1)).lstrip('0')) | |
39 # Don't filter the record. | |
40 return 1 | |
858
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
41 |
1512 | 42 coloredlogs.install( |
43 level='DEBUG', | |
44 fmt='%(fractionTime)s %(name)s[%(process)d] %(levelname)s %(message)s') | |
45 logging.getLogger().handlers[0].addFilter(FractionTimeFilter()) | |
858
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
46 |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
47 |
933 | 48 def setTerminalTitle(s): |
1425 | 49 if os.environ.get('TERM', '') in ['xterm', 'rxvt', 'rxvt-unicode-256color']: |
933 | 50 print "\033]0;%s\007" % s # not escaped/protected correctly |
874
167a61d3cfbf
subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents:
873
diff
changeset
|
51 |
1215 | 52 if 'listsongs' not in sys.argv[0] and 'homepageConfig' not in sys.argv[0]: |
1425 | 53 setTerminalTitle('[%s] %s' % (socket.gethostname(), ' '.join(sys.argv).replace('bin/', ''))) |
934 | 54 |
55 # see http://www.youtube.com/watch?v=3cIOT9kM--g for commands that make | |
56 # profiles and set background images |