import subprocess def attached_devices(): device=[] formate = ["deviceName","platformVersion"] n = subprocess.Popen("adb devices", shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.readlines() for i in n: l = [] t = i.decode().split("\t") if len(t) >= 2: l.append(t[0]) s = "adb -s %s shell getprop ro.build.version.release"%t[0] v = subprocess.Popen(s, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.readlines() for i in v: a = i.decode().split("\n") l.append(a[0].replace("\r",'')) d = dict(zip(formate,l)) # device.append(d) return d
json_path = os.path.dirname('D:\\trunk\\cases\\citymeia965\\Resources\\basic\\') + "\element.yaml" jsdate = attached_devices() # print(jsdate) jsdate['appActivity']='com.android.jsbcmasterapp.Welcome' # print(jsdate) with open(json_path, "w", encoding="utf-8") as f: yaml.dump(jsdate, f, Dumper=yaml.Dumper)
def init_yaml(): yamlpath = os.path.dirname(__file__) + "/element.yaml" #print(yamlpath) with open(yamlpath, encoding='utf-8') as f: x = yaml.load(f,Loader=yaml.Loader) return x
x = init_yaml()
capailities = { 'platformName': 'Android', 'deviceName': x['deviceName'], 'platformVersion': x['platformVersion'],