Commit b1ca750fa383ec3e75758e7fb5e0330c012add51

Authored by Wesnydy Ribeiro
1 parent 3cee1828
Exists in release

translator worker release

Showing 1 changed file with 4 additions and 7 deletions   Show diff stats
core/translator.py
... ... @@ -41,9 +41,6 @@ ch.setFormatter(formatter)
41 41 logger.addHandler(fh)
42 42 logger.addHandler(ch)
43 43  
44   -#conn_send = pika.BlockingConnection(pika.ConnectionParameters(host='localhost',heartbeat_interval=0))
45   -#conn_receive = pika.BlockingConnection(pika.ConnectionParameters(host='localhost',heartbeat_interval=0))
46   -
47 44 manager = PikaManager.PikaManager("150.165.205.10", "test", "test")
48 45  
49 46 def run(ch, method, properties, body):
... ... @@ -61,20 +58,20 @@ def run(ch, method, properties, body):
61 58 body : json object
62 59 Informations received from queue.
63 60 """
64   - logger.info("Processando a requisição " + properties.correlation_id.encode("utf-8"))
65 61 # body it's a json that contains text to be translating
66 62 body = json.loads(body)
67   - print ("Translating...",)
  63 + print ("Translating...")
68 64 # Initialize the translation of text
69   - logger.info("Traduzindo texto")
70 65 try:
  66 + logger.info("Traduzindo: "+body["text"]+" id: "+properties.correlation_id.encode("utf-8"))
71 67 gloss = traduzir(body["text"].encode("utf-8"))
72 68 body["gloss"] = gloss
73 69 del body["text"]
74 70 except KeyError:
  71 + logger.info("Não existe texto para traduzir")
75 72 pass
76 73 # Send the body to the queue
77   - logger.info("Enviando para a fila de traduções")
  74 + logger.info("Enviando glosa para a fila de traduções")
78 75 manager.send_to_queue("translations", body, properties)
79 76 print ("Success")
80 77  
... ...