How to use list_containers method in localstack

Best Python code snippet using localstack_python

azure_access.py

Source:azure_access.py Github

copy

Full Screen

...26 # --- Initialize27 blob_service_client = BlobServiceClient.from_connection_string(connect_str)28 # --- Print list of containers29 print(f"List of containers:")30 for blob in blob_service_client.list_containers():31 print("\t" + blob.name)32 return blob_service_client33# -------- initContainerClient34def initContainerClient(blob_client, container):35 """Instantiate a container client36 Arguments:37 blob_client -- Blob Storage Client initialized by initBlobServiceClient function38 container {str} -- Container to access/download from.39 """40 # Get the container client41 container_client = blob_client.get_container_client(container)42 # List all blobs in that container43 list_containers = list(container_client.list_blobs())44 print(f"Container initialized. Number of blobs: {len(list_containers)}")...

Full Screen

Full Screen

Day17_part2.py

Source:Day17_part2.py Github

copy

Full Screen

1'''Day 17 Advent of Code, ways to add to 150'''2import sys3import time4import itertools5def parse(file_loc):6 '''7 read input to list8 :param file_loc: file path to AOC input.txt9 :return list_containers: list of container sizes10 '''11 list_containers = []12 with open(file_loc, "r") as myfile:13 for line in myfile:14 value = int(line)15 list_containers.append(value)16 return sorted(list_containers)17def max_and_min(list_containers, target):18 '''19 :param list_containers: list of container sizes20 :param target: the target value we are trying to reach21 :return max_number: the maximum number of containers that can be used to reach 150 wihtout going over22 :return min_number: the minimum number of containers that can be used to reach 150 wihtout being too few23 '''24 num_containers = len(list_containers)25 for i, value in enumerate(list_containers):26 if sum(list_containers[0:i+1]) > target:27 break28 max_number = i29 for i, value in enumerate(list_containers):30 if sum(list_containers[num_containers-i-1:]) >= target:31 break32 min_number = i+133 return max_number, min_number34def combo_generator(list_containers, max_number, min_number):35 '''36 Generates all the possible way of choosing n containers from a set of containers37 repeated for different values of n as our solution may use 7 or 12 buckets etc38 :param list_containers: list of container sizes39 :param max_number: the maximum number of containers that can be used to reach 150 without going over40 :param min_number: the minimum number of containers that can be used to reach 150 without being too few41 :return: generator with all combinations that could possibly be a solution42 '''43 for num_containers_in_sol in range(min_number, max_number+1):44 combo_level = itertools.combinations(list_containers, num_containers_in_sol)45 for combo in combo_level:46 yield combo47def checker(some_combo, target):48 sum_to_target = False49 if sum(some_combo) == target:50 sum_to_target = True51 return sum_to_target52def main(file_loc, target, part_num):53 my_containers = parse(file_loc)54 max_containers, min_containers = max_and_min(my_containers, target)55 if part_num == 1:56 possible_sol_generator = combo_generator(my_containers, max_containers, min_containers)57 num_correct_combos = 058 for candidate_combo in possible_sol_generator:59 if checker(candidate_combo, target):60 num_correct_combos += 161 return num_correct_combos62 if part_num == 2:63 num_correct_combos = 064 possible_minimum_number = min_containers65 while num_correct_combos == 0:66 possible_sol_generator = combo_generator(my_containers, possible_minimum_number, possible_minimum_number)67 for candidate_combo in possible_sol_generator:68 if checker(candidate_combo, target):69 num_correct_combos += 170 possible_minimum_number += 171 print('The minimum number of containers required is {}'.format(possible_minimum_number-1))72 return num_correct_combos73if __name__ == '__main__':74 start_time = time.time()75 input_file = 'Day17_input.txt'76 total = 15077 part = 178 if len(sys.argv) >= 2:79 input_file = sys.argv[1]80 if len(sys.argv) == 3:81 part = int(sys.argv[2])82 print(input_file, part)83 num_possible_correct_combos = main(input_file, total, part)84 print('For part {}, the number of correct combinations is {}'.format(part, num_possible_correct_combos))85 end_time = time.time()86 duration = end_time - start_time...

Full Screen

Full Screen

Day17_part1.py

Source:Day17_part1.py Github

copy

Full Screen

1'''Day 17 Advent of Code, ways to add to 150'''2import sys3import time4import itertools5def parse(file_loc):6 '''7 read input to list8 :param file_loc: file path to AOC input.txt9 :return list_containers: list of container sizes10 '''11 list_containers = []12 with open(file_loc, "r") as myfile:13 for line in myfile:14 value = int(line)15 list_containers.append(value)16 return sorted(list_containers)17def max_and_min(list_containers, target):18 '''19 :param list_containers: list of container sizes20 :param target: the target value we are trying to reach21 :return max_number: the maximum number of containers that can be used to reach 150 wihtout going over22 :return min_number: the minimum number of containers that can be used to reach 150 wihtout being too few23 '''24 num_containers = len(list_containers)25 for i, value in enumerate(list_containers):26 if sum(list_containers[0:i+1]) > target:27 break28 max_number = i29 for i, value in enumerate(list_containers):30 if sum(list_containers[num_containers-i-1:]) >= target:31 break32 min_number = i+133 return max_number, min_number34def combo_generator(list_containers, max_number, min_number):35 '''36 Generates all the possible way of choosing n containers from a set of containers37 repeated for different values of n as our solution may use 7 or 12 buckets etc38 :param list_containers: list of container sizes39 :param max_number: the maximum number of containers that can be used to reach 150 without going over40 :param min_number: the minimum number of containers that can be used to reach 150 without being too few41 :return: generator with all combinations that could possibly be a solution42 '''43 for num_containers_in_sol in range(min_number, max_number+1):44 combo_level = itertools.combinations(list_containers, num_containers_in_sol)45 for combo in combo_level:46 yield combo47def checker(some_combo, target):48 sum_to_target = False49 if sum(some_combo) == target:50 sum_to_target = True51 return sum_to_target52def main(file_loc, target):53 my_containers = parse(file_loc)54 max_containers, min_containers = max_and_min(my_containers, target)55 possible_sol_generator = combo_generator(my_containers, max_containers, min_containers)56 num_correct_combos = 057 for candidate_combo in possible_sol_generator:58 if checker(candidate_combo, target):59 num_correct_combos += 160 return num_correct_combos61if __name__ == '__main__':62 start_time = time.time()63 input_file = 'Day17_input.txt'64 TOTAL = 15065 if len(sys.argv) >= 2:66 input_file = sys.argv[1]67 num_possible_correct_combos = main(input_file, TOTAL)68 print('The number of correct combinations is {}'.format(num_possible_correct_combos))69 end_time = time.time()70 duration = end_time - start_time...

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