Non travis env and py3 no-unicode fix

This commit is contained in:
2015-12-24 12:49:59 +05:30
parent a127bc4af7
commit 43f875e18c
+7 -4
View File
@@ -14,7 +14,7 @@ if env_redis_port:
else:
REDIS_PORT = 5946
if os.environ["TRAVIS"] == "true":
if os.environ.get("TRAVIS") == "true":
command_redis_server_gen = "redis-server --port {port}"
else:
command_redis_server_gen = "redis-server --port {port} --maxheap 20MB"
@@ -42,17 +42,20 @@ def s(input_):
If list, do it for all of them.
If others, return as is. '''
import sys
PY3 = sys.version_info > (3,)
if hasattr(input_, "__iter__"):
return [s(ele) for ele in input_]
try:
if PY3:
assert(type(input_) in [str, unicode, bytes])
else:
assert(type(input_) in [str, bytes])
except AssertionError:
return input_
import sys
PY3 = sys.version_info > (3,)
if PY3:
if type(input_) == bytes:
str_ = bytes.decode(input_)