Commit f8a696aa authored by Marco Mariani's avatar Marco Mariani

abilian: unoconv drop-in replacement

parent 37d8473c
......@@ -174,8 +174,11 @@ class JsonDump(Recipe):
with os.fdopen(os.open(self._json_output, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o600), 'w') as fout:
fout.write(json.dumps(parameter_dict, indent=2, sort_keys=True))
def install(self):
return [self._json_output]
# also augment the buildout section
options.update(parameter_dict)
update = install
def install(self):
return [self._json_output]
update = install
#!/usr/bin/env cloudoooconv-python
# -*- coding: utf-8 -*-
import argparse
import os
# ./conv.py -f pdf -o hello.pdf hello.odp
__version__ = '0.1'
import base64
import sys
import xmlrpclib
import mimetypes
import magic
extension_remap = {
'.xlb': '.xls'
}
def process_file(in_fn, out_fn, fmt):
cloudooo_uri = os.environ['CLOUDOOO_URI']
proxy = xmlrpclib.ServerProxy(cloudooo_uri, allow_none=True)
with file(in_fn) as fin:
data = fin.read()
input_mimetype = magic.Magic(mime=True).from_buffer(data)
input_extension = os.path.splitext(in_fn)[1] or mimetypes.guess_extension(input_mimetype)
input_extension = extension_remap.get(input_extension, input_extension)
data = proxy.convertFile(base64.encodestring(data),
input_extension.lstrip('.'),
fmt)
with file(out_fn, 'wb') as fout:
fout.write(base64.decodestring(data))
def run(argv):
prog = argv[0]
parser = argparse.ArgumentParser(prog=prog)
parser.add_argument('--version', action='version', version='%(prog)s v' + __version__)
parser.add_argument('-f', '--format')
parser.add_argument('-o', '--output')
parser.add_argument('input', nargs='?', help='input file')
args = parser.parse_args(argv[1:])
if 'input' in args:
process_file(args.input,
args.output,
args.format)
else:
sys.stderr.write('%s: you have to provide a filename as argument\n' % prog)
sys.stderr.write("Try `%s -h' for more information." % prog)
if __name__ == '__main__':
run(sys.argv)
......@@ -13,9 +13,9 @@ ABILIAN_CONFIG=${abilian-config:location}/${abilian-config:filename}
EXTRANET_INSTANCE_PATH=$${directories:extranet_spr-instance}
ABILIAN_CONFIG_EXTRA_PYTHON=$${config-production-py:rendered}
ABILIAN_CONFIG_EXTRA_JSON=$${json-extra-configuration:json-output}:$${buildout:directory}/partition-parameters.json
CLOUDOOO_URI=$${json-configuration:CLOUDOOO_URI}
LD_LIBRARY_PATH=${cairo:location}/lib:${glib:location}/lib:${pango:location}/lib:${cups:location}/lib:${dbus:location}/lib:${dbus-glib:location}/lib:${fontconfig:location}/lib
# abilian/services/conversion.py does not like it, if PATH does not exist
PATH=/usr/sbin:/usr/bin:/sbin:/bin:${git:location}/bin:${poppler:location}/bin:${postgresql91:location}/bin:${redis:location}/bin:${unoconv-repository:location}
PATH=$${directories:bin}:${git:location}/bin:${poppler:location}/bin:${postgresql91:location}/bin:${redis:location}/bin:${unoconv-repository:location}:/usr/sbin:/usr/bin:/sbin:/bin
......@@ -31,6 +31,7 @@ inline =
export ABILIAN_CONFIG_EXTRA_PYTHON=$${instance-environment:ABILIAN_CONFIG_EXTRA_PYTHON}
export ABILIAN_CONFIG_EXTRA_JSON=$${instance-environment:ABILIAN_CONFIG_EXTRA_JSON}
export LD_LIBRARY_PATH=$${instance-environment:LD_LIBRARY_PATH}
export CLOUDOOO_URI=$${instance-environment:CLOUDOOO_URI}
export PATH=$${instance-environment:PATH}
output = $${buildout:directory}/environment.sh
......
......@@ -14,6 +14,7 @@ recipe = slapos.cookbook:symbolic.link
target-directory = $${directories:bin}
link-binary =
${buildout:directory}/bin/abilian
${buildout:directory}/bin/cloudoooconv-python
[extranet-service]
......
......@@ -44,7 +44,8 @@ cert = $${slap-connection:cert-file}
[json-extra-configuration]
recipe = slapos.cookbook:jsondump
json-output = $${buildout:directory}/abilian-config-extra.json
UNOCONV_LOCATION = ${unoconv-repository:location}/unoconv
#UNOCONV_LOCATION = ${unoconv-repository:location}/unoconv
UNOCONV_LOCATION = ${cloudoooconv:location}/${cloudoooconv:filename}
BROKER_URL = redis://:$${redis-requirepass:passwd}@[$${redis:ipv4}]:$${redis:port}/2
CELERY_RESULT_BACKEND = redis://:$${redis-requirepass:passwd}@[$${redis:ipv4}]:$${redis:port}/2
SECRET_KEY = $${csrf-secret-key:passwd}
......
......@@ -23,6 +23,13 @@ extends =
parts =
slapos-cookbook
# for poppler (pdftoppm, etc.)
liberation-fonts
ipaex-fonts
ipa-fonts
ocrb-fonts
android-fonts
weasyprint-repository
flask-alembic-repository
flask-security-repository
......@@ -46,6 +53,7 @@ parts =
psycopg2
gmp
eggs
imagemagick
poppler
cups
......@@ -65,6 +73,8 @@ parts =
config-staging-py-template
config-production-py-template
abilian-config
cloudoooconv-python
cloudoooconv
find-links +=
......@@ -229,7 +239,7 @@ configure-command =
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in
output = ${buildout:directory}/instance.cfg
md5sum = a865bcd6f894f28c69edf58d4df143ca
md5sum = 6aaed03a96475027eff404c430d7888f
mode = 0644
[instance-postgres]
......@@ -250,14 +260,14 @@ mode = 0644
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-extranet.cfg.in
output = ${buildout:directory}/instance-extranet.cfg
md5sum = d39a2a7348866130ef4c63857e0f2945
md5sum = 55c580c54045bf21508088d6548c771a
mode = 0644
[instance-environment]
recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance-environment.cfg.in
output = ${buildout:directory}/instance-environment.cfg
md5sum = 747242345673e3b241b50bab5609294b
md5sum = b67de525594c9b522a99ef1890a98037
mode = 0644
......@@ -272,6 +282,22 @@ download-only = true
mode = 0755
[cloudoooconv-python]
recipe = zc.recipe.egg
eggs = python-magic
interpreter = cloudoooconv-python
[cloudoooconv]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/cloudoooconv
md5sum = 5e6033e0f4d13d52229d952ea0faf0ce
location = ${buildout:parts-directory}/${:_buildout_section_name_}
filename = cloudoooconv
download-only = true
mode = 0755
[config-staging-py-template]
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/${:filename}
......
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