<commit_before>"""Destroy Security Group Resources."""
import logging
import requests

from ...consts import API_URL, HEADERS
from ...utils import get_template, get_vpc_id, check_task, Gate

LOG = logging.getLogger(__name__)


def destroy_sg(app='', env='', region='', **_):
    """Destroy Security Group.

    Args:
        account (str): AWS account name.
        region (str): Region name, e.g. us-east-1.

    Returns:
        True upon successful completion.
    """
    vpc = get_vpc_id(account=env, region=region)

    try:
        url = '{api}/securityGroups/{env}/{region}/{app}'.format(
            api=API_URL, env=env, region=region,
            app=app)
        security_group = Gate(url).get(vpcId=vpc)
    except AssertionError:
        raise

    if not security_group:
        LOG.info('Nothing to delete.')
        raise SystemExit
    else:
        LOG.info('Found Security Group in %(region)s: %(name)s',
                 security_group)

    destroy_request = get_template('destroy/destroy_sg.json.j2',
                                   app=app,
                                   env=env,
                                   region=region,
                                   vpc=vpc)

    response = Gate().tasks.post(destroy_request)

    check_task(response, app)

    return True<commit_msg>fix: Remove SystemExit from `destroy-sg`<commit_after>"""Destroy Security Group Resources."""
import logging
import requests

from ...consts import API_URL, HEADERS
from ...utils import get_template, get_vpc_id, check_task, Gate

LOG = logging.getLogger(__name__)


def destroy_sg(app='', env='', region='', **_):
    """Destroy Security Group.

    Args:
        account (str): AWS account name.
        region (str): Region name, e.g. us-east-1.

    Returns:
        True upon successful completion.
    """
    vpc = get_vpc_id(account=env, region=region)

    try:
        url = '{api}/securityGroups/{env}/{region}/{app}'.format(
            api=API_URL, env=env, region=region,
            app=app)
        security_group = Gate(url).get(vpcId=vpc)
    except AssertionError:
        raise

    if not security_group:
        LOG.info('Nothing to delete.')
    else:
        LOG.info('Found Security Group in %(region)s: %(name)s',
                 security_group)

        destroy_request = get_template('destroy/destroy_sg.json.j2',
                                       app=app,
                                       env=env,
                                       region=region,
                                       vpc=vpc)

        response = Gate().tasks.post(destroy_request)

        check_task(response, app)

    return True
{'fraction_non_alphanumeric': 0.1149511645379414, 'fraction_numerical': 0.0015026296018031556, 'mean_word_length': 1.9263736263736264, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1080873', 'n_tokens_mistral': 770, 'n_tokens_neox': 741, 'n_words': 179}