<commit_before>from flask import render_template, redirect, url_for, session, flash, abort
from .. import main
from . import get_template_data
from flask_login import login_required, current_user
from app.main.forms import SmsForm
from app import data_api_client
from app.api_client.errors import APIError


@main.route('/service/<int:service_id>/send-sms', methods=['GET'])
@login_required
def send_sms(service_id):
    service = data_api_client.get_service_by_user_id_and_service_id(int(session['user_id']), service_id)
    return render_template("send_sms.html", service=service['service'], form=SmsForm(), **get_template_data())


@main.route('/service/<int:service_id>/send-sms', methods=['POST'])
def process_sms(service_id):
    form = SmsForm()
    if form.validate_on_submit():
        service = data_api_client.get_service_by_user_id_and_service_id(int(session['user_id']), service_id)
        try:
            data_api_client.send_sms(form.mobile_number.data, form.message.data, token=service['service']['token']['token'])
            flash("SMS sent to {}".format(form.mobile_number.data), "success")
            return redirect(url_for('.view_all_jobs', service_id=service_id))
        except APIError as ex:
            print(ex.response.json())
            abort(500, "API error")
    else:
        return render_template(
            "send_sms.html",
            service_id=service_id,
            form=form,
            **get_template_data()), 400<commit_msg>pep8 sorted<commit_after>from flask import render_template, redirect, url_for, session, flash, abort
from .. import main
from . import get_template_data
from flask_login import login_required, current_user
from app.main.forms import SmsForm
from app import data_api_client
from app.api_client.errors import APIError


@main.route('/service/<int:service_id>/send-sms', methods=['GET'])
@login_required
def send_sms(service_id):
    service = data_api_client.get_service_by_user_id_and_service_id(int(session['user_id']), service_id)
    return render_template("send_sms.html", service=service['service'], form=SmsForm(), **get_template_data())


@main.route('/service/<int:service_id>/send-sms', methods=['POST'])
def process_sms(service_id):
    form = SmsForm()
    if form.validate_on_submit():
        service = data_api_client.get_service_by_user_id_and_service_id(int(session['user_id']), service_id)
        try:
            data_api_client.send_sms(
                form.mobile_number.data,
                form.message.data,
                token=service['service']['token']['token'])
            flash("SMS sent to {}".format(form.mobile_number.data), "success")
            return redirect(url_for('.view_all_jobs', service_id=service_id))
        except APIError as ex:
            print(ex.response.json())
            abort(500, "API error")
    else:
        return render_template(
            "send_sms.html",
            service_id=service_id,
            form=form,
            **get_template_data()), 400
{'fraction_non_alphanumeric': 0.12270756918972991, 'fraction_numerical': 0.004334778259419807, 'mean_word_length': 3.8309178743961354, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2069485', 'n_tokens_mistral': 945, 'n_tokens_neox': 923, 'n_words': 169}