(command_name, *args, required_commit=None, custom_message=None, **kwargs)
Helper function to run a management command automatically and abort if there was an error
    with helpful console output to allow users to run it manually if it fails or
    has since been removed from the codebase.
Helper function to run a management command automatically and abort if there was an error
    with helpful console output to allow users to run it manually if it fails or
    has since been removed from the codebase.
Helper function to run a management command automatically and abort if there was an error with helpful console output to allow users to run it manually if it fails or has since been removed from the codebase .
def run_management_command_or_exit(command_name, *args, required_commit=None, custom_message=None, **kwargs):
    """Helper function to run a management command automatically and abort if there was an error
    with helpful console output to allow users to run it manually if it fails or
    has since been removed from the codebase."""
    try:
        call_command(command_name, *args, **kwargs)
    except Exception:
        traceback.print_exc()
        print(f"""
            A migration must be performed before this environment can be upgraded to the latest version
            of CommCareHQ. This migration is run using the management command {command_name}.
        """)
        if required_commit or custom_message:
            print("")
            print(custom_message or f"""
            Run the following commands to run the migration and get up to date:

                commcare-cloud <env> fab setup_limited_release --set code_branch={required_commit}

                commcare-cloud <env> django-manage --release <release created by previous command> migrate_multi

                commcare-cloud <env> deploy commcare
            """)
        sys.exit(1)
def run_management_command_or_exit ( command_name , * args , required_commit = None , custom_message = None , * * kwargs ) : try : call_command ( command_name , * args , * * kwargs ) except Exception : traceback . print_exc ( ) print ( f"""
            A migration must be performed before this environment can be upgraded to the latest version
            of CommCareHQ. This migration is run using the management command {command_name}.
        """ ) if required_commit or custom_message : print ( "" ) print ( custom_message or f"""
            Run the following commands to run the migration and get up to date:

                commcare-cloud <env> fab setup_limited_release --set code_branch={required_commit}

                commcare-cloud <env> django-manage --release <release created by previous command> migrate_multi

                commcare-cloud <env> deploy commcare
            """ ) sys . exit ( 1 )