def connectToServer(hostname): builder = cobra.initSocketBuilder(hostname, viv_port) builder.setTimeout(timeo_sock) server = cobra.CobraProxy("cobra://%s:%d/VivServer" % (hostname, viv_port), msgpack=True) version = server.getServerVersion() if version != server_version: raise Exception('Incompatible Server: his ver: %d our ver: %d' % (version, server_version)) return server
def connectToServer(hostname): builder = cobra.initSocketBuilder(hostname,viv_port) builder.setTimeout(timeo_sock) server = cobra.CobraProxy("cobra://%s:%d/VivServer" % (hostname,viv_port), msgpack=True) version = server.getServerVersion() if version != server_version: raise Exception('Incompatible Server: his ver: %d our ver: %d' % (version, server_version)) return server
def main(uri, cacrt=None, sslcert=None, sslkey=None): if any([cacrt, sslcert, sslkey]): scheme, host, port, name, urlparams = cobra.chopCobraUri(uri) builder = cobra.initSocketBuilder(host, port) tempdir = tempfile.mkdtemp() if cacrt: cafile = dumpfile(cacrt, os.path.join(tempdir, 'ca.crt')) builder.setSslCa(cafile) if sslkey: keyfile = dumpfile(sslkey, os.path.join(tempdir, 'client.key')) certfile = dumpfile(sslcert, os.path.join(tempdir, 'client.crt')) builder.setSslClientCert(certfile, keyfile) try: c_remoteapp.getAndRunApp(uri) except Exception as e: logger.warning('error: %s', e)
def main(uri,cacrt=None,sslcert=None,sslkey=None): if any([cacrt,sslcert,sslkey]): scheme, host, port, name, urlparams = cobra.chopCobraUri( uri ) builder = cobra.initSocketBuilder(host,port) tempdir = tempfile.mkdtemp() if cacrt: cafile = dumpfile(cacrt, os.path.join(tempdir,'ca.crt')) builder.setSslCa(cafile) if sslkey: keyfile = dumpfile(sslkey, os.path.join(tempdir,'client.key')) certfile = dumpfile(sslcert, os.path.join(tempdir,'client.crt')) builder.setSslClientCert(certfile,keyfile) try: c_remoteapp.getAndRunApp(uri) except Exception, e: print('error: %s' % e)
def buildCobra(host, port, name): builder = cobra.initSocketBuilder(host, port) builder.setTimeout(5) return cobra.CobraProxy('cobra://%s:%s/%s?msgpack=1' % (host, port, name))