Mercurial > code > home > repos > light9
annotate bin/run_local.py @ 2019:a6045f11198d
don't show a misleading TL cursor when we're viewing a song that's not the playing one
Ignore-this: 33928b4331aa09f2191b6d45e4e163a
author | drewp@bigasterisk.com |
---|---|
date | Mon, 10 Jun 2019 23:22:06 +0000 |
parents | 7088d60fde7e |
children | aeafe7d0b033 |
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 |
1697
5c04a54df635
fix startup (this might be breaking mypy)
Drew Perttula <drewp@bigasterisk.com>
parents:
1512
diff
changeset
|
6 |
1858 | 7 |
1697
5c04a54df635
fix startup (this might be breaking mypy)
Drew Perttula <drewp@bigasterisk.com>
parents:
1512
diff
changeset
|
8 def fixSysPath(): |
1858 | 9 root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), |
10 '..')) + '/' | |
1697
5c04a54df635
fix startup (this might be breaking mypy)
Drew Perttula <drewp@bigasterisk.com>
parents:
1512
diff
changeset
|
11 sys.path = [ |
5c04a54df635
fix startup (this might be breaking mypy)
Drew Perttula <drewp@bigasterisk.com>
parents:
1512
diff
changeset
|
12 root, |
1861 | 13 root + 'env/lib/python3.7', |
14 root + 'env/lib/python3.7/plat-x86_64-linux-gnu', | |
15 root + 'env/lib/python3.7/lib-tk', | |
16 root + 'env/lib/python3.7/lib-old', | |
17 root + 'env/lib/python3.7/lib-dynload', | |
18 '/usr/lib/python3/dist-packages/', | |
19 '/usr/lib/python3.7', | |
1865
1aa91a31c0e2
reformat some missed files
Drew Perttula <drewp@bigasterisk.com>
parents:
1861
diff
changeset
|
20 # '/usr/lib/python3.7/plat-x86_64-linux-gnu', |
1aa91a31c0e2
reformat some missed files
Drew Perttula <drewp@bigasterisk.com>
parents:
1861
diff
changeset
|
21 # '/usr/lib/python3.7/lib-tk', |
1aa91a31c0e2
reformat some missed files
Drew Perttula <drewp@bigasterisk.com>
parents:
1861
diff
changeset
|
22 # root + 'env/local/lib/python3.7/site-packages', |
1aa91a31c0e2
reformat some missed files
Drew Perttula <drewp@bigasterisk.com>
parents:
1861
diff
changeset
|
23 # root + 'env/local/lib/python3.7/site-packages/gtk-2.0', |
1861 | 24 root + 'env/lib/python3.7/site-packages', |
1865
1aa91a31c0e2
reformat some missed files
Drew Perttula <drewp@bigasterisk.com>
parents:
1861
diff
changeset
|
25 # root + 'env/lib/python3.7/site-packages/gtk-2.0', |
1697
5c04a54df635
fix startup (this might be breaking mypy)
Drew Perttula <drewp@bigasterisk.com>
parents:
1512
diff
changeset
|
26 ] |
5c04a54df635
fix startup (this might be breaking mypy)
Drew Perttula <drewp@bigasterisk.com>
parents:
1512
diff
changeset
|
27 |
1858 | 28 |
1697
5c04a54df635
fix startup (this might be breaking mypy)
Drew Perttula <drewp@bigasterisk.com>
parents:
1512
diff
changeset
|
29 fixSysPath() |
209
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
30 |
306
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
31 from twisted.python.failure import Failure |
209
1a84c5e83d3e
dmxserver and subcomposer work in new layout
drewp@bigasterisk.com
parents:
diff
changeset
|
32 |
1239 | 33 try: |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
34 import tkinter |
1239 | 35 except ImportError: |
36 pass | |
37 else: | |
1858 | 38 |
1239 | 39 def rce(self, exc, val, tb): |
40 sys.stderr.write("Exception in Tkinter callback\n") | |
41 if True: | |
42 sys.excepthook(exc, val, tb) | |
43 else: | |
44 Failure(val, exc, tb).printDetailedTraceback() | |
1858 | 45 |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
46 tkinter.Tk.report_callback_exception = rce |
306
41830567a8d0
bigger traceback printouts for all tools
Drew Perttula <drewp@bigasterisk.com>
parents:
209
diff
changeset
|
47 |
1087
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
48 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
|
49 try: |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
50 import faulthandler |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
51 faulthandler.enable() |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
52 except ImportError: |
1f877950ad28
new picamserve for raspberry pi camera -> http, especially with crop control
Drew Perttula <drewp@bigasterisk.com>
parents:
1072
diff
changeset
|
53 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
|
54 |
1952
7088d60fde7e
leave cool ipython exc handler in run_local.py
Drew Perttula <drewp@bigasterisk.com>
parents:
1865
diff
changeset
|
55 if 0: |
7088d60fde7e
leave cool ipython exc handler in run_local.py
Drew Perttula <drewp@bigasterisk.com>
parents:
1865
diff
changeset
|
56 from IPython.core import ultratb |
7088d60fde7e
leave cool ipython exc handler in run_local.py
Drew Perttula <drewp@bigasterisk.com>
parents:
1865
diff
changeset
|
57 sys.excepthook = ultratb.FormattedTB(mode='Verbose', |
7088d60fde7e
leave cool ipython exc handler in run_local.py
Drew Perttula <drewp@bigasterisk.com>
parents:
1865
diff
changeset
|
58 color_scheme='Linux', |
7088d60fde7e
leave cool ipython exc handler in run_local.py
Drew Perttula <drewp@bigasterisk.com>
parents:
1865
diff
changeset
|
59 call_pdb=1) |
7088d60fde7e
leave cool ipython exc handler in run_local.py
Drew Perttula <drewp@bigasterisk.com>
parents:
1865
diff
changeset
|
60 |
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
|
61 progName = sys.argv[0].split('/')[-1] |
1858 | 62 log = logging.getLogger() # this has to get the root logger |
63 log.name = progName # but we can rename it for clarity | |
64 | |
1221
3c78608a216a
don't break all non-root log channels
Drew Perttula <drewp@bigasterisk.com>
parents:
1215
diff
changeset
|
65 |
1512 | 66 class FractionTimeFilter(logging.Filter): |
1858 | 67 |
1512 | 68 def filter(self, record): |
69 record.fractionTime = ( | |
70 time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(record.created)) + | |
71 ("%.3f" % (record.created % 1)).lstrip('0')) | |
72 # Don't filter the record. | |
73 return 1 | |
858
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
74 |
1858 | 75 |
1512 | 76 coloredlogs.install( |
77 level='DEBUG', | |
78 fmt='%(fractionTime)s %(name)s[%(process)d] %(levelname)s %(message)s') | |
79 logging.getLogger().handlers[0].addFilter(FractionTimeFilter()) | |
858
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
80 |
1f93e5d19f8a
merge run_local again
Drew Perttula <drewp@bigasterisk.com>
parents:
837
diff
changeset
|
81 |
933 | 82 def setTerminalTitle(s): |
1425 | 83 if os.environ.get('TERM', '') in ['xterm', 'rxvt', 'rxvt-unicode-256color']: |
1859
f066d6e874db
2to3 with these fixers: all idioms set_literal
drewp@bigasterisk.com
parents:
1858
diff
changeset
|
84 print("\033]0;%s\007" % s) # not escaped/protected correctly |
1858 | 85 |
874
167a61d3cfbf
subcomposer put local subs into the graph with a type edge.
Drew Perttula <drewp@bigasterisk.com>
parents:
873
diff
changeset
|
86 |
1215 | 87 if 'listsongs' not in sys.argv[0] and 'homepageConfig' not in sys.argv[0]: |
1858 | 88 setTerminalTitle( |
89 '[%s] %s' % | |
90 (socket.gethostname(), ' '.join(sys.argv).replace('bin/', ''))) | |
934 | 91 |
92 # see http://www.youtube.com/watch?v=3cIOT9kM--g for commands that make | |
93 # profiles and set background images |