<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import logging

from raven import Client

from .server import Lights433Server
import clip

app = clip.App()

DEFAULT_SWITCH_CONF = "/etc/lights-433/switches.conf"
DEFAULT_SENTRY_CONF = "/etc/lights-433/sentry.conf"

log = logging.getLogger(__name__)


@app.main(description='An HTTP server daemon for controlling 433MHz '
                      'light switches')
@clip.arg('serial', required=True, help='The port to the serial device '
                                        'that generates the signals')
@clip.opt('--host', default='127.0.0.1', type=str,
          help='The interface to listen and permit connections on')
@clip.opt('--port', default=8080, type=int,
          help='The port to run the server on')
@clip.opt('--baud', required=False, default=9600, type=int,
          help='Baud rate of the serial interface')
@clip.opt('--timeout', required=False, default=1, type=int,
          help='The timeout of the serial interface')
@clip.arg('--switches', required=True, default=DEFAULT_SWITCH_CONF, type=str,
          help='Path to the config file for users and signals')
@clip.opt('--sentry', required=False, default=DEFAULT_SENTRY_CONF, type=str,
          help='Path to the config file containing the Sentry capture URL')
@clip.flag('--resettable',
           help='Enables device resetting over pin 3 (assumed RPi)')
def lights433(host, port, resettable, serial, baud, timeout, switches, sentry):
    if sentry:
        with open(sentry, 'r') as f:
            url = f.read()
        if not url and sentry == DEFAULT_SENTRY_CONF:
            log.warn("No sentry URL specified in [%s]" % DEFAULT_SENTRY_CONF)
        else:
            sentry_client = Client(url)
        log.info("Sentry client configured!")

    log.info("Loading switch configurations from [%s]" % DEFAULT_SWITCH_CONF)
    server = Lights433Server(host, port, serial, baud, timeout, switches,
                             resettable, locals().get('sentry_client', None))
    server.run()


def main():
    try:
        app.run()
    except clip.ClipExit:
        pass

if __name__ == '__main__':
    main()
<commit_msg>Fixed required flag<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

import logging

from raven import Client

from .server import Lights433Server
import clip

app = clip.App()

DEFAULT_SWITCH_CONF = "/etc/lights-433/switches.conf"
DEFAULT_SENTRY_CONF = "/etc/lights-433/sentry.conf"

log = logging.getLogger(__name__)


@app.main(description='An HTTP server daemon for controlling 433MHz '
                      'light switches')
@clip.arg('serial', required=True, help='The port to the serial device '
                                        'that generates the signals')
@clip.opt('--host', default='127.0.0.1', type=str,
          help='The interface to listen and permit connections on')
@clip.opt('--port', default=8080, type=int,
          help='The port to run the server on')
@clip.opt('--baud', required=False, default=9600, type=int,
          help='Baud rate of the serial interface')
@clip.opt('--timeout', default=1, type=int,
          help='The timeout of the serial interface')
@clip.arg('--switches', default=DEFAULT_SWITCH_CONF, type=str,
          help='Path to the config file for users and signals')
@clip.opt('--sentry', default=DEFAULT_SENTRY_CONF, type=str,
          help='Path to the config file containing the Sentry capture URL')
@clip.flag('--resettable',
           help='Enables device resetting over pin 3 (assumed RPi)')
def lights433(host, port, resettable, serial, baud, timeout, switches, sentry):
    if sentry:
        with open(sentry, 'r') as f:
            url = f.read()
        if not url and sentry == DEFAULT_SENTRY_CONF:
            log.warn("No sentry URL specified in [%s]" % DEFAULT_SENTRY_CONF)
        else:
            sentry_client = Client(url)
        log.info("Sentry client configured!")

    log.info("Loading switch configurations from [%s]" % DEFAULT_SWITCH_CONF)
    server = Lights433Server(host, port, serial, baud, timeout, switches,
                             resettable, locals().get('sentry_client', None))
    server.run()


def main():
    try:
        app.run()
    except clip.ClipExit:
        pass

if __name__ == '__main__':
    main()

{'fraction_non_alphanumeric': 0.1253717684740334, 'fraction_numerical': 0.01601464195836193, 'mean_word_length': 2.9817850637522767, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '741364', 'n_tokens_mistral': 1357, 'n_tokens_neox': 1280, 'n_words': 381}