Moved on-demand code from esp.py to ESPonDemand.py

Still need to test failure scenarios