Commit 3b7bbafa authored by Gabriel Monnerat's avatar Gabriel Monnerat

fixed Bug #2014. refactor code to convert data to base64. With this, is...

fixed Bug #2014. refactor code to convert data to base64. With this, is possible send data with quotes

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@38939 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9c7e088f
......@@ -27,6 +27,7 @@
##############################################################################
import jsonpickle, pkg_resources
from base64 import decodestring, encodestring
from os import environ, path
from subprocess import Popen, PIPE
from cloudooo.application.openoffice import openoffice
......@@ -38,7 +39,6 @@ from cloudooo.document import FileSystemDocument
from cloudooo.monitor.timeout import MonitorTimeout
from cloudooo.utils import logger
from psutil import pid_exists
from sys import executable as python_path
class OOHandler:
"""OOHandler is used to access the one Document and OpenOffice.
......@@ -79,9 +79,9 @@ class OOHandler:
, "--document_url='%s'" % self.document.getUrl()
, "--jsonpickle_path='%s'" % jsonpickle_path]
for arg in args:
command_list.insert(3, "'--%s'" % arg)
command_list.insert(3, "--%s" % arg)
for k, v in kw.iteritems():
command_list.append("'--%s=%s'" % (k,v))
command_list.append("--%s='%s'" % (k,v))
return ' '.join(command_list)
......@@ -194,8 +194,7 @@ class OOHandler:
openoffice.release()
if self.monitor.is_alive():
self._stopTimeout()
metadata={}
exec("metadata=%s" % stdout)
metadata=jsonpickle.decode(decodestring(stdout))
if metadata.get("Data"):
self.document.reload(metadata['Data'])
metadata['Data'] = self.document.getContent()
......@@ -213,7 +212,7 @@ class OOHandler:
openoffice.acquire()
metadata_pickled = jsonpickle.encode(metadata)
logger.debug("setMetadata")
kw = dict(metadata=metadata_pickled)
kw = dict(metadata=encodestring(metadata_pickled))
try:
stdout, stderr = self._callUnoConverter(*['setmetadata'], **kw)
finally:
......
......@@ -33,6 +33,7 @@ from types import UnicodeType, InstanceType
from os import environ, putenv
from os.path import dirname, exists
from tempfile import mktemp
from base64 import decodestring, encodestring
from getopt import getopt, GetoptError
__doc__ = """
......@@ -298,6 +299,7 @@ def main():
elif opt == '--source_format':
source_format = arg
elif opt == '--metadata':
arg = decodestring(arg)
metadata = jsonpickle.decode(arg)
elif opt == '--mimemapper':
mimemapper = jsonpickle.decode(arg)
......@@ -319,10 +321,12 @@ def main():
elif '--convert' in param_list and 'destination_format' in locals():
output = unoconverter.convert(destination_format)
elif '--getmetadata' in param_list and not '--convert' in param_list:
output = unoconverter.getMetadata()
metadata_dict = unoconverter.getMetadata()
output = encodestring(jsonpickle.encode(metadata_dict))
elif '--getmetadata' in param_list and '--convert' in param_list:
output = unoconverter.getMetadata()
output['Data'] = unoconverter.convert()
metadata_dict = unoconverter.getMetadata()
metadata_dict['Data'] = unoconverter.convert()
output = encodestring(jsonpickle.encode(metadata_dict))
elif '--setmetadata' in param_list:
unoconverter.setMetadata(metadata)
output = document_url
......
Markdown is supported
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