Commit 59a04869 authored by Julien Muchembled's avatar Julien Muchembled

Py3 fixes

parent 6999afe9
...@@ -89,7 +89,7 @@ class Handler(object): ...@@ -89,7 +89,7 @@ class Handler(object):
kw['hostname'] = hostname kw['hostname'] = hostname
kw['port'] = port kw['port'] = port
python = path.join(self.office_binary_path, "python") python = path.join(self.office_binary_path, "python")
command_list = [path.exists(python) and python or "python", command_list = [path.exists(python) and python or "python3",
pkg_resources.resource_filename(__name__, pkg_resources.resource_filename(__name__,
path.join("helper", "unoconverter.py")), path.join("helper", "unoconverter.py")),
"--uno_path=%s" % self.uno_path, "--uno_path=%s" % self.uno_path,
......
...@@ -35,7 +35,7 @@ import codecs ...@@ -35,7 +35,7 @@ import codecs
import helper_util import helper_util
from os.path import dirname, splitext from os.path import dirname, splitext
from tempfile import mktemp from tempfile import mktemp
from base64 import decodestring, encodestring from base64 import b64encode, b64decode
from getopt import getopt, GetoptError from getopt import getopt, GetoptError
try: try:
...@@ -342,7 +342,7 @@ def main(): ...@@ -342,7 +342,7 @@ def main():
elif opt == '--refresh': elif opt == '--refresh':
refresh = json.loads(arg) refresh = json.loads(arg)
elif opt == '--metadata': elif opt == '--metadata':
arg = decodestring(arg.encode('ascii')).decode('utf-8') arg = b64decode(arg).decode('utf-8')
metadata = json.loads(arg) metadata = json.loads(arg)
elif opt == '--mimemapper': elif opt == '--mimemapper':
mimemapper = json.loads(arg) mimemapper = json.loads(arg)
...@@ -357,7 +357,7 @@ def main(): ...@@ -357,7 +357,7 @@ def main():
output = unoconverter.convert(destination_format) output = unoconverter.convert(destination_format)
elif '--getmetadata' in param_list and not '--convert' in param_list: elif '--getmetadata' in param_list and not '--convert' in param_list:
metadata_dict = unoconverter.getMetadata() metadata_dict = unoconverter.getMetadata()
output = encodestring(json.dumps(metadata_dict).encode('utf-8')).decode('utf-8') output = b64encode(json.dumps(metadata_dict).encode('utf-8')).decode()
elif '--getmetadata' in param_list and '--convert' in param_list: elif '--getmetadata' in param_list and '--convert' in param_list:
document_url = unoconverter.convert() document_url = unoconverter.convert()
# Instanciate new UnoConverter instance with new url # Instanciate new UnoConverter instance with new url
...@@ -365,7 +365,7 @@ def main(): ...@@ -365,7 +365,7 @@ def main():
uno_path, office_binary_path, refresh) uno_path, office_binary_path, refresh)
metadata_dict = unoconverter.getMetadata() metadata_dict = unoconverter.getMetadata()
metadata_dict['document_url'] = document_url metadata_dict['document_url'] = document_url
output = encodestring(json.dumps(metadata_dict).encode('utf-8')).decode('utf-8') output = b64encode(json.dumps(metadata_dict).encode('utf-8')).decode()
elif '--setmetadata' in param_list: elif '--setmetadata' in param_list:
unoconverter.setMetadata(metadata) unoconverter.setMetadata(metadata)
output = document_url output = document_url
......
...@@ -118,7 +118,7 @@ class MimeMapper(object): ...@@ -118,7 +118,7 @@ class MimeMapper(object):
office_binary_path = kw.get("office_binary_path", office_binary_path = kw.get("office_binary_path",
environ.get('office_binary_path')) environ.get('office_binary_path'))
python = path.join(office_binary_path, "python") python = path.join(office_binary_path, "python")
command = [path.exists(python) and python or "python", command = [path.exists(python) and python or "python3",
pkg_resources.resource_filename(__name__, pkg_resources.resource_filename(__name__,
path.join("helper", "unomimemapper.py")), path.join("helper", "unomimemapper.py")),
"--uno_path=%s" % uno_path, "--uno_path=%s" % uno_path,
......
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