<commit_before>#!/usr/bin/env python

import argparse

import service_configuration_lib
from paasta_tools import marathon_tools
from paasta_tools import drain_lib
from paasta_tools import bounce_lib
from paasta_tools.utils import decompose_job_id
from paasta_tools.setup_marathon_job import do_bounce, get_old_live_draining_tasks
from paasta_tools.utils import load_system_paasta_config
from marathon.exceptions import MarathonHttpError


def parse_args():
    parser = argparse.ArgumentParser(
        description='',
    )
    parser.add_argument(
        'appname',
        help="the app that will be drained",
    )
    parser.add_argument(
        '-d', '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=service_configuration_lib.DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    return parser.parse_args()


def main():
    args = parse_args()
    full_appid = args.appname
    soa_dir = args.soa_dir
    marathon_config = marathon_tools.load_marathon_config()
    client = marathon_tools.get_marathon_client(
        marathon_config.get_url(),
        marathon_config.get_username(),
        marathon_config.get_password(),
    )

    if not marathon_tools.is_app_id_running(app_id=full_appid, client=client):
        print("Couldn't find an app named {0}".format(full_appid))
        quit()

    service, instance, _, __ = (s.replace('--', '_') for s in decompose_job_id(full_appid))
    short_appid = marathon_tools.format_job_id(service, instance)
    complete_config = marathon_tools.create_complete_config(service, instance, marathon_config)
    cluster = load_system_paasta_config().get_cluster()
    service_instance_config = marathon_tools.load_marathon_service_config(
        service,
        instance,
        cluster,
        soa_dir=soa_dir,
    )
    nerve_ns = service_instance_config.get_nerve_namespace()<commit_msg>updated graceful_app_drain to work with the /appid format<commit_after>#!/usr/bin/env python

import argparse
import sys

import service_configuration_lib
from paasta_tools import marathon_tools
from paasta_tools import drain_lib
from paasta_tools import bounce_lib
from paasta_tools.utils import decompose_job_id
from paasta_tools.setup_marathon_job import do_bounce, get_old_live_draining_tasks
from paasta_tools.utils import load_system_paasta_config
from marathon.exceptions import MarathonHttpError


def parse_args():
    parser = argparse.ArgumentParser(
        description='',
    )
    parser.add_argument(
        'appname',
        help="the app that will be drained",
    )
    parser.add_argument(
        '-d', '--soa-dir',
        dest="soa_dir",
        metavar="SOA_DIR",
        default=service_configuration_lib.DEFAULT_SOA_DIR,
        help="define a different soa config directory",
    )
    return parser.parse_args()


def main():
    args = parse_args()
    full_appid = args.appname.lstrip('/')
    soa_dir = args.soa_dir
    marathon_config = marathon_tools.load_marathon_config()
    client = marathon_tools.get_marathon_client(
        url=marathon_config.get_url(),
        user=marathon_config.get_username(),
        password=<PASSWORD>(),
    )

    if not marathon_tools.is_app_id_running(app_id=full_appid, client=client):
        print("Couldn't find an app named {0}".format(full_appid))
        sys.exit(1)

    service, instance, _, __ = (s.replace('--', '_') for s in decompose_job_id(full_appid))
    short_appid = marathon_tools.format_job_id(service, instance)
    complete_config = marathon_tools.create_complete_config(service, instance, marathon_config)
    cluster = load_system_paasta_config().get_cluster()
    service_instance_config = marathon_tools.load_marathon_service_config(
        service,
        instance,
        cluster,
        soa_dir=soa_dir,
    )
    nerve_ns = service_instance_config.get_nerve_namespace()
{'fraction_non_alphanumeric': 0.08664259927797834, 'fraction_numerical': 0.0007735946364105209, 'mean_word_length': 3.867001254705144, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4493352', 'n_tokens_mistral': 1244, 'n_tokens_neox': 1204, 'n_words': 232}