<commit_before>from __future__ import print_function
import os
from flask import Flask, request, redirect
import twilio.twiml

app = Flask(__name__)

@app.route("/", methods=['GET', 'POST'])
def hello():
    """Respond to incoming calls with a simple text message."""

    resp = twilio.twiml.Response()

    text_command = request.values.get('Body', None)
    text_command = text_command.strip().upper()

    if text_command and text_command not in ['ON','OFF','CAL','CALIBRATE']:
        resp.message("invalid command: " + text_command)

    elif text_command:
        # write text command to file
        print(text_command, file='status.txt')
        resp.message("Cat Detector status changed to: " + text_command)

    else:
        # no text_command, just try to get current status
        try:
            status = open('status.txt').readlines()[0].strip()
        except IOError:
            # default status is 'ON'
            status = 'ON'
            print(status, file='status.txt')
            resp.message(status)

    return str(resp)


if __name__ == "__main__":
    app.run(debug=True)<commit_msg>fixes broken writing to file twilio app<commit_after>from __future__ import print_function
import os
from flask import Flask, request, redirect
import twilio.twiml

app = Flask(__name__)

f = open('status.txt')

@app.route("/", methods=['GET', 'POST'])
def hello():
    """Respond to incoming calls with a simple text message."""

    text_command = request.values.get('Body', None)

    resp = twilio.twiml.Response()

    if text_command and text_command not in ['ON','OFF','CAL','CALIBRATE']:
        resp.message("invalid command: " + text_command)

    elif text_command:
        # write text command to file
        print(text_command, file=f)
        resp.message("Cat Detector status changed to: " + text_command)

    else:
        # no text_command, just try to get current status
        try:
            status = open('status.txt').readlines()[0].strip()
            resp.message(status)
        except IOError:
            # default status is 'ON'
            status = 'ON'
            print(status, file=f)
            resp.message(status)

    return str(resp)

if __name__ == "__main__":
    app.run(debug=True)
{'fraction_non_alphanumeric': 0.12132024977698483, 'fraction_numerical': 0.0008920606601248885, 'mean_word_length': 2.8407534246575343, 'pattern_counts': {'":': 2, '<': 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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2437867', 'n_tokens_mistral': 664, 'n_tokens_neox': 645, 'n_words': 188}