def calljava(opclass, args, **kwargs): """ Should do whatever "create" is defined as in java code. It is assumed that the java implementation main function accepts an Operation class name and a varargs list """ proxy_server = HTTPCtxProxy(ctx._get_current_object()) try: jarpath = os.path.dirname(os.path.abspath(__file__)) + "/plugin.jar" # below will fail on windows res = subprocess.call( ["java", "-jar", jarpath, str(proxy_server.port), opclass] + args) if res != 0: raise NonRecoverableError( "operation {} execution failed".format(opclass)) finally: proxy_server.close()
def start_ctx_proxy(ctx, process): ctx_proxy_type = process.get('ctx_proxy_type') if not ctx_proxy_type or ctx_proxy_type in ('auto', 'http'): return HTTPCtxProxy(ctx) elif ctx_proxy_type == 'none': return StubCtxProxy() else: raise NonRecoverableError( 'Unsupported proxy type: {0}'.format(ctx_proxy_type))
def callgo(func, args, **kwargs): """ Should do whatever "create" is defined as in go code. It is assumed that the go implementation main function accepts a funcion name and a varargs list """ install() proxy_server = HTTPCtxProxy(ctx._get_current_object()) try: exepath = ctx.instance.runtime_properties['plugin_path'] # below will fail on windows res = subprocess.call( [exepath, str(proxy_server.port), func, json.dumps(args)]) if res != 0: raise NonRecoverableError("func {} execution faild".format(func)) finally: proxy_server.close()
def start_ctx_proxy(ctx, process): ctx_proxy_type = process.get('ctx_proxy_type') if not ctx_proxy_type or ctx_proxy_type == 'auto': if HAS_ZMQ: if IS_WINDOWS: return TCPCtxProxy(ctx) else: return UnixCtxProxy(ctx) else: return HTTPCtxProxy(ctx) elif ctx_proxy_type == 'unix': return UnixCtxProxy(ctx) elif ctx_proxy_type == 'tcp': return TCPCtxProxy(ctx) elif ctx_proxy_type == 'http': return HTTPCtxProxy(ctx) elif ctx_proxy_type == 'none': return StubCtxProxy() else: raise NonRecoverableError( 'Unsupported proxy type: {0}'.format(ctx_proxy_type))