def __init__(self, exchange, key, qThread): c = Config() self.exchange = exchange self.routing_key = key self.qThread = qThread rmq_host = str(c.host) rmq_port = c.port rmq_username = c.username rmq_password = c.password print "connecting with username", rmq_username, "and password", rmq_password if rmq_username: if rmq_password: print( "Connection established" if RabbitMQ.establishConnection( rmq_host, rmq_port, rmq_username, rmq_password) else "Failed to connect") else: print( "Connection established" if RabbitMQ.establishConnection( rmq_host, rmq_port, rmq_username) else "Failed to connect") else: print("Connection established" if RabbitMQ.establishConnection( rmq_host, rmq_port) else "Failed to connect") print "start listening on", rmq_host, "with port", rmq_port print "waiting for", key, "on exchange", exchange
def __init__(self, exchange, key): self.host = "131.227.92.55" self.port = 8007 self.connection, self.channel = RabbitMQ.establishConnection(self.host, self.port) self.exchange = exchange self.routing_key = key
def __init__(self, exchange, key): self.host = "131.227.92.55" self.port = 8007 self.connection, self.channel = RabbitMQ.establishConnection( self.host, self.port) self.exchange = exchange self.routing_key = key
def __init__(self, exchange, key, qThread): c = Config() self.exchange = exchange self.routing_key = key self.qThread = qThread rmq_host = str(c.host) rmq_port = c.port rmq_username = c.username rmq_password = c.password print "connecting with username", rmq_username, "and password", rmq_password if rmq_username: if rmq_password: print ("Connection established" if RabbitMQ.establishConnection(rmq_host, rmq_port, rmq_username, rmq_password) else "Failed to connect") else: print ("Connection established" if RabbitMQ.establishConnection(rmq_host, rmq_port, rmq_username) else "Failed to connect") else: print ("Connection established" if RabbitMQ.establishConnection(rmq_host, rmq_port) else "Failed to connect") print "start listening on", rmq_host, "with port", rmq_port print "waiting for", key, "on exchange", exchange
def __init__(self, exchange, key): self.config = JOb(file(os.path.join(os.path.dirname(__file__), "..", "virtualisation", "config.json"), "rb")) # self.host = self.config.rabbitmq.host # self.port = self.config.rabbitmq.port self.exchange = exchange self.routing_key = key rmq_host = str(self.config.rabbitmq.host) rmq_port = self.config.rabbitmq.port rmq_username = self.config.rabbitmq.username if "username" in self.config.rabbitmq else None rmq_password = self.config.rabbitmq.password if "password" in self.config.rabbitmq else None print "connecting with", rmq_username, "and", rmq_password if rmq_username: if rmq_password: print ("Connection established" if RabbitMQ.establishConnection(rmq_host, rmq_port, rmq_username, rmq_password) else "Failed to connect") else: print ("Connection established" if RabbitMQ.establishConnection(rmq_host, rmq_port, rmq_username) else "Failed to connect") else: print ("Connection established" if RabbitMQ.establishConnection(rmq_host, rmq_port) else "Failed to connect") print "start listening on", rmq_host, "with port", rmq_port print "waiting for", key, "on exchange", exchange
def hello_IoT_world(): # establish connection host = "131.227.92.55" port = 8007 rabbitmqconnection, rabbitmqchannel = RabbitMQ.establishConnection(host, port) # declare exchange exchange = 'Social_data' topic1 = 'Aarhus' topic2 = 'Aarhus.Traffic.SensorID002' RabbitMQ.declareExchange(rabbitmqchannel, exchange, _type="topic") json = make_message() RabbitMQ.sendMessage(json, rabbitmqchannel, exchange, topic1) time.sleep(10)
def __init__(self, exchange, key, seconds_delay, repetitions): self.config = JOb(file(os.path.join(os.path.dirname(__file__), "..", "virtualisation", "config.json"), "rb")) self.host = self.config.rabbitmq.host self.port = self.config.rabbitmq.port print "Start listening on", self.host, "with port", self.port print "Waiting for topic", key, "on exchange", exchange self.connection, self.channel = RabbitMQ.establishConnection(self.host, self.port) self.exchange = exchange self.routing_key = key RabbitMQ.declareExchange(self.channel, self.exchange, _type='topic') self.seconds_delay = seconds_delay self.repetitions = repetitions self.timer = None self.q = Queue() self.lock = Lock()
"CrimeEvent", "SocialEvent", "CulturalEvent", "TransportationEvent", "HealthEvent", "SportEvent", "EnvironmentalEvent", "FoodEvent" ] label_list2 = [ '<B-CRIME>', '<B-SOCIAL>', '<B-CULTURAL>', '<B-TRAFFIC>', '<B-HEALTH>', '<B-SPORT>', '<B-WEATHER>', '<B-FOOD>', '<I-CRIME>', '<I-SOCIAL>', '<I-CULTURAL>', '<I-TRAFFIC>', '<I-HEALTH>', '<I-SPORT>', '<I-WEATHER>', '<I-FOOD>' ] Loc_label = ['<B-LOCATION>', '<I-LOCATION>'] gran_event_df = pd.read_csv(dictionary_folder + 'GranuralDic.csv', sep="<>") #Message Bus setting: Host = "server IP" Port = 8007 rabbitmqconnection, rabbitmqchannel = RabbitMQ.establishConnection(Host, Port) # declare exchange exchange = 'event' topic = 'Aarhus.Twitter' #connecting to google translate API Timer = NOW.minute gs = goslate.Goslate() while start_flag: Sleep = 0 start = time.clock() loaded_data = load_data_from_mysqlDB(NOW, step, delay) trans_df, raw_df, noData_flag, Now, ED_flag = loaded_data[0], loaded_data[ 1], loaded_data[2], loaded_data[3], loaded_data[4] if noData_flag: stop = time.clock()
start_flag=1 CRFDic_tag=Load_Tag('CRFDic_tag.txt') CNN_NER_tag=Load_Tag('CNN_NER_tag.txt') CRFDic_tag.pop(-1) CNN_Loc_tag=CNN_NER_tag[:7] LocTags=['B-LOCATION>','I-LOCATION>']+CNN_Loc_tag label_list=["-CRIME>", "-SOCIAL>", "-CULTURAL>", "-TRAFFIC>", "-HEALTH>", "-SPORT>", "-WEATHER>","-FOOD>"] Type_list=["CrimeEvent", "SocialEvent", "CulturalEvent", "TransportationEvent", "HealthEvent", "SportEvent", "EnvironmentalEvent","FoodEvent"] label_list2=['<B-CRIME>', '<B-SOCIAL>', '<B-CULTURAL>', '<B-TRAFFIC>', '<B-HEALTH>', '<B-SPORT>', '<B-WEATHER>', '<B-FOOD>', '<I-CRIME>', '<I-SOCIAL>', '<I-CULTURAL>', '<I-TRAFFIC>', '<I-HEALTH>', '<I-SPORT>', '<I-WEATHER>', '<I-FOOD>'] Loc_label=[ '<B-LOCATION>','<I-LOCATION>'] gran_event_df=pd.read_csv(dictionary_folder+'GranuralDic.csv', sep="<>") #Message Bus setting: Host = "server IP" Port = 8007 rabbitmqconnection, rabbitmqchannel = RabbitMQ.establishConnection(Host, Port) # declare exchange exchange = 'event' topic = 'Aarhus.Twitter' #connecting to google translate API Timer=NOW.minute gs = goslate.Goslate() while start_flag: Sleep=0 start = time.clock() loaded_data=load_data_from_mysqlDB(NOW,step,delay) trans_df,raw_df,noData_flag,Now,ED_flag=loaded_data[0],loaded_data[1],loaded_data[2],loaded_data[3],loaded_data[4] if noData_flag: stop=time.clock() processing_time=stop-start