Files
@ 40cc863d2b63
Branch filter:
Location: light9/bin/run_local.py - annotation
40cc863d2b63
2.5 KiB
text/x-python
start py3 and other dep fixes
Ignore-this: f43a792107c9640a01d35c080b0ee87d
Ignore-this: f43a792107c9640a01d35c080b0ee87d
1a84c5e83d3e 1a84c5e83d3e 1a84c5e83d3e 1a84c5e83d3e f66586649ae3 5c04a54df635 7772cc48e016 5c04a54df635 7772cc48e016 7772cc48e016 5c04a54df635 5c04a54df635 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 40cc863d2b63 5c04a54df635 5c04a54df635 7772cc48e016 5c04a54df635 1a84c5e83d3e 41830567a8d0 1a84c5e83d3e 0025b04a1c0a f066d6e874db 0025b04a1c0a 0025b04a1c0a 0025b04a1c0a 7772cc48e016 0025b04a1c0a 0025b04a1c0a 0025b04a1c0a 0025b04a1c0a 0025b04a1c0a 0025b04a1c0a 7772cc48e016 f066d6e874db 41830567a8d0 1f877950ad28 1f877950ad28 1f877950ad28 1f877950ad28 1f877950ad28 1f877950ad28 8e8d778f9e21 8e8d778f9e21 7772cc48e016 7772cc48e016 7772cc48e016 3c78608a216a 3693b226b0b8 7772cc48e016 3693b226b0b8 3693b226b0b8 3693b226b0b8 3693b226b0b8 3693b226b0b8 3693b226b0b8 1f93e5d19f8a 7772cc48e016 3693b226b0b8 3693b226b0b8 3693b226b0b8 3693b226b0b8 1f93e5d19f8a 1f93e5d19f8a 8435e3ee1ec2 8796803a1b45 f066d6e874db 7772cc48e016 167a61d3cfbf 0d295af23c4b 7772cc48e016 7772cc48e016 7772cc48e016 f92550d33004 f92550d33004 f92550d33004 | # allows bin/* to work without installation
# this should be turned off when the programs are installed
import sys, os, socket
def fixSysPath():
root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]),
'..')) + '/'
sys.path = [
root,
root + 'env/lib/python3.7',
root + 'env/lib/python3.7/plat-x86_64-linux-gnu',
root + 'env/lib/python3.7/lib-tk',
root + 'env/lib/python3.7/lib-old',
root + 'env/lib/python3.7/lib-dynload',
'/usr/lib/python3/dist-packages/',
'/usr/lib/python3.7',
# '/usr/lib/python3.7/plat-x86_64-linux-gnu',
# '/usr/lib/python3.7/lib-tk',
# root + 'env/local/lib/python3.7/site-packages',
# root + 'env/local/lib/python3.7/site-packages/gtk-2.0',
root + 'env/lib/python3.7/site-packages',
# root + 'env/lib/python3.7/site-packages/gtk-2.0',
]
fixSysPath()
from twisted.python.failure import Failure
try:
import tkinter
except ImportError:
pass
else:
def rce(self, exc, val, tb):
sys.stderr.write("Exception in Tkinter callback\n")
if True:
sys.excepthook(exc, val, tb)
else:
Failure(val, exc, tb).printDetailedTraceback()
tkinter.Tk.report_callback_exception = rce
import coloredlogs, logging, time
try:
import faulthandler
faulthandler.enable()
except ImportError:
pass
progName = sys.argv[0].split('/')[-1]
log = logging.getLogger() # this has to get the root logger
log.name = progName # but we can rename it for clarity
class FractionTimeFilter(logging.Filter):
def filter(self, record):
record.fractionTime = (
time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(record.created)) +
("%.3f" % (record.created % 1)).lstrip('0'))
# Don't filter the record.
return 1
coloredlogs.install(
level='DEBUG',
fmt='%(fractionTime)s %(name)s[%(process)d] %(levelname)s %(message)s')
logging.getLogger().handlers[0].addFilter(FractionTimeFilter())
def setTerminalTitle(s):
if os.environ.get('TERM', '') in ['xterm', 'rxvt', 'rxvt-unicode-256color']:
print("\033]0;%s\007" % s) # not escaped/protected correctly
if 'listsongs' not in sys.argv[0] and 'homepageConfig' not in sys.argv[0]:
setTerminalTitle(
'[%s] %s' %
(socket.gethostname(), ' '.join(sys.argv).replace('bin/', '')))
# see http://www.youtube.com/watch?v=3cIOT9kM--g for commands that make
# profiles and set background images
|