@app.route('/start', methods=['POST'])
def start():
    data = request.get_json()
    source_ip = data['source_ip']
    destination_host = data['destination_host']
    interface = data['interface']
    destination_port = data['destination_port']

    # Check if a same sniffer already exists
    if (source_ip, destination_host) in sniffers:
        err = '409 - Sniffer (source_ip: {}, destination_host: {}) already exists.'.format(source_ip, destination_host)
        logger.warning(err)
        return str(err), 409

    params = {'source_ip': source_ip,
              'destination_host': destination_host,
              'interface': interface,
              'destination_port': destination_port}

    # Check if parameters are invalid
    try:
        sniffer = Sniffer(params)
    except AssertionError, err:
        logger.warning(err)
        return str(err), 400

    sniffers[(source_ip, destination_host)] = sniffer

    # Start the new sniffer thread and block until it has come to life
    sniffer.start()
    while not sniffer.is_alive():
        sleep(0.01)
    msg = 'Sniffer (source_ip: {}, destination_host: {}) is alive.'.format(source_ip, destination_host)
    logger.debug(msg)

    return msg, 201
Rollback active transactions
dataset/ETHPy150Open dionyziz/rupture/sniffer/sniff.py/start--crossover with--dataset/ETHPy150Open RDFLib/rdflib/rdflib/graph.py/Graph.rollback