I have a long script that runs several GPIO devices using both SMBus and pigpio. It starts a thread to cycle through a series of screens on an OLED display, and then connects to Paho MQTT, and keeps track of events with logging for later debugging.
There is a 'master program' called mybox.py which then uses the much larger script via:
from BIG import Box
box = Box('my box', use_WiFi=True)
box.new_OLEDi2c('my oled')
# box.start_MQTT()
from IDLE:
When I run mybox.py with IDLE everything works as planned. It spews out messages and then stops with the familliar >>>
I can then type box.start_MQTT() in IDLE and that will happen. I can continue interacting with the Box object through IDLE as long as I like.
from Terminal:
When I open a terminal and type python mybox.py it starts the same way, but then I loose the ability to interact via the terminal. If I type, it is echoed to the screen, but it doesn't go anywhere. Also cursor characters are echoed as ^[[A, ^[[B, ^[[C, ^[[D,
Question: I'm not a developer and I'm learning to swim here by trial and error. Is there some way to get the terminal interaction to work the same easy way as I'm able to do using IDLE?
Is there something about this behavior that sounds familliar? In the past I've been able to use the terminal the way I'd like to without problem, but I wonder if the terminal is being set to a different mode by my script somehow without me knowing about it? For example, I recently found out that typing exit in iTerm returns big red broken pipe banner. Maybe my output is causing the terminal to change state?
GOOD: copy/paste from IDLE:
INFO 2018-12-12 10:40:52 initiate OLEDi2c("my oled")
OLED initiated in 0.065995 seconds
INFO 2018-12-12 10:40:52 show_image OLEDi2c("my oled")
showimage opened size w0 h0=(720, 405)
INFO 2018-12-12 10:40:52 show_image OLEDi2c("my oled")
showimage hscale <= wscale resize size=(113, 64)
INFO 2018-12-12 10:40:52 show_image OLEDi2c("my oled")
showimage conversion_method "threshold"
Thread me!
keepgoing.isSet(): True
Hey!! keepgoing: <threading._Event object at 0x72d279d0>
dwell_time: None
self.dwell_time: 2
>>>
>>> box.start_MQTT()
trying to connect with MQTT:
pingable is: True
('On Log: ', 'Sending CONNECT (u0, p0, wr0, wq0, wf0, c1, k60) client_id=Luke, I am your client')
connect status: 0
('Disconnect code: ', 0)
loop_start status: ('On Log: ', 'Received CONNACK (0, 0)')
None('Connect code: ', 0)
BAD: copy/paste from Terminal:
INFO 2018-12-12 10:45:47 initiate OLEDi2c("my oled")
OLED initiated in 0.011983 seconds
INFO 2018-12-12 10:45:48 show_image OLEDi2c("my oled")
showimage opened size w0 h0=(720, 405)
INFO 2018-12-12 10:45:48 show_image OLEDi2c("my oled")
showimage hscale <= wscale resize size=(113, 64)
INFO 2018-12-12 10:45:48 show_image OLEDi2c("my oled")
showimage conversion_method "threshold"
Thread me!
keepgoing.isSet(): True
Hey!! keepgoing: <threading._Event object at 0x73766b70>
dwell_time: None
self.dwell_time: 2
asdf
^[[A^[[A^[[A^[[A^[[A^[[B^[[B^[[B^[[B^[[D^[[C^[[D^[[A('On Log: ', 'Sending PINGREQ')
python mybox.py ¬e that little&on the end of the command.boxmethods. I am sure I can use your suggestion in the future though, thank you!