class rMakeClient(object): """ Client for communicating with rMake servers. @param uri: URI or address to server @type uri: URI or instance of L{rmake.lib.rpcproxy.Address} @param clientCert: Path to a X509 certificate and RSA private key to make available when contacting a SSL-enabled rMake server. @type clientCert: C{str} """ def __init__(self, uri, clientCert=None): if not isinstance(uri, Address): uri = parseAddress(uri) if hasattr(uri, 'handler') and uri.handler in ('', '/'): firehose_uri = uri.copy() firehose_uri.handler = '/firehose' uri = uri.copy() uri.handler = '/picklerpc' else: firehose_uri = None self.uri = uri self.proxy = PickleServerProxy(uri, key_file=clientCert, ignoreCommonName=True) if firehose_uri: self.firehose = FirehoseClient(firehose_uri.asString( withPassword=False)) else: self.firehose = None def addRepositoryInfo(self, cfg): info = self.proxy.build.getRepositoryInfo() cfg.repositoryMap.update(info['repositoryMap']) for user in info['reposUser']: cfg.user.append(user) cfg.reposName = info['reposName'] if info['conaryProxy'] and not cfg.conaryProxy: cfg.conaryProxy['http'] = info['conaryProxy'] cfg.conaryProxy['https'] = info['conaryProxy'] def buildJob(self, job, subscribe=True): sid = subscribe and self.firehose.sid or None import pickle; pickle.dump(job, open('job.pickle', 'wb'), 2) return self.proxy.build.createJob(job, firehose=sid) def watchJob(self, job): selfEvent = ('job', str(job.jobUUID), 'self') for event in self.firehose.iterAll(): print event.event print ' Matched:', event.matched if hasattr(event.data, 'code'): print ' Status: %s %s' % (event.data.code, event.data.text) if event.data.detail: print event.data.detail print else: print ' Data:', event.data if event.event == selfEvent and event.data in ( 'finalized', 'destroyed'): break
def __init__(self, uri, clientCert=None): if not isinstance(uri, Address): uri = parseAddress(uri) if hasattr(uri, 'handler') and uri.handler in ('', '/'): firehose_uri = uri.copy() firehose_uri.handler = '/firehose' uri = uri.copy() uri.handler = '/picklerpc' else: firehose_uri = None self.uri = uri self.proxy = PickleServerProxy(uri, key_file=clientCert, ignoreCommonName=True) if firehose_uri: self.firehose = FirehoseClient(firehose_uri.asString( withPassword=False)) else: self.firehose = None