<commit_before>#!/usr/bin/env python
# coding=utf-8

import tornado.httpserver
import tornado.websocket
import tornado.ioloop
import tornado.web
import socket
import json
import signal
import logging
import time
import os.path
from threading import Timer
from Traductores.TraductoresHandler import TraductoresHandler, CONFIG_FILE_NAME, TraductorException
import ConfigParser






# chdir otherwise will not work fine in rc service
newpath = os.path.dirname(os.path.realpath(__file__))
os.chdir(newpath)




MAX_WAIT_SECONDS_BEFORE_SHUTDOWN = 2
INTERVALO_IMPRESORA_WARNING = 30.0

#global para el listado de clientes conectados
clients = []
# leer los parametros de configuracion de la impresora fiscal 
# en config.ini 
traductor = TraductoresHandler()

class WebSocketException(Exception):
	pass

 
class WSHandler(tornado.websocket.WebSocketHandler):

	def open(self):
		global clients
		clients.append(self)
		print 'new connection'
	
	def on_message(self, message):
		global traductor
		print("----- - -- - - - ---")
		print message
		try:
			jsonMes = json.loads(message, strict=False)
			print("***************")
			response = traductor.json_to_comando( jsonMes )
		except TypeError:
			print "error parseando el JSON:"
			print jsonMes
			print "- - - - - - - - - - - -"
			response = {"err": "Error parseando el JSON"}
		except TraductorException, e:
			response = {"err": "Traductor Comandos: %s"%str(e)}
		except Exception, e:
			response = {"err": repr(e)+"- "+str(e)}

			import sys, traceback
			traceback.print_exc(file=sys.stdout)

		print response
		self.write_message( response )<commit_msg>mejoras para eñes y acentos<commit_after>#!/usr/bin/env python
# coding=utf-8

import tornado.httpserver
import tornado.websocket
import tornado.ioloop
import tornado.web
import socket
import json
import signal
import logging
import time
import os.path
from threading import Timer
from Traductores.TraductoresHandler import TraductoresHandler, CONFIG_FILE_NAME, TraductorException
import ConfigParser






# chdir otherwise will not work fine in rc service
newpath = os.path.dirname(os.path.realpath(__file__))
os.chdir(newpath)




MAX_WAIT_SECONDS_BEFORE_SHUTDOWN = 2
INTERVALO_IMPRESORA_WARNING = 30.0

#global para el listado de clientes conectados
clients = []
# leer los parametros de configuracion de la impresora fiscal 
# en config.ini 
traductor = TraductoresHandler()

class WebSocketException(Exception):
	pass

 
class WSHandler(tornado.websocket.WebSocketHandler):

	def open(self):
		global clients
		clients.append(self)
		print 'new connection'
	
	def on_message(self, message):
		global traductor
		print("----- - -- - - - ---")
		print message
		try:
			jsonMes = json.loads(message, strict=False)
			print("***************")
			
		except TypeError:
			print "error parseando el JSON:"
			print jsonMes
			print "- - - - - - - - - - - -"
			response = {"err": "Error parseando el JSON"}
		except TraductorException, e:
			response = {"err": "Traductor Comandos: %s"%str(e)}
		except Exception, e:
			response = {"err": repr(e)+"- "+str(e)}

			import sys, traceback
			traceback.print_exc(file=sys.stdout)

		response = traductor.json_to_comando( jsonMes )

		print response
		self.write_message( response )
{'fraction_non_alphanumeric': 0.11124845488257108, 'fraction_numerical': 0.0030902348578491965, 'mean_word_length': 4.162679425837321, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1391068', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1061, 'n_words': 284}