예제 #1
0
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)
예제 #2
0
 def __init__(self, device, platform, version=None, **kwargs):
     self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'],
                                 kb_port=device['kb']['kb_tty'])
     self.kb_device_port = device['kb']['port']
     self.platform = platform
     self.version = version
     base_step.__init__(self, **kwargs)
예제 #3
0
 def __init__(self, device, platform="ECS27B", **kwargs):
     self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'],
                                 kb_port=device['kb']['kb_tty'])
     self.touch_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"],
         always_allow_port=device["relay"]["always_allow_port"],
         allow_ok_port=device["relay"]["allow_ok_port"],
     )
     self.kb_device_port = device['kb']['port']
     self.device = device
     self.allowed = False
     self.platform = platform
     base_step.__init__(self, **kwargs)
예제 #4
0
 def __init__(self, **kwargs):
     base_step.__init__(self, **kwargs)
     self.relay = Relayed_device(  # "RLY08B" or "URMC32"
         relay_type=kwargs["relay_type"],
         # COM port used for communication. Ex: "/dev/ttyACM0"
         relay_port=kwargs["relay_port"]
         if "relay_port" in kwargs else None,
         # number of the relay connected to POWER button
         power_port=kwargs["power_port"]
         if "power_port" in kwargs else None,
         # number of the relay connected to VOL UP button
         v_up_port=kwargs["v_up_port"] if "v_up_port" in kwargs else None,
         # number of the relay connected to VOL DOWN button
         v_down_port=kwargs["v_down_port"]
         if "v_down_port" in kwargs else None,
         # number of the relay used to cut VC+ of the USB cable connected to the device
         USB_VC_cut_port=kwargs["USB_VC_cut_port"]
         if "USB_VC_cut_port" in kwargs else None)
예제 #5
0
    def do(self):

        screen_log = local_steps.create_screen(screen_name=self.screen_name,
                                               with_log=True)()
        grep_for = [
            "Phone Flash Tool exited with code ",
            "Platform Flash Tool exited with code "
        ]
        pft_screen_command(serial=self.serial,
                           device=self.device,
                           screen_name=self.screen_name,
                           screen_log=screen_log,
                           flash_xml_path=self.flash_xml_path,
                           user_build=self.user_build,
                           user_signed=self.user_signed,
                           timeout=self.timeout,
                           grep_for=grep_for,
                           update=self.update)()

        if self.usb_debugging:
            iterations = 2
            for i in range(iterations):
                try:
                    local_steps.wait_for_adb(serial=self.serial, timeout=300)()
                    break
                except Exception, e:
                    print "{0}/{1} interation({2}): adb is not enabled on "\
                          "{3} after 300 seconds.".format(i + 1, iterations,
                                                          e.message, self.serial)
                    try:
                        my_relay = Relayed_device(
                            relay_port=self.device["relay"]["tty"],
                            power_port=self.device["relay"]["power_port"],
                            v_up_port=self.device["relay"]["v_up_port"],
                            v_down_port=self.device["relay"]["v_down_port"])
                        my_relay.relay_reboot()
                    except Exception, e:
                        print "Serial {0} has no relay connection: {1}".format(
                            self.serial, e.message)
                        raise e
예제 #6
0
    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
########################################################################
예제 #7
0
 def __init__(self, device, **kwargs):
     self.relay = Relayed_device(kb_relay_port=device['kb']['relay_tty'],
                                 kb_port=device['kb']['kb_tty'])
     self.kb_device_port = device['kb']['port']
     base_step.__init__(self, **kwargs)
예제 #8
0
 def do(self):
     cmd_header = "screen -x {0} -p0 -X stuff '".format(self.screen_name)
     enter = "\r'"
     local_steps.command(command="{0}{1}{2}".format(
         cmd_header, self.screen_command, enter))()
     if not self.user_build or self.user_signed or self.update:
         return
     waiting = 0
     unlock_grep = "\"oem\" \"unlock\"` command"
     print "{0}: Waiting unlock command".format(self.serial)
     while waiting < self.timeout / 8:
         cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format(
             self.screen_log, unlock_grep)
         stdout, stderr = self.local_connection.run_cmd(
             command=cat_grep_cmd)
         if unlock_grep in stdout:
             time.sleep(30)
             my_relay = Relayed_device(
                 relay_port=self.device["relay"]["tty"],
                 power_port=self.device["relay"]["power_port"],
                 v_up_port=self.device["relay"]["v_up_port"],
                 v_down_port=self.device["relay"]["v_down_port"])
             my_relay.press_volume_up()
             my_relay.press_power()
             my_relay.close()
             break
         waiting += 2
         time.sleep(2)
     unlock_grep = "\"oem\" \"unlock\"` failed"
     while waiting < 30:
         cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format(
             self.screen_log, unlock_grep)
         stdout, stderr = self.local_connection.run_cmd(
             command=cat_grep_cmd)
         if unlock_grep in stdout:
             print "{0}: Unlock command failed".format(self.serial)
             print "{0}: The device is not OEM enabled!!!!!".format(
                 self.serial)
             sys.exit(0)
         waiting += 2
         time.sleep(2)
     waiting = 0
     lock_grep = "\"oem\" \"lock\"` command"
     print "{0}: Waiting lock command".format(self.serial)
     while waiting < self.timeout * 6 / 8:
         cat_grep_cmd = "tail -n 10 {0} | grep '{1}'".format(
             self.screen_log, lock_grep)
         stdout, stderr = self.local_connection.run_cmd(
             command=cat_grep_cmd)
         if lock_grep in stdout:
             time.sleep(30)
             my_relay = Relayed_device(
                 relay_port=self.device["relay"]["tty"],
                 power_port=self.device["relay"]["power_port"],
                 v_up_port=self.device["relay"]["v_up_port"],
                 v_down_port=self.device["relay"]["v_down_port"])
             my_relay.press_volume_up()
             my_relay.press_power()
             my_relay.close()
             break
         waiting += 2
         time.sleep(2)