pyterm: make formatting string configurable
pyterm: handle TCP connection errors