How to use do_tap method in ATX

Best Python code snippet using ATX

spile_tapper.py

Source:spile_tapper.py Github

copy

Full Screen

1from typing import Generator, List2from aws_network_tap.models.ec2_api_client import Ec2ApiClient, ENI_Tag3from aws_network_tap.models.spile import Spile4from aws_network_tap.models.aws_tag import AWSTag5from aws_network_tap.models.tag_config import EC2Config, VPCTagConfig6class SpileTapper(Ec2ApiClient):7 FOREST_SPECIES = [8 # A19 "a1.medium",10 "a1.large",11 "a1.xlarge",12 "a1.2xlarge",13 "a1.4xlarge",14 # C515 "c5.large",16 "c5.xlarge",17 "c5.2xlarge",18 "c5.4xlarge",19 "c5.9xlarge",20 "c5.12xlarge",21 "c5.18xlarge",22 "c5.24xlarge",23 "c5.metal",24 # C5d25 "c5d.large",26 "c5d.xlarge",27 "c5d.2xlarge",28 "c5d.4xlarge",29 "c5d.9xlarge",30 "c5d.18xlarge",31 # C5n32 "c5n.large",33 "c5n.xlarge",34 "c5n.2xlarge",35 "c5n.4xlarge",36 "c5n.9xlarge",37 "c5n.18xlarge",38 "c5n.metal",39 # I3en40 "i3en.large",41 "i3en.xlarge",42 "i3en.2xlarge",43 "i3en.3xlarge",44 "i3en.6xlarge",45 "i3en.12xlarge",46 "i3en.24xlarge",47 "i3en.metal",48 # M549 "m5.large",50 "m5.xlarge",51 "m5.2xlarge",52 "m5.4xlarge",53 "m5.8xlarge",54 "m5.12xlarge",55 "m5.16xlarge",56 "m5.24xlarge",57 "m5.metal",58 # M5a59 "m5a.large",60 "m5a.xlarge",61 "m5a.2xlarge",62 "m5a.4xlarge",63 "m5a.8xlarge",64 "m5a.12xlarge",65 "m5a.16xlarge",66 "m5a.24xlarge",67 # M5ad68 "m5ad.large",69 "m5ad.xlarge",70 "m5ad.2xlarge",71 "m5ad.4xlarge",72 "m5ad.12xlarge",73 "m5ad.24xlarge",74 # M5d75 "m5d.large",76 "m5d.xlarge",77 "m5d.2xlarge",78 "m5d.4xlarge",79 "m5d.8xlarge",80 "m5d.12xlarge",81 "m5d.16xlarge",82 "m5d.24xlarge",83 "m5d.metal",84 "p3dn.24xlarge",85 # R586 "r5.large",87 "r5.xlarge",88 "r5.2xlarge",89 "r5.4xlarge",90 "r5.8xlarge",91 "r5.12xlarge",92 "r5.16xlarge",93 "r5.24xlarge",94 "r5.metal",95 # R5a96 "r5a.large",97 "r5a.xlarge",98 "r5a.2xlarge",99 "r5a.4xlarge",100 "r5a.8xlarge",101 "r5a.12xlarge",102 "r5a.16xlarge",103 "r5a.24xlarge",104 # R5ad105 "r5ad.large",106 "r5ad.xlarge",107 "r5ad.2xlarge",108 "r5ad.4xlarge",109 "r5ad.12xlarge",110 "r5ad.24xlarge",111 # R5d112 "r5d.large",113 "r5d.xlarge",114 "r5d.2xlarge",115 "r5d.4xlarge",116 "r5d.8xlarge",117 "r5d.12xlarge",118 "r5d.16xlarge",119 "r5d.24xlarge",120 "r5d.metal",121 # T3122 "t3.nano",123 "t3.micro",124 "t3.small",125 "t3.medium",126 "t3.large",127 "t3.xlarge",128 "t3.2xlarge",129 # T3a130 "t3a.nano",131 "t3a.micro",132 "t3a.small",133 "t3a.medium",134 "t3a.large",135 "t3a.xlarge",136 "t3a.2xlarge",137 # z1d138 "z1d.large",139 "z1d.xlarge",140 "z1d.2xlarge",141 "z1d.3xlarge",142 "z1d.6xlarge",143 "z1d.12xlarge",144 "z1d.metal",145 ]146 def discover(self) -> Generator[Spile, None, None]:147 """ find all the nitro instances and return a Spile if so"""148 paginator = self.ec2_client.get_paginator("describe_instances")149 filters = [{"Name": "instance-type", "Values": self.FOREST_SPECIES}]150 if self.vpc_ids:151 filters.append({"Name": "vpc-id", "Values": self.vpc_ids})152 page_iterator = paginator.paginate(Filters=filters)153 for page in page_iterator:154 for garbo in page["Reservations"]:155 for instance in garbo["Instances"]:156 instance_id = instance["InstanceId"]157 tags = AWSTag.to_dict(instance.get(AWSTag.TAGS_KEY))158 for interface in instance["NetworkInterfaces"]:159 yield Spile(160 ec2_client=self.ec2_client,161 eni_tag=ENI_Tag(162 instance_id,163 interface["NetworkInterfaceId"],164 tags,165 instance["State"]["Name"]166 ),167 )168 @classmethod169 def manage(cls, region: str, vpc_ids: List[str], config: VPCTagConfig) -> None:170 tapper = SpileTapper(region=region, vpc_ids=vpc_ids)171 if not config.enabled:172 return173 ec2_blacklist = []174 ec2_whitelist = []175 if config.auto_enrollment:176 ec2_blacklist = Ec2ApiClient.get_instances_by_tag(region=region, tag=EC2Config.T_BLACKLIST)177 else:178 ec2_whitelist = Ec2ApiClient.get_instances_by_tag(region=region, tag=EC2Config.T_WHITELIST)179 for spile in tapper.discover(): # type: Spile180 if config.auto_enrollment:181 do_tap = spile.eni_tag.instance_id not in ec2_blacklist182 else:183 do_tap = spile.eni_tag.instance_id in ec2_whitelist...

Full Screen

Full Screen

test_spile.py

Source:test_spile.py Github

copy

Full Screen

...26 spile = Spile(boto3.client('s3'), eni_tag)27 spile._find_tap = MagicMock(return_value=None)28 result = spile.manage('arn:/foo/bar', do_tap=False)29 self.assertIsNone(result)30 def test_manage_do_tap(self):31 eni_tag = ENI_Tag('id-12345', 'eth0', None, Ec2ApiClient.STATE_RUNNING)32 spile = Spile(boto3.client('s3'), eni_tag)33 spile._find_tap = MagicMock(return_value=None)34 spile._tap = MagicMock()35 result = spile.manage('arn:/foo/bar', do_tap=True)36 self.assertIsNotNone(result)37 spile._tap.assert_called_once()38 def test_manage_not_running_prevents_tap(self):39 eni_tag = ENI_Tag('id-12345', 'eth0', None, Ec2ApiClient.STATE_STOPPED)40 spile = Spile(boto3.client('s3'), eni_tag)41 spile._find_tap = MagicMock(return_value=None)42 result = spile.manage('arn:/foo/bar', do_tap=True)43 self.assertIsNone(result)44 def test_manage_no_change_already_tapped(self):...

Full Screen

Full Screen

sim_tap.py

Source:sim_tap.py Github

copy

Full Screen

...6 self.x = stp[0]7 self.y = stp[1]8 self.t = stp[2]9 if doimm is True:10 self.do_tap()11 def do_tap(self):12 print('tapping ' + str(self.x) + r' ' + str(self.y))13 subprocess.Popen('adb shell input tap ' + str(self.x) + r' ' + str(self.y), shell=True)14 print('sleeping ' + str(self.t))...

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 ATX 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