Best Python code snippet using localstack_python
app.py
Source:app.py
...17def extractSoftwareFromInstanceObject(ssmClient, instanceObj):18 try:19 softData = []20 21 results = ssmClient.list_inventory_entries(22 InstanceId=instanceObj['instanceId'],23 TypeName='AWS:Application'24 )25 if 'Entries' in results:26 softData.extend([ dumps({'date': time.strftime('%Y-%m-%d'), **instanceObj, **createSoftwareObject(data)}) + '\n' for data in results['Entries'] ])27 while 'NextToken' in results:28 results = ssmClient.list_inventory_entries(29 InstanceId=instanceObj['instanceId'],30 TypeName='AWS:Application', NextToken=results['NextToken']31 )32 if 'Entries' in results:33 softData.extend([ dumps({'date': time.strftime('%Y-%m-%d'), **instanceObj, **createSoftwareObject(data)}) + '\n' for data in results['Entries'] ])34 return softData35 except Exception as e:36 print(e)37def createSoftwareObject(data):38 return {39 'packageId': data.get('PackageId', ""),40 'publisher': data.get('Publisher', ""),41 'architecture': data.get('Architecture', ""),42 'version': data.get('Version', ""),...
software_audit.py
Source:software_audit.py
...48 instances.append(i.id)49 # Find connected instances50 for i in instances:51 print(i)52 response = ssm.list_inventory_entries(InstanceId = i, TypeName = "AWS:Application")53 54 while response.get("NextToken"):55 ##print(response.get("NextToken"))56 software_list.extend(getSoftwareFromEntries(response.get("InstanceId"), response["Entries"]))57 response = ssm.list_inventory_entries(InstanceId = i, TypeName = "AWS:Application", NextToken = response.get("NextToken"))58 software_list.extend(getSoftwareFromEntries(response.get("InstanceId"), response["Entries"]))59 s3.put_object(Body='\n'.join(software_list), Bucket=bucket, Key=fname)60 61 62def lambda_handler(event, context):...
ssm-ec2.py
Source:ssm-ec2.py
...17 final_dict = {}18 ssm = boto3.client('ssm')19 20 # getting inventory details Applications installed21 inventory = ssm.list_inventory_entries(22 InstanceId=['InstanceId'],23 TypeName='AWS:Application'24 )25 final_dict['Applications'] = inventory['Entries']26 final_list.append(final_dict.copy())27 ...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!