How to use get_package_version method in Airtest

Best Python code snippet using Airtest

deviceconfig.py

Source: deviceconfig.py Github

copy

Full Screen

...47 """48 Read the optional package versions into a dictionary.49 """50 output = OrderedDict()51 output["Pytorch Ignite"] = get_package_version("ignite")52 output["Nibabel"] = get_package_version("nibabel")53 output["scikit-image"] = get_package_version("skimage")54 output["Pillow"] = get_package_version("PIL")55 output["Tensorboard"] = get_package_version("tensorboard")56 output["gdown"] = get_package_version("gdown")57 output["TorchVision"] = get_package_version("torchvision")58 output["tqdm"] = get_package_version("tqdm")59 output["lmdb"] = get_package_version("lmdb")60 output["psutil"] = psutil_version61 output["pandas"] = get_package_version("pandas")62 output["einops"] = get_package_version("einops")63 output["transformers"] = get_package_version("transformers")64 return output65def print_config(file=sys.stdout):66 """67 Print the package versions to `file`.68 Args:69 file: `print()` text stream file. Defaults to `sys.stdout`.70 """71 for k, v in get_config_values().items():72 print(f"{k} version: {v}", file=file, flush=True)73 print(f"MONAI flags: HAS_EXT = {HAS_EXT}, USE_COMPILED = {USE_COMPILED}")74 print(f"MONAI rev id: {monai.__revision_id__}")75 print("\nOptional dependencies:", file=file, flush=True)76 for k, v in get_optional_config_values().items():77 print(f"{k} version: {v}", file=file, flush=True)...

Full Screen

Full Screen

find_k8s.py

Source: find_k8s.py Github

copy

Full Screen

...52 for x in inventory.items():53 server_id = x[0]54 server_csp_id = x[1]["server_metadata"]["csp_account_id"] if "csp_account_id" in x[1]["server_metadata"] else "" # NOQA55 server_instance_id = x[1]["server_metadata"]["csp_instance_id"] if "csp_instance_id" in x[1]["server_metadata"] else "" # NOQA56 kubectl_version = get_package_version(x[1]["packages"], "kubectl")57 kubeadm_version = get_package_version(x[1]["packages"], "kubeadm")58 kubelet_version = get_package_version(x[1]["packages"], "kubelet")59 kube_procs = get_kube_procs(x[1]["processes"])60 kubectl_vulnerable = is_kube_vulnerable(kube_min_ver, kubectl_version)61 kubeadm_vulnerable = is_kube_vulnerable(kube_min_ver, kubeadm_version)62 kubelet_vulnerable = is_kube_vulnerable(kube_min_ver, kubelet_version)63 print("{}{}{}{}{}{}{}{}{}\n{}\n\n".format(server_id.ljust(40),64 server_csp_id.ljust(40),65 server_instance_id.ljust(40),66 kubectl_version.ljust(16),67 kubeadm_version.ljust(16),68 kubelet_version.ljust(16),69 kubectl_vulnerable.ljust(20),70 kubeadm_vulnerable.ljust(20),71 kubelet_vulnerable.ljust(20),72 kube_procs))73 dump_to_csv(inventory, kube_min_ver)74 dump_to_json(inventory)75def dump_to_csv(inventory, comparisons):76 with open("out.csv", "w") as out_file:77 fieldnames = ["csp_account_id", "csp_instance_id", "halo_id",78 "kubectl_version", "kubeadm_version", "kubelet_version",79 "processes", "kubectl_vulnerable", "kubeadm_vulnerable",80 "kubelet_vulnerable"]81 writer = csv.DictWriter(out_file, fieldnames=fieldnames)82 writer.writeheader()83 for workload_id, meta in inventory.items():84 kubectl_version = get_package_version(meta["packages"], "kubectl")85 kubeadm_version = get_package_version(meta["packages"], "kubeadm")86 kubelet_version = get_package_version(meta["packages"], "kubelet")87 dataz = {"halo_id": workload_id,88 "csp_account_id": meta["server_metadata"]["csp_account_id"] if "csp_account_id" in meta["server_metadata"] else "", # NOQA89 "csp_instance_id": meta["server_metadata"]["csp_instance_id"] if "csp_instance_id" in meta["server_metadata"] else "", # NOQA90 "kubectl_version": kubectl_version,91 "kubeadm_version": kubeadm_version,92 "kubelet_version": kubelet_version,93 "processes": "\n".join([x["command"] for x in meta["processes"] if "kube" in x["process_name"]]), # NOQA94 "kubectl_vulnerable": is_kube_vulnerable(comparisons,95 kubectl_version),96 "kubeadm_vulnerable": is_kube_vulnerable(comparisons,97 kubeadm_version),98 "kubelet_vulnerable": is_kube_vulnerable(comparisons,99 kubelet_version)}100 writer.writerow(dataz)101 print("Wrote out.csv")102 return103def dump_to_json(inventory):104 with open("out.json", "w") as out_file:105 json.dump(inventory, out_file)106 print("Wrote out.json")107def merge_server_lists(list_1, list_2):108 observed = set({})109 list_1.extend(list_2)110 cleaned = []111 for server in list_1:112 if server["id"] in observed:113 continue114 else:115 cleaned.append(server)116 observed.add(server["id"])117 return cleaned118def get_kube_procs(procs):119 kube_procs = [" {}".format(x["command"]) for x in procs120 if "kube" in x["process_name"]]121 return "\n".join(kube_procs)122def get_package_version(packages, package_name):123 for p_name, p_version in packages.items():124 if p_name.startswith(package_name):125 return(p_version)126 return "NONE"127def is_kube_vulnerable(comparisons, actual):128 try:129 if actual == "NONE":130 return "INDETERMINATE"131 majorminor = str(".".join(actual.split(".")[:2]))132 # We know all these are vulnerable133 if majorminor in ["1.0", "1.1", "1.2", "1.3", "1.4", "1.5",134 "1.6", "1.7", "1.8", "1.9"]:135 return "YES"136 comparator = comparisons[majorminor]...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

QA’s and Unit Testing – Can QA Create Effective Unit Tests

Unit testing is typically software testing within the developer domain. As the QA role expands in DevOps, QAOps, DesignOps, or within an Agile team, QA testers often find themselves creating unit tests. QA testers may create unit tests within the code using a specified unit testing tool, or independently using a variety of methods.

LIVE With Automation Testing For OTT Streaming Devices ????

People love to watch, read and interact with quality content — especially video content. Whether it is sports, news, TV shows, or videos captured on smartphones, people crave digital content. The emergence of OTT platforms has already shaped the way people consume content. Viewers can now enjoy their favorite shows whenever they want rather than at pre-set times. Thus, the OTT platform’s concept of viewing anything, anytime, anywhere has hit the right chord.

Why Agile Is Great for Your Business

Agile project management is a great alternative to traditional methods, to address the customer’s needs and the delivery of business value from the beginning of the project. This blog describes the main benefits of Agile for both the customer and the business.

Options for Manual Test Case Development & Management

The purpose of developing test cases is to ensure the application functions as expected for the customer. Test cases provide basic application documentation for every function, feature, and integrated connection. Test case development often detects defects in the design or missing requirements early in the development process. Additionally, well-written test cases provide internal documentation for all application processing. Test case development is an important part of determining software quality and keeping defects away from customers.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

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