Пример #1
0
def _get_dimension_raw_noexcept(path, device_id=None):
    if device_id:
        shell_adb = Popen(_("{} -s {} shell wm size".format(path, device_id)),
                          stdout=PIPE,
                          stderr=PIPE)
    else:
        shell_adb = Popen(_("{} shell wm size".format(path)),
                          stdout=PIPE,
                          stderr=PIPE)
    return shell_adb
Пример #2
0
 def shell(path, command, device_id=None):
     if device_id:
         po = Popen(_("{} -s {} shell {}".format(path, device_id, command)),
                    stdout=PIPE,
                    stderr=PIPE)
     else:
         po = Popen(_("{} shell {}".format(path, command)),
                    stdout=PIPE,
                    stderr=PIPE)
     return po
Пример #3
0
 def command(path, command, device_id=None):
     if device_id:
         adb_shell_output = Popen(_("{} -s {} {}".format(
             path, device_id, command)),
                                  stdout=PIPE,
                                  stderr=PIPE)
     else:
         adb_shell_output = Popen(_("{} {}".format(path, command)),
                                  stdout=PIPE,
                                  stderr=PIPE)
     return adb_shell_output
Пример #4
0
 def shell_input(path, command, device_id=None):
     if device_id:
         Popen(
             _("{} -s {} shell input {}".format(path, device_id, command)),
             stdout=PIPE,
             stderr=PIPE,
         )
     else:
         Popen(
             _("{} shell input {}".format(path, command)),
             stdout=PIPE,
             stderr=PIPE,
         )
Пример #5
0
 def start(path, args):
     Popen(
         _("{} {}".format(path, args)),
         stdout=PIPE,
         stderr=PIPE,
     )
     return True
Пример #6
0
 def devices_detailed(increment=''):
     if increment is None:
         raise FileNotFoundError(
             "guiscrcpy couldn't find adb. "
             "Please specify path to adb in configuration filename")
     proc = Popen(_(increment + " devices -l"), stdout=PIPE)
     output = [[y.strip() for y in x.split()]
               for x in decode_process(proc)[1:]][:-1]
     devices_found = []
     for device in output:
         # https://github.com/srevinsaju/guiscrcpy/issues/117
         if 'udev' in device and 'permission' in device:
             # This is an error with some linux and Windows OSes
             # This happens because the udev is not configured
             # and linux adb does not have access to reading the device
             # the status hence should be 'no_permission'
             status = 'no_permission'
         else:
             status = device[1]
         description = {
             'identifier': device[0],
             'status': status,
             'product': get(device, 2, ':').split(':')[-1],
             'model': get(device, 3, ':').split(':')[-1],
             'device': get(device, 4, ':').split(':')[-1],
             'transport_id': get(device, 5, ':').split(':')[-1]
         }
         devices_found.append(description)
     logging.debug("ADB: {}".format(devices_found))
     return devices_found
Пример #7
0
 def command(path, command):
     shellx = Popen(
         _("{} {}".format(path, command)),
         stdout=PIPE,
         stderr=PIPE,
     )
     return shellx
Пример #8
0
 def shell(path, command):
     shellx = Popen(
         _("{} shell {}".format(path, command)),
         stdout=PIPE,
         stderr=PIPE,
     )
     return True
Пример #9
0
 def devices(increment=''):
     if increment is None:
         raise FileNotFoundError(
             "guiscrcpy couldn't find adb. Please specify path to adb in configuration file")
     proc = Popen(_(increment + " devices"), stdout=PIPE)
     output = decode_process(proc)[1].split('\t')
     logging.debug("ADB: {}".format(output))
     return output
Пример #10
0
 def tcpip(path, port=5555, identifier=""):
     if identifier:
         command = "{path} -s {identifier} -d tcpip {port}"
     else:
         command = "{path} -d tcpip {port}"
     exit_code = call(_(
         command.format(path=path, port=port, identifier=identifier)),
                      stdout=PIPE,
                      stderr=PIPE)
     return exit_code
Пример #11
0
 def get_dimensions(path, device_id=None):
     if device_id:
         shell_adb = Popen(_("{} -s {} shell wm size".format(
             path, device_id)),
                           stdout=PIPE,
                           stderr=PIPE)
     else:
         shell_adb = Popen(_("{} shell wm size".format(path)),
                           stdout=PIPE,
                           stderr=PIPE)
     raw_dimensions = shell_adb.stdout.read().decode().strip('\n')
     for i in ['Override size', 'Physical size']:
         if i in raw_dimensions:
             out = raw_dimensions[raw_dimensions.find(i):]
             out_decoded = out.split(':')[1].strip()
             dimension_values = out_decoded.split('x')
             return dimension_values
     else:
         logging.error(
             "AndroidDeviceError: adb shell wm size did not return "
             "'Physical Size' or 'Override Size'")
         return False
Пример #12
0
 def shell_input(path, command):
     shellx = Popen(
         _("{} shell input {}".format(path, command)),
         stdout=PIPE,
         stderr=PIPE,
     )