2021-02-05 09:30:43 +00:00
|
|
|
#!/usr/bin/env python3
|
2021-01-14 18:56:45 +00:00
|
|
|
|
|
|
|
import atexit, serial, os, struct, code, traceback, readline, rlcompleter
|
|
|
|
from proxy import *
|
|
|
|
import __main__
|
|
|
|
import builtins
|
2021-05-01 06:11:23 +00:00
|
|
|
from proxyutils import *
|
2021-05-01 06:13:29 +00:00
|
|
|
from utils import *
|
2021-01-14 18:56:45 +00:00
|
|
|
|
|
|
|
class HistoryConsole(code.InteractiveConsole):
|
|
|
|
def __init__(self, locals=None, filename="<console>",
|
|
|
|
histfile=os.path.expanduser("~/.m1n1-history")):
|
|
|
|
code.InteractiveConsole.__init__(self, locals, filename)
|
|
|
|
self.init_history(histfile)
|
|
|
|
|
|
|
|
def init_history(self, histfile):
|
|
|
|
readline.parse_and_bind("tab: complete")
|
|
|
|
if hasattr(readline, "read_history_file"):
|
|
|
|
try:
|
|
|
|
readline.read_history_file(histfile)
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
atexit.register(self.save_history, histfile)
|
|
|
|
|
|
|
|
def save_history(self, histfile):
|
|
|
|
readline.set_history_length(1000)
|
|
|
|
readline.write_history_file(histfile)
|
|
|
|
|
|
|
|
def showtraceback(self):
|
|
|
|
type, value, tb = sys.exc_info()
|
|
|
|
traceback.print_exception(type, value, tb)
|
|
|
|
|
|
|
|
saved_display = sys.displayhook
|
|
|
|
|
|
|
|
def display(val):
|
2021-01-16 15:50:13 +00:00
|
|
|
global saved_display, mon
|
|
|
|
mon.poll()
|
2021-01-14 18:56:45 +00:00
|
|
|
if isinstance(val, int) or isinstance(val, int):
|
|
|
|
builtins._ = val
|
|
|
|
print(hex(val))
|
|
|
|
else:
|
|
|
|
saved_display(val)
|
|
|
|
|
|
|
|
sys.displayhook = display
|
|
|
|
|
|
|
|
# convenience
|
|
|
|
h = hex
|
|
|
|
|
2021-01-16 15:50:13 +00:00
|
|
|
from setup import *
|
2021-01-14 18:56:45 +00:00
|
|
|
|
|
|
|
locals = __main__.__dict__
|
|
|
|
|
|
|
|
for attr in dir(iface):
|
|
|
|
locals[attr] = getattr(iface,attr)
|
2021-01-16 15:50:13 +00:00
|
|
|
for attr in dir(p):
|
|
|
|
locals[attr] = getattr(p,attr)
|
|
|
|
for attr in dir(u):
|
|
|
|
locals[attr] = getattr(u,attr)
|
2021-01-14 18:56:45 +00:00
|
|
|
del attr
|
|
|
|
|
|
|
|
from tgtypes import *
|
|
|
|
|
|
|
|
HistoryConsole(locals).interact("Have fun!")
|
|
|
|
|