Таким образом, я могу запустить код, если использую блок кода в функции, в которой список переменных впервые определен, однако, когда я передаю переменную в другую функцию и запускаю startwith (), она возвращает false!
def lambda_handler(event, context):
test = ['2', 'Snapshot-Only2019-10-07T06-08-43.522172Dev/']
name_of_snapshot_folder = test[1]
total_instances = int(test[0])
print('name_of_snapshot_folder : {0}'.format(name_of_snapshot_folder))
start_status_check(name_of_snapshot_folder, total_instances)
def start_status_check(name_of_snapshot_folder, total_instances):
try:
print('Type of total instance inside start status check : {0}'.format(type(total_instances)))
snap_list = []
count = 0
print('Type of snapshot folder is :{0}'.format(type(name_of_snapshot_folder)))
print('Total instances are :{0}'.format(total_instances))
client = boto3.client('s3')
new_name = str(name_of_snapshot_folder).strip()
print('type pf new name: {0}'.format(type(new_name)))
for i in my_bucket.objects.all():
print('Printing i inside my bucket loop: {0}'.format(i.key))
print('Snapshot-Only2019-10-07T06-08-43.522172Dev/ff'.startswith(new_name))
if(i.key.startswith(new_name) and i.key.endswith('.txt')):
count += 1
print(count)
print('Printing i :{0}'.format(i))
print("count value {0}, true or false is? {1} :".format(count, count == total_instances))
if count == total_instances:
print('testing phase')
#client = boto3.client('lambda')
print('Total files matches total instances, invoking status check function')
check_backup_status(total_instances, name_of_snapshot_folder)
else:
print('Inside codepipeline continued execution')
Функция startwith () должна возвращать значение True, однако во второй функции она возвращает значение false