Rev | Line | |
---|
[103] | 1 | # -*- coding: utf-8 -*- |
---|
| 2 | from subprocess import Popen, PIPE |
---|
| 3 | import json , os , sys , tempfile |
---|
| 4 | class %CLASSNAME%: |
---|
| 5 | |
---|
| 6 | def __run_function(self,class_module,function_module,*raw_args): |
---|
| 7 | pipe_in = tempfile.NamedTemporaryFile().name |
---|
| 8 | fd = open(pipe_in,'w') |
---|
| 9 | args_parsed = [] |
---|
| 10 | for i in raw_args: |
---|
| 11 | args_parsed.append(i) |
---|
| 12 | args = {'args':args_parsed} |
---|
| 13 | json.dump(args,fd) |
---|
| 14 | fd.close() |
---|
| 15 | exec_result = Popen(["/usr/share/n4d/xmlrpc-server/perl_support/core_perl_plugins.pl",class_module,function_module,pipe_in],stdout=PIPE,stderr=PIPE) |
---|
| 16 | result_json_path = exec_result.communicate()[0] |
---|
| 17 | if os.path.exists(result_json_path): |
---|
| 18 | fd = open(result_json_path,'r') |
---|
| 19 | raw_result = fd.readlines() |
---|
| 20 | result = json.loads(raw_result[0]) |
---|
| 21 | os.remove(result_json_path) |
---|
| 22 | return result['result'] |
---|
| 23 | else: |
---|
| 24 | return None |
---|
| 25 | |
---|
Note: See
TracBrowser
for help on using the repository browser.