MCPcopy Index your code
hub / github.com/zappa/Zappa / callback

Method callback

zappa/cli.py:2509–2557  ·  view source on GitHub ↗

Allows the execution of custom code between creation of the zip file and deployment to AWS. :return: None

(self, position)

Source from the content-addressed store, hash-verified

2507 ##
2508
2509 def callback(self, position):
2510 """
2511 Allows the execution of custom code between creation of the zip file and deployment to AWS.
2512 :return: None
2513 """
2514
2515 callbacks = self.stage_config.get("callbacks", {})
2516 callback = callbacks.get(position)
2517
2518 if callback:
2519 (mod_path, cb_func_name) = callback.rsplit(".", 1)
2520
2521 try: # Prefer callback in working directory
2522 if mod_path.count(".") >= 1: # Callback function is nested in a folder
2523 (mod_folder_path, mod_name) = mod_path.rsplit(".", 1)
2524 mod_folder_path_fragments = mod_folder_path.split(".")
2525 working_dir = os.path.join(os.getcwd(), *mod_folder_path_fragments)
2526 else:
2527 mod_name = mod_path
2528 working_dir = os.getcwd()
2529
2530 working_dir_importer = pkgutil.get_importer(working_dir)
2531 module_ = working_dir_importer.find_spec(mod_name).loader.load_module(mod_name)
2532
2533 except (ImportError, AttributeError):
2534 try: # Callback func might be in virtualenv
2535 module_ = importlib.import_module(mod_path)
2536 except ImportError: # pragma: no cover
2537 raise ClickException(
2538 click.style("Failed ", fg="red")
2539 + "to "
2540 + click.style(
2541 "import {position} callback ".format(position=position),
2542 bold=True,
2543 )
2544 + 'module: "{mod_path}"'.format(mod_path=click.style(mod_path, bold=True))
2545 )
2546
2547 if not hasattr(module_, cb_func_name): # pragma: no cover
2548 raise ClickException(
2549 click.style("Failed ", fg="red")
2550 + "to "
2551 + click.style("find {position} callback ".format(position=position), bold=True)
2552 + 'function: "{cb_func_name}" '.format(cb_func_name=click.style(cb_func_name, bold=True))
2553 + 'in module "{mod_path}"'.format(mod_path=mod_path)
2554 )
2555
2556 cb_func = getattr(module_, cb_func_name)
2557 cb_func(self) # Call the function passing self
2558
2559 def check_for_update(self):
2560 """

Callers 4

dispatch_commandMethod · 0.95
packageMethod · 0.95
deployMethod · 0.95
updateMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected