Example #1
0
def get_records(cur):
    cached = mclient.get(CACHE_KEY)
    if cached:
        print_success('Found the cached version instead')
        return cached
    else:
        print_warning('Looking up SQL Records')
        cur.execute('SELECT * FROM cache_table;')
        records = cur.fetchall()
        conn.commit()
        # Setup caching once loaded
        mclient.set(CACHE_KEY, records)
        return records
Example #2
0
def get_records(cur):
    cached = mclient.get(CACHE_KEY)
    if cached:
        print_success('Found the cached version instead')
        return cached
    else:
        print_warning('Looking up SQL Records')
        cur.execute('SELECT * FROM cache_table;')
        records = cur.fetchall()
        conn.commit()
        # Setup caching once loaded
        mclient.set(CACHE_KEY, records)
        return records
Example #3
0
def on_open(ch, method, properties, body):
    key = method.routing_key
    message = '* Received! {}'.format(body)
    if key == 'info':
        print_info(message)
    if key == 'warning':
        print_warning(message)
    if key == 'error':
        print_error(message)
    if key == 'success':
        print_success(message)

    if not start.USE_EXCHANGE:
        # Specify ACK to prevent failures from disappearing.
        ch.basic_ack(delivery_tag=method.delivery_tag)
Example #4
0
def on_open(ch, method, properties, body):
    key = method.routing_key
    message = '* Received! {}'.format(body)
    if key == 'info':
        print_info(message)
    if key == 'warning':
        print_warning(message)
    if key == 'error':
        print_error(message)
    if key == 'success':
        print_success(message)

    if not start.USE_EXCHANGE:
        # Specify ACK to prevent failures from disappearing.
        ch.basic_ack(delivery_tag=method.delivery_tag)