How to use sdk_version method in Airtest

Best Python code snippet using Airtest

build_apis_db.py

Source:build_apis_db.py Github

copy

Full Screen

...34 :param framework_folder: public路径35 """36 table_name = db_names['SET_A']37 # 先清除已有版本的api38 api_dbs.delete_api_by_sdk_version(table_name, sdk_version)39 framework_dump_header_apis = api_utils.frame_work_dump_apis(sdk_version, framework_folder)40 # [{'class':'','methods':'','type':''},{},{}]41 return api_dbs.insert_apis(table_name, framework_dump_header_apis)42def rebuild_framework_header_api(sdk_version, framework_folder):43 """44 public-framework-.h-apis45 SET_B46 """47 table_name = db_names['SET_B']48 api_dbs.delete_api_by_sdk_version(table_name, sdk_version)49 framework_header_apis = api_utils.framework_header_apis(sdk_version, framework_folder)50 # [{'class':'','methods':'','type':''},{},{}]51 return api_dbs.insert_apis(table_name, framework_header_apis)52def rebuild_document_api(sdk_version, docset):53 """54 document api55 SET_C56 """57 table_name = db_names['SET_C']58 api_dbs.delete_api_by_sdk_version(table_name, sdk_version)59 document_apis = api_utils.document_apis(sdk_version, docset)60 return api_dbs.insert_apis(table_name, document_apis)61def rebuild_private_dump_framework_api(sdk_version, framework_folder):62 """63 private_framework_dump_apis64 SET_E65 """66 table_name = db_names['SET_E']67 api_dbs.delete_api_by_sdk_version(table_name, sdk_version)68 private_framework_dump_apis = api_utils.deduplication_api_list(api_utils.private_framework_dump_apis(sdk_version, framework_folder))69 return api_dbs.insert_apis(table_name, private_framework_dump_apis)70# 组合获取所有的私有API库71def rebuild_private_apis(sdk_version):72 table_name_D = db_names['SET_D'] # 最终的私有API73 table_name_F = db_names['SET_F'] # public 下过滤出来的私有API74 # flush table datas75 api_dbs.delete_api_by_sdk_version(table_name_D, sdk_version)76 api_dbs.delete_api_by_sdk_version(table_name_F, sdk_version)77 # public下私有API78 framework_dump_private_apis = []79 # public下所有API80 framework_dump_apis = api_dbs.get_publick_framework_dump_apis(sdk_version)81 public_count = 082 private_count = 083 __count = 084 for api in framework_dump_apis:85 # print("正在从公有API库中提取私有API-->%s"%api)86 # 方法以 '_'下划线开始直接定义为私有API87 if api['api_name'] and api['api_name'][0:1] == "_":88 __count += 189 framework_dump_private_apis.append(api)90 continue...

Full Screen

Full Screen

find_mac_sdk.py

Source:find_mac_sdk.py Github

copy

Full Screen

1#!/usr/bin/env python2# coding: utf-83# Copyright 2012 The Chromium Authors. All rights reserved.4# Use of this source code is governed by a BSD-style license that can be5# found in the LICENSE file.6from __future__ import print_function7import argparse8import distutils.version9import os10import re11import subprocess12import sys13import textwrap14def _AsVersion(string):15 return distutils.version.StrictVersion(string)16def _RunXCRun(args, sdk=None):17 xcrun_args = ['xcrun']18 if sdk is not None:19 xcrun_args.extend(['--sdk', sdk])20 xcrun_args.extend(args)21 return subprocess.check_output(xcrun_args).decode('utf-8').rstrip()22def _SDKPath(sdk=None):23 return _RunXCRun(['--show-sdk-path'], sdk)24def _SDKVersion(sdk=None):25 return _AsVersion(_RunXCRun(['--show-sdk-version'], sdk))26class DidNotMeetCriteria(Exception):27 pass28def _FindPlatformSDKWithMinimumVersion(platform, minimum_sdk_version_str):29 minimum_sdk_version = _AsVersion(minimum_sdk_version_str)30 # Try the SDKs that Xcode knows about.31 xcodebuild_showsdks_subprocess = subprocess.Popen(32 ['xcodebuild', '-showsdks'],33 stdout=subprocess.PIPE,34 stderr=open(os.devnull, 'w'))35 xcodebuild_showsdks_output = (36 xcodebuild_showsdks_subprocess.communicate()[0].decode('utf-8'))37 if xcodebuild_showsdks_subprocess.returncode == 0:38 # Collect strings instead of version objects to preserve the precise39 # format used to identify each SDK.40 sdk_version_strs = []41 for line in xcodebuild_showsdks_output.splitlines():42 match = re.match('[ \t].+[ \t]-sdk ' + re.escape(platform) + '(.+)$',43 line)44 if match:45 sdk_version_str = match.group(1)46 if _AsVersion(sdk_version_str) >= minimum_sdk_version:47 sdk_version_strs.append(sdk_version_str)48 if len(sdk_version_strs) == 0:49 raise DidNotMeetCriteria({'minimum': minimum_sdk_version_str,50 'platform': platform})51 sdk_version_str = sorted(sdk_version_strs, key=_AsVersion)[0]52 sdk_path = _SDKPath(platform + sdk_version_str)53 sdk_version = _AsVersion(sdk_version_str)54 else:55 # Xcode may not be installed. If the command-line tools are installed, use56 # the system’s default SDK if it meets the requirements.57 sdk_path = _SDKPath()58 sdk_version = _SDKVersion()59 if sdk_version < minimum_sdk_version:60 raise DidNotMeetCriteria({'minimum': minimum_sdk_version_str,61 'platform': platform,62 'sdk_path': sdk_path,63 'sdk_version': str(sdk_version)})64 return (sdk_version, sdk_path)65def main(args):66 parser = argparse.ArgumentParser(67 description='Find an appropriate platform SDK',68 epilog='Two lines will be written to standard output: the version of the '69 'selected SDK, and its path.')70 parser.add_argument('--developer-dir',71 help='path to Xcode or Command Line Tools')72 parser.add_argument('--exact', help='an exact SDK version to find')73 parser.add_argument('--minimum', help='the minimum SDK version to find')74 parser.add_argument('--path', help='a known SDK path to validate')75 parser.add_argument('--platform',76 default='macosx',77 help='the platform to target')78 parsed = parser.parse_args(args)79 if parsed.developer_dir is not None:80 os.environ['DEVELOPER_DIR'] = parsed.developer_dir81 if (os.environ.get('DEVELOPER_DIR') is None and82 subprocess.call(['xcode-select', '--print-path'],83 stdout=open(os.devnull, 'w'),84 stderr=open(os.devnull, 'w')) != 0):85 # This is friendlier than letting the first invocation of xcrun or86 # xcodebuild show the UI prompting to install developer tools at an87 # inopportune time.88 hint = 'Install Xcode and run "sudo xcodebuild -license"'89 if parsed.platform == 'macosx':90 hint += ', or install Command Line Tools with "xcode-select --install"'91 hint += ('. If necessary, run "sudo xcode-select --switch" to select an '92 'active developer tools installation.')93 hint = '\n'.join(textwrap.wrap(hint, 80))94 print(os.path.basename(sys.argv[0]) +95 ': No developer tools found.\n' +96 hint,97 file=sys.stderr)98 return 199 if parsed.path is not None:100 # _SDKVersion() doesn’t work with a relative pathname argument or one that’s101 # a symbolic link. Such paths are suitable for other purposes, like “clang102 # -isysroot”, so use an absolute non-symbolic link path for _SDKVersion(),103 # but preserve the user’s path in sdk_path.104 sdk_version = _SDKVersion(os.path.realpath(parsed.path))105 sdk_path = parsed.path106 elif parsed.exact is None and parsed.minimum is None:107 # Use the platform’s default SDK.108 sdk_version = _SDKVersion(parsed.platform)109 sdk_path = _SDKPath(parsed.platform)110 elif parsed.exact is not None:111 sdk_version = _SDKVersion(parsed.platform + parsed.exact)112 sdk_path = _SDKPath(parsed.platform + parsed.exact)113 else:114 (sdk_version,115 sdk_path) = _FindPlatformSDKWithMinimumVersion(parsed.platform,116 parsed.minimum)117 # These checks may be redundant depending on how the SDK was chosen.118 if ((parsed.exact is not None and sdk_version != _AsVersion(parsed.exact)) or119 (parsed.minimum is not None and120 sdk_version < _AsVersion(parsed.minimum))):121 raise DidNotMeetCriteria({'developer_dir': parsed.developer_dir,122 'exact': parsed.exact,123 'minimum': parsed.minimum,124 'path': parsed.path,125 'platform': parsed.platform,126 'sdk_path': sdk_path,127 'sdk_version': str(sdk_version)})128 # Nobody wants trailing slashes. This is true even if “/” is the SDK: it’s129 # better to return an empty string, which will be interpreted as “no sysroot.”130 sdk_path = sdk_path.rstrip(os.path.sep)131 print(sdk_version)132 print(sdk_path)133 return 0134if __name__ == '__main__':...

Full Screen

Full Screen

rest.py

Source:rest.py Github

copy

Full Screen

1from requests import get, post, delete, patch2from ..utils.request import fetch3from ..utils.api import endpoint, last_name, last_name_plural, api_json, from_api_json, cast_json_to_api_format4def get_page(sdk_version, host, api_version, user, resource, language, timeout, **query):5 json = fetch(6 host=host,7 sdk_version=sdk_version,8 user=user,9 method=get,10 path=endpoint(resource),11 query=query,12 api_version=api_version,13 language=language,14 timeout=timeout,15 ).json()16 entities = [from_api_json(resource, entity) for entity in json[last_name_plural(resource)]]17 cursor = json.get("cursor")18 return entities, cursor19def get_stream(sdk_version, host, api_version, user, resource, language, timeout, limit=None, **query):20 limit_query = {"limit": min(limit, 100) if limit else limit}21 limit_query.update(query)22 while True:23 entities, cursor = get_page(24 host=host,25 sdk_version=sdk_version,26 user=user,27 resource=resource,28 api_version=api_version,29 language=language,30 timeout=timeout,31 **limit_query32 )33 for entity in entities:34 yield entity35 if limit:36 limit -= 10037 query["limit"] = min(limit, 100)38 query["cursor"] = cursor39 if not cursor or (limit is not None and limit <= 0):40 break41def get_id(sdk_version, host, api_version, user, resource, id, language, timeout, **query):42 json = fetch(43 host=host,44 sdk_version=sdk_version,45 user=user,46 method=get,47 path="{endpoint}/{id}".format(endpoint=endpoint(resource), id=id),48 query=query,49 api_version=api_version,50 language=language,51 timeout=timeout,52 ).json()53 entity = json[last_name(resource)]54 return from_api_json(resource, entity)55def get_content(sdk_version, host, api_version, user, resource, id, sub_resource_name, language, timeout, **query):56 return fetch(57 host=host,58 sdk_version=sdk_version,59 user=user,60 method=get,61 path="{endpoint}/{id}/{sub_resource_name}".format(62 endpoint=endpoint(resource),63 id=id,64 sub_resource_name=sub_resource_name,65 ),66 query=query,67 api_version=api_version,68 language=language,69 timeout=timeout,70 ).content71def get_sub_resource(sdk_version, host, api_version, user, resource, id, sub_resource, language, timeout, **query):72 entity = fetch(73 host=host,74 sdk_version=sdk_version,75 user=user,76 method=get,77 path="{endpoint}/{id}/{sub_resource}".format(78 endpoint=endpoint(resource),79 id=id,80 sub_resource=endpoint(sub_resource),81 ),82 query=query,83 api_version=api_version,84 language=language,85 timeout=timeout,86 ).json()[last_name(sub_resource)]87 return from_api_json(sub_resource, entity)88def get_sub_resources(sdk_version, host, api_version, user, resource, id, sub_resource, language, timeout, **query):89 entities = fetch(90 host=host,91 sdk_version=sdk_version,92 user=user,93 method=get,94 path="{endpoint}/{id}/{sub_resource}".format(95 endpoint=endpoint(resource),96 id=id,97 sub_resource=endpoint(sub_resource),98 ),99 query=query,100 api_version=api_version,101 language=language,102 timeout=timeout,103 ).json()[last_name_plural(sub_resource)]104 return [from_api_json(sub_resource, entity) for entity in entities]105def post_multi(sdk_version, host, api_version, user, resource, entities, language, timeout, **query):106 json = fetch(107 host=host,108 sdk_version=sdk_version,109 user=user,110 method=post,111 path=endpoint(resource),112 payload={last_name_plural(resource): [api_json(entity) for entity in entities]},113 query=query,114 api_version=api_version,115 language=language,116 timeout=timeout,117 ).json()118 entities = json[last_name_plural(resource)]119 return [from_api_json(resource, entity) for entity in entities]120def post_single(sdk_version, host, api_version, user, resource, entity, language, timeout, **query):121 payload = api_json(entity)122 json = fetch(123 host=host,124 sdk_version=sdk_version,125 user=user,126 method=post,127 path=endpoint(resource),128 payload=payload,129 query=query,130 api_version=api_version,131 language=language,132 timeout=timeout,133 ).json()134 entity_json = json[last_name(resource)]135 return from_api_json(resource, entity_json)136def delete_id(sdk_version, host, api_version, user, resource, id, language, timeout, **query):137 json = fetch(138 host=host,139 sdk_version=sdk_version,140 user=user,141 method=delete,142 path="{endpoint}/{id}".format(endpoint=endpoint(resource), id=id),143 query=query,144 api_version=api_version,145 language=language,146 timeout=timeout,147 ).json()148 entity = json[last_name(resource)]149 return from_api_json(resource, entity)150def patch_id(sdk_version, host, api_version, user, resource, id, payload, language, timeout, **query):151 json = fetch(152 host=host,153 sdk_version=sdk_version,154 user=user,155 method=patch,156 path="{endpoint}/{id}".format(endpoint=endpoint(resource), id=id),157 payload=cast_json_to_api_format(payload),158 query=query,159 api_version=api_version,160 language=language,161 timeout=timeout,162 ).json()163 entity = json[last_name(resource)]164 return from_api_json(resource, entity)165def get_raw(sdk_version, host, api_version, path, user, language, timeout, **query):166 return fetch(167 host=host,168 sdk_version=sdk_version,169 user=user,170 method=get,171 path=path,172 query=query,173 api_version=api_version,174 language=language,175 timeout=timeout,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Airtest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful