Mercurial > code > home > repos > light9
annotate bin/run_local.py @ 1336:2d77dc9436c3
music drives cursor
Ignore-this: ffa7a9a94084bb8feab6d04e888fb3f6
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sat, 04 Jun 2016 21:23:58 +0000 |
parents | 0025b04a1c0a |
children | 8796803a1b45 |
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 |
858
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
34 |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
35 class CSH(coloredlogs.ColoredStreamHandler): |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
36 def render_timestamp(self, created): |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
37 return time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(created)) + ( |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
38 "%.3f" % (created % 1)).lstrip('0') |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
39 |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
40 def render_name(self, name): |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
41 return name |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
42 |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
43 log.addHandler(CSH(show_hostname=False, show_name=True)) |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
44 |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
45 |
933 | 46 def setTerminalTitle(s): |
1098
770b0d0005fc
command shell title support on TERM=rxvt too
Drew Perttula <drewp@bigasterisk.com>
parents:
1087
diff
changeset
|
47 if os.environ.get('TERM', '') in ['xterm', 'rxvt']: |
933 | 48 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
|
49 |
1215 | 50 if 'listsongs' not in sys.argv[0] and 'homepageConfig' not in sys.argv[0]: |
1156
f66586649ae3
show more process info in terminal title
drewp@bigasterisk.com
parents:
1155
diff
changeset
|
51 setTerminalTitle('[%s] %s' % (socket.gethostname(), ' '.join(sys.argv))) |
934 | 52 |
53 # see http://www.youtube.com/watch?v=3cIOT9kM--g for commands that make | |
54 # profiles and set background images |