Commit 5e60b9cb authored by Jerome Mariette's avatar Jerome Mariette
Browse files

fixe some binary encoding bugs with the new version of cherrypy

parent 3e23af97
......@@ -121,10 +121,8 @@ def regexpfiles(files_pattern):
return files_pattern
def create_test_function(itype):
try: itype = itype.encode('ascii','ignore')
except: pass
try:
ctype, csizel = itype.split(AbstractInputFile.SIZE_LIMIT_SPLITER)
ctype, csizel = itype.split(AbstractInputFile.SIZE_LIMIT_SPLITER)
def inner_function(ifile):
# first eval the asked type
returned_value = eval(ctype)(ifile)
......@@ -158,6 +156,7 @@ def create_test_function(itype):
raise argparse.ArgumentTypeError("URL '" + file + "' is invalid!")
# then test the type
return returned_value
inner_function.__name__ = ctype+AbstractInputFile.SIZE_LIMIT_SPLITER+csizel
return inner_function
except:
......
......@@ -374,7 +374,7 @@ class JFlowServer (object):
if isinstance(kwargs[file_param], list):
for cfile in kwargs[file_param]:
FH_sever_file = open(os.path.join(file_dir, cfile.filename.encode('ascii','ignore')), "w")
FH_sever_file = open(os.path.join(file_dir, cfile.filename), "w")
while True:
data = cfile.file.read(8192)
if not data:
......@@ -382,7 +382,7 @@ class JFlowServer (object):
FH_sever_file.write(data)
FH_sever_file.close()
else:
FH_sever_file = open(os.path.join(file_dir, kwargs[file_param].filename.encode('ascii','ignore')), "w")
FH_sever_file = open(os.path.join(file_dir, kwargs[file_param].filename), "w")
while True:
data = kwargs[file_param].file.read(8192)
if not data:
......@@ -426,12 +426,12 @@ class JFlowServer (object):
for cfile in currentFile:
os.link(
cfile.get_file_name(),
os.path.join(fileDir, cfile.filename.encode('ascii','ignore'))
os.path.join(fileDir, cfile.filename)
)
else:
os.link(
currentFile.get_file_name(),
os.path.join(fileDir, currentFile.filename.encode('ascii','ignore'))
os.path.join(fileDir, currentFile.filename)
)
@cherrypy.expose
......@@ -508,9 +508,9 @@ class JFlowServer (object):
# if it's an append parameter, let's check each value
if kwargs["action"] == "append":
for cval in kwargs[value_key].split("\n"):
create_test_function(kwargs["type"])(cval.encode('utf8'))
create_test_function(kwargs["type"])(cval)
else:
create_test_function(kwargs["type"])(kwargs[value_key].encode('utf8'))
create_test_function(kwargs["type"])(kwargs[value_key])
return True
except Exception as e:
return str(e)
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment