Commit ba4585a0 authored by Gabriel Monnerat's avatar Gabriel Monnerat

refactor to send data via json

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk/utils@41720 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent a284aa6b
......@@ -28,6 +28,7 @@
##############################################################################
import sys
import json
import helper_utils
from os import environ, path, putenv
from getopt import getopt, GetoptError
......@@ -127,7 +128,7 @@ def main():
if not opt_list:
help()
for opt, arg in opt_list:
if opt in ("-h", "--help"):
help()
......@@ -143,7 +144,8 @@ def main():
mimemapper = UnoMimemapper(hostname, port, **dict(environ))
filter_dict = mimemapper.getFilterDict()
type_dict = mimemapper.getTypeDict()
print "filter_dict = %s\ntype_dict = %s" % (filter_dict, type_dict)
print json.dumps((filter_dict, type_dict))
if "__main__" == __name__:
main()
......@@ -35,6 +35,7 @@ from os import environ, path
from interfaces.mimemapper import IMimemapper
from types import InstanceType
from utils import getCleanPythonEnvironment
import json
class MimeMapper(object):
......@@ -107,21 +108,21 @@ class MimeMapper(object):
uno_path = kw.get("uno_path", environ.get('uno_path'))
office_binary_path = kw.get("office_binary_path",
environ.get('office_binary_path'))
args = [path.join(office_binary_path, "python"),
command = [path.join(office_binary_path, "python"),
pkg_resources.resource_filename(__name__,
path.join("helper", "unomimemapper.py")),
"--uno_path=%s" % uno_path,
"--office_binary_path=%s" % office_binary_path,
"--hostname=%s" % hostname,
"--port=%s" % port]
stdout, stderr = Popen(args,
stdout, stderr = Popen(command,
stdout=PIPE,
close_fds=True,
env=getCleanPythonEnvironment()).communicate()
# XXX Use json here
exec(stdout)
for key, value in filter_dict.iteritems():
filter_name = key
filter_dict, type_dict = json.loads(stdout)
for filter_name, value in filter_dict.iteritems():
flag = value.get("Flags")
if flag in bad_flag_list:
continue
......
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