예제 #1
0
def rabbitmqConnection(options):
    while True:
        connection = app.connection.connectionPack()
        channel = connection.channel()
        channel.exchange_declare(exchange='test',
                                 exchange_type='direct',
                                 passive=False,
                                 durable=True,
                                 auto_delete=False)

        for scan_type in options:
            channel.queue_declare(queue=scan_type, exclusive=False)
            channel.queue_bind(exchange='test',
                               queue=scan_type,
                               routing_key=scan_type)
            channel.basic_qos(prefetch_count=1)

            threads = []
            on_message_callback = functools.partial(on_message,
                                                    args=(connection, threads))
            channel.basic_consume(scan_type, on_message_callback)

        try:
            channel.start_consuming()
        except KeyboardInterrupt:
            channel.stop_consuming()
            connection.close()
            break
        except:
            # Wait for all to complete
            for thread in threads:
                thread.join()
            connection.close()
            continue
예제 #2
0
 def get_nearest(self, myCoords=[13.964049, 48.136443]):
     coll = connection.BSOOE.febs
     nearest_list = []
     myLoc = {"$geometry":{"type":"Point", "coordinates": myCoords}}
     query = coll.find({"loc": {"$near": myLoc}}).limit(1)
     for doc in query:
         nearest_list.append(doc)
     connection.close()
     return nearest_list
예제 #3
0
def get_number_of_solutions():
    nro_soluciones = []
    print()
    for i in range(1, 13):
        solver = BacktrackingNQueensOptimizedSafetyCheck(i)
        solver.run()
        nro = solver.get_number_of_solutions()
        nro_soluciones.append(nro)
        print(f' N : {i}, total soluciones : {nro}')
    connection.close()
    return nro_soluciones
예제 #4
0
#!/usr/bin/env python3
from app import BacktrackingNQueensOptimizedSafetyCheck
from app import flat_matrix, save_solutions, connection
import datetime
import sys

if __name__ == "__main__":
    start_time = datetime.datetime.now()
    for i in range(1, 20):
        solver = BacktrackingNQueensOptimizedSafetyCheck(i)
        for board in solver.get_boards():
            flatten = flat_matrix(board)
            save_solutions(i, board)
            elapsed_time = datetime.datetime.now() - start_time
            print(elapsed_time, i, solver.get_number_of_solutions(), flatten)
            if elapsed_time > datetime.timedelta(minutes=10):
                sys.exit(0)
    connection.close()
예제 #5
0
 def get_boundaries(self):
     coll = connection.BSOOE.bound
     state_boundary = coll.find({"name": "state_boundary"})
     connection.close()
     return state_boundary
예제 #6
0
 def get_unbekannt(self):
     coll = connection.BSOOE.febs
     unbekannte = coll.find({"type": "unb"})
     connection.close()
     return unbekannte
예제 #7
0
 def get_schloesser(self):
     coll = connection.BSOOE.febs
     schloesser = coll.find({"type": "Schloss"})
     connection.close()        
     return schloesser
예제 #8
0
 def get_burgen(self):
     coll = connection.BSOOE.febs
     burgen = coll.find({"type": "Burg"})
     connection.close()
     return burgen