Fixed int and float compression errors
This commit is contained in:
parent
07031d719c
commit
1105b0fc8c
1 changed files with 7 additions and 3 deletions
|
@ -50,18 +50,20 @@ class Meta:
|
||||||
def run(self, data, handler):
|
def run(self, data, handler):
|
||||||
if type(data) is dict:
|
if type(data) is dict:
|
||||||
handler.peer_exchange_routes = data
|
handler.peer_exchange_routes = data
|
||||||
Logging.success("Received peer exchange routes: %s" % str(data))
|
if handler.debug:
|
||||||
|
Logging.success("Received peer exchange routes: %s" % str(data))
|
||||||
handler.peer_reverse_exchange_routes = reverse_dict(handler.peer_exchange_routes)
|
handler.peer_reverse_exchange_routes = reverse_dict(handler.peer_exchange_routes)
|
||||||
if issubclass(handler.__class__, Client):
|
if issubclass(handler.__class__, Client):
|
||||||
handler.send(handler.exchange_routes, META_ROUTE, indexed_dict=True)
|
handler.send(handler.exchange_routes, META_ROUTE, indexed_dict=True)
|
||||||
try:
|
try:
|
||||||
handler.ready()
|
handler.ready()
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
Logging.warning("Consider to add a ready method to your handler. "
|
pass
|
||||||
"Without one, it's pretty much useless.")
|
|
||||||
if handler.debug:
|
if handler.debug:
|
||||||
Logging.info("Launching routes.")
|
Logging.info("Launching routes.")
|
||||||
Routing.launch_routes(handler.routes, handler)
|
Routing.launch_routes(handler.routes, handler)
|
||||||
|
if handler.debug:
|
||||||
|
Logging.info("Routes launched.")
|
||||||
if type(data) is int:
|
if type(data) is int:
|
||||||
if data == 1:
|
if data == 1:
|
||||||
Logging.error("Last route was invalid.")
|
Logging.error("Last route was invalid.")
|
||||||
|
@ -87,6 +89,8 @@ def prepare_data(data):
|
||||||
data_type = DATA_TYPES[bytes]
|
data_type = DATA_TYPES[bytes]
|
||||||
if original_data_type is str:
|
if original_data_type is str:
|
||||||
data = data.encode()
|
data = data.encode()
|
||||||
|
elif original_data_type in (int, float):
|
||||||
|
data = str(data).encode()
|
||||||
elif original_data_type is dict or original_data_type is list:
|
elif original_data_type is dict or original_data_type is list:
|
||||||
data = json.dumps(data, separators=(',',':')).encode()
|
data = json.dumps(data, separators=(',',':')).encode()
|
||||||
elif original_data_type is NoneType:
|
elif original_data_type is NoneType:
|
||||||
|
|
Reference in a new issue