|
7 | 7 | import os
|
8 | 8 | import sys
|
9 | 9 | import time
|
| 10 | +from collections import defaultdict |
10 | 11 | from imp import load_source
|
11 | 12 | from shutil import copy
|
12 |
| -from shutil import copyfile, copytree |
| 13 | +from shutil import copyfile |
| 14 | +from shutil import copytree |
13 | 15 | from tempfile import mkdtemp
|
14 |
| -from collections import defaultdict |
15 | 16 |
|
16 | 17 | import boto3
|
17 | 18 | import botocore
|
|
26 | 27 |
|
27 | 28 |
|
28 | 29 | ARN_PREFIXES = {
|
29 |
| - 'us-gov-west-1': 'aws-us-gov' |
| 30 | + 'us-gov-west-1': 'aws-us-gov', |
30 | 31 | }
|
31 | 32 |
|
32 | 33 | log = logging.getLogger(__name__)
|
@@ -247,11 +248,18 @@ def build(src, requirements=False, local_package=None):
|
247 | 248 | else output_filename
|
248 | 249 | )
|
249 | 250 |
|
250 |
| - # Allow definition of source code directories we want to build into our zipped package. |
| 251 | + # Allow definition of source code directories we want to build into our |
| 252 | + # zipped package. |
251 | 253 | build_config = defaultdict(**cfg.get('build', {}))
|
252 | 254 | build_source_directories = build_config.get('source_directories', '')
|
253 |
| - build_source_directories = build_source_directories if build_source_directories is not None else '' |
254 |
| - source_directories = [d.strip() for d in build_source_directories.split(',')] |
| 255 | + build_source_directories = ( |
| 256 | + build_source_directories |
| 257 | + if build_source_directories is not None |
| 258 | + else '' |
| 259 | + ) |
| 260 | + source_directories = [ |
| 261 | + d.strip() for d in build_source_directories.split(',') |
| 262 | + ] |
255 | 263 |
|
256 | 264 | files = []
|
257 | 265 | for filename in os.listdir(src):
|
@@ -407,7 +415,10 @@ def create_function(cfg, path_to_zip_file):
|
407 | 415 | aws_secret_access_key = cfg.get('aws_secret_access_key')
|
408 | 416 |
|
409 | 417 | account_id = get_account_id(aws_access_key_id, aws_secret_access_key)
|
410 |
| - role = get_role_name(cfg.get('region'), account_id, cfg.get('role', 'lambda_basic_execution')) |
| 418 | + role = get_role_name( |
| 419 | + cfg.get('region'), account_id, |
| 420 | + cfg.get('role', 'lambda_basic_execution'), |
| 421 | + ) |
411 | 422 |
|
412 | 423 | client = get_client(
|
413 | 424 | 'lambda', aws_access_key_id, aws_secret_access_key,
|
@@ -454,7 +465,10 @@ def update_function(cfg, path_to_zip_file):
|
454 | 465 | aws_secret_access_key = cfg.get('aws_secret_access_key')
|
455 | 466 |
|
456 | 467 | account_id = get_account_id(aws_access_key_id, aws_secret_access_key)
|
457 |
| - role = get_role_name(cfg.get('region'), account_id, cfg.get('role', 'lambda_basic_execution')) |
| 468 | + role = get_role_name( |
| 469 | + cfg.get('region'), account_id, |
| 470 | + cfg.get('role', 'lambda_basic_execution'), |
| 471 | + ) |
458 | 472 |
|
459 | 473 | client = get_client(
|
460 | 474 | 'lambda', aws_access_key_id, aws_secret_access_key,
|
@@ -541,12 +555,18 @@ def function_exists(cfg, function_name):
|
541 | 555 | cfg.get('region'),
|
542 | 556 | )
|
543 | 557 |
|
544 |
| - # Need to loop through until we get all of the lambda functions returned. It appears |
545 |
| - # to be only returning 50 functions at a time. |
| 558 | + # Need to loop through until we get all of the lambda functions returned. |
| 559 | + # It appears to be only returning 50 functions at a time. |
546 | 560 | functions = []
|
547 | 561 | functions_resp = client.list_functions()
|
548 |
| - functions.extend([f['FunctionName'] for f in functions_resp.get('Functions', [])]) |
| 562 | + functions.extend([ |
| 563 | + f['FunctionName'] for f in functions_resp.get('Functions', []) |
| 564 | + ]) |
549 | 565 | while('NextMarker' in functions_resp):
|
550 |
| - functions_resp = client.list_functions(Marker=functions_resp.get('NextMarker')) |
551 |
| - functions.extend([f['FunctionName'] for f in functions_resp.get('Functions', [])]) |
| 566 | + functions_resp = client.list_functions( |
| 567 | + Marker=functions_resp.get('NextMarker'), |
| 568 | + ) |
| 569 | + functions.extend([ |
| 570 | + f['FunctionName'] for f in functions_resp.get('Functions', []) |
| 571 | + ]) |
552 | 572 | return function_name in functions
|
0 commit comments