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

"""
Receive Geo location data from the Gps2Udp Android application
and forward them to the stdout line by line.
"""

import getopt
import os.path
import socket
import sys

DEFAULT_PORT = 5000


def usage(exitcode = 1):
    """
    Show usage info and exit.
    """
    argv0 = os.path.basename(sys.argv[0])
    print 'Usage: {0} [options]'.format(argv0)
    print '  Options:'
    print '    --port=N   UDP port number to listen. Default is 5000.'
    sys.exit(exitcode)


def main():
    """
    Entry point.
    """
    try:
        cmd_opts, _cmd_args = getopt.getopt(
            sys.argv[1:], '', ['port='])
    except getopt.GetoptError as exc:
        print str(exc)
        usage()
    cmd_opts = dict(cmd_opts)
    port = int(cmd_opts.get('--port', str(DEFAULT_PORT)))
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(('', port))
    while True:
        data, _addr = sock.recvfrom(100)
        try:
            tokens = data.split(' ')
            _time = int(tokens[0])
        except Exception:
            continue
        sys.stdout.write(data)
        sys.stdout.flush()

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        sys.exit(1)
<commit_msg>server: fix error reporting on bad cmd args<commit_after>#!/usr/bin/env python

"""
Receive Geo location data from the Gps2Udp Android application
and forward them to the stdout line by line.
"""

import getopt
import os.path
import socket
import sys

DEFAULT_PORT = 5000


def usage(exitcode = 1):
    """
    Show usage info and exit.
    """
    argv0 = os.path.basename(sys.argv[0])
    print 'Usage: {0} [options]'.format(argv0)
    print '  Options:'
    print '    --port=N   UDP port number to listen. Default is 5000.'
    sys.exit(exitcode)


def main():
    """
    Entry point.
    """
    try:
        cmd_opts, _cmd_args = getopt.getopt(
            sys.argv[1:], '', ['port='])
    except getopt.GetoptError as exc:
        sys.stderr.write('Error: ' + str(exc) + '\n')
        usage()
    cmd_opts = dict(cmd_opts)
    port = int(cmd_opts.get('--port', str(DEFAULT_PORT)))
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(('', port))
    while True:
        data, _addr = sock.recvfrom(100)
        try:
            tokens = data.split(' ')
            _time = int(tokens[0])
        except Exception:
            continue
        sys.stdout.write(data)
        sys.stdout.flush()

if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        sys.exit(1)

{'fraction_non_alphanumeric': 0.13181291070738307, 'fraction_numerical': 0.015461925009663703, 'mean_word_length': 2.313700384122919, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3462566', 'n_tokens_mistral': 882, 'n_tokens_neox': 843, 'n_words': 222}