Intergrating another python tool in web2py

27 views
Skip to first unread message

max

unread,
Apr 21, 2015, 4:34:34 AM4/21/15
to web...@googlegroups.com

I would like to runs a  typesetting tool which generates a  TEI xml from a word doc ,  after a file is uploaded to web2py.
I have the ubuntu script configuration from web2py with the user www-data running the web2py framework.
I have given the typesetting script the www-data  rights , but it cannot  set the rights.
Does somebody have any idea, how I can give the rights?

Thanks for anybody for any idea?



import os
import shutil
import subprocess
def metypeset_conversion(filename):
    app_path = '/home/www-data/web2py/applications/HEIDIEditor/'
    metypeset_path = app_path+'static/meTypeset/bin/meTypeset.py'
    file_type = 'docx'
    file_path  =app_path+ 'uploads/'+filename
    output_path  = app_path +'uploads/'+ filename.rsplit('.', 1)[0]
    if not os.path.exists(output_path):
         os.makedirs(output_path)
    cmd = [metypeset_path , file_type +' '+file_path+' '+output_path]

    try:
        #os.setuid(1000)
        #os.setgid(1000)
        retcode =  subprocess.call(cmd)
    except OSError as e:
        retcode = [cmd, e]
    return dict(retcode=retcode)
Reply all
Reply to author
Forward
0 new messages