def prepare_for_next_run(suite): devices = [device for device in all_devices] print "Start preparing for the next {0} run".format(suite.upper()) if len(devices) > 0: for device in devices: serial = device["serial"] print "Prepare device {0} for next build.".format(device) print "Will try to use adb connection to shutdown/put the device into sleep mode" if local_utils.has_adb_serial(serial = serial): if shutdown_to_charge: print "[ {0} ]: Shutdown device to charge".format(serial) local_steps.command(command = "adb -s {0} shell reboot -p".format(serial))() time.sleep(5) print "[ {0} ]: Shutdown - Done!".format(serial) else: print "[ {0} ]: Put device into sleep mode".format(serial) adb_steps.put_device_into_sleep_mode(serial = serial)() print "[ {0} ]: Sleep - Done!".format(serial) else: print "[ {0} ]: does not have adb connection!!!".format(serial) print "[ {0} ]: Try to use relay to shutdown the devices".format(serial) try: my_relay = Relayed_device(relay_port = device["relay"]["tty"], power_port = device["relay"]["power_port"], v_up_port = device["relay"]["v_up_port"], v_down_port = device["relay"]["v_down_port"]) my_relay.power_on() my_relay.power_off() my_relay.close() except Exception, e: print "{0} devivice has no relay - {1}!!!".format(serial, e.message)
s = d["serial"] print "Prepare device " + str(s) + " for next build." print "Will try to use adb connection to shutdown/put to sleep the device" if local_utils.has_adb_serial(serial=s): adb_steps.enable_uiautomator_service(serial=s, timeout=120)() if shutdown_to_charge: print str(s) + ": Shutdown device to charge" local_steps.command(command="adb -s " + str(s) + " shell reboot -p")() time.sleep(5) print str(s) + ": Shutdown - Done!" else: print str(s) + ": Put device to sleep" adb_steps.put_device_into_sleep_mode(serial=s)() print str(s) + ": Sleep - Done!" else: print str(s) + ": does not have adb connection!!!" print str(s) + ": Try to use relay to shutdown the devices" try: my_relay = Relayed_device(relay_port=d["relay"]["tty"], power_port=d["relay"]["power_port"], v_up_port=d["relay"]["v_up_port"], v_down_port=d["relay"]["v_down_port"]) my_relay.power_on() my_relay.power_off() my_relay.close() except Exception, e: print "NO relay!!!" print e.message ########################################################################