fuse_server.py 847 Bytes
Newer Older
1
from SimpleXMLRPCServer import SimpleXMLRPCServer
2 3
from subprocess import *

4 5 6
import sys
sys.path.insert(0, './web2py/applications/vidjil/modules')
import defs
7
import os.path
8

9 10
def fuse(cmd, output_dir, filename):
    from subprocess import Popen, PIPE, STDOUT, os
11

12 13
    fuse_log_file = open(output_dir+'/'+filename+'.fuse.log', 'w')
    output_file = output_dir+'/'+filename+'.fused'
14

15 16 17 18 19 20 21 22
    ## fuse.py 
    p = Popen(cmd, shell=True, stdin=PIPE, stdout=fuse_log_file, stderr=STDOUT, close_fds=True)
    (stdoutdata, stderrdata) = p.communicate()
    fuse_filepath = os.path.abspath(output_file)
    p.wait()
    return fuse_filepath

def main():
23
    server = SimpleXMLRPCServer((defs.FUSE_SERVER, defs.PORT_FUSE_SERVER))
24 25 26 27 28
    server.register_function(fuse, "fuse")
    while True:
        server.handle_request()

if __name__ == "__main__":
29 30
    main()