本文整理汇总了Python中twisted.spread.pb.PBClientFactory类的典型用法代码示例。如果您正苦于以下问题:Python PBClientFactory类的具体用法?Python PBClientFactory怎么用?Python PBClientFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PBClientFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(reactor, cred, masterIP, masterPort, commPort, uid):
f = open('/opt/rce/data/env.log', 'w') # TODO: Hardcoded? Use os.getenv('HOME')?
log.startLogging(f)
rospy.init_node('RCE_Master')
print 'connect to ', masterIP, masterPort
factory = PBClientFactory()
reactor.connectTCP(masterIP, masterPort, factory)
client = EnvironmentClient(reactor, commPort)
def terminate():
reactor.callFromThread(client.terminate)
reactor.callFromThread(reactor.stop)
rospy.on_shutdown(terminate)
def _err(reason):
print(reason)
terminate()
d = factory.login(cred, (client, uid))
d.addCallback(lambda ref: setattr(client, '_avatar', ref))
d.addErrback(_err)
reactor.run(installSignalHandlers=False)
f.close()
开发者ID:arunenigma,项目名称:rce,代码行数:29,代码来源:environment.py
示例2: clientConnectionLost
def clientConnectionLost(self, connector, reason, reconnecting=1):
zenlog.debug("Lost connection to %s:%s - %s", connector.host, connector.port, reason.getErrorMessage())
self._perspective = None
self._cancelConnectTimeout()
PBClientFactory.clientConnectionLost(self, connector, reason, reconnecting=reconnecting)
RCF = protocol.ReconnectingClientFactory
RCF.clientConnectionLost(self, connector, reason)
开发者ID:jpeacock-zenoss,项目名称:zenoss-prodbin,代码行数:7,代码来源:PBUtil.py
示例3: login
def login(self, userID, robotID, password):
""" Callback for Robot connection to login and authenticate.
@param userID: User ID under which the robot is logging in.
@type userID: str
@param robotID: Unique ID of the robot in the namespace of the
user under which the robot is logging in.
@type robotID: str
@param password: Hashed password as hex-encoded string which is
used to authenticate the user.
@type password: str
@return: Representation of the connection to the robot
which is used in the Robot process.
(type: rce.robot.Connection)
@rtype: twisted.internet.defer.Deferred
"""
conn = Connection(self, userID, robotID)
factory = PBClientFactory()
self._reactor.connectTCP(self._masterIP, self._masterPort, factory)
d = factory.login(UsernamePassword(userID, password))
d.addCallback(self._cbAuthenticated, conn)
d.addCallback(self._cbConnected, conn)
d.addCallback(lambda _: conn)
return d
开发者ID:micpalmia,项目名称:rce,代码行数:29,代码来源:robot.py
示例4: clientConnectionMade
def clientConnectionMade(self, broker):
log.debug("clientConnectionMade")
self.resetDelay()
self._cancelConnectTimeout()
PBClientFactory.clientConnectionMade(self, broker)
if self._creds:
self._startConnectTimeout("Login")
self._login(self._creds)
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:8,代码来源:PBUtil.py
示例5: clientConnectionFailed
def clientConnectionFailed(self, connector, reason):
PBClientFactory.clientConnectionFailed(self, connector, reason)
# Twisted-1.3 erroneously abandons the connection on non-UserErrors.
# To avoid this bug, don't upcall, and implement the correct version
# of the method here.
if self.continueTrying:
self.connector = connector
self.retry()
开发者ID:rhaejr,项目名称:canasta,代码行数:8,代码来源:PBUtil.py
示例6: clientConnectionMade
def clientConnectionMade(self, broker):
self.resetDelay()
PBClientFactory.clientConnectionMade(self, broker)
if self._doingLogin:
self.doLogin(self._root)
if self._doingGetPerspective:
self.doGetPerspective(self._root)
self.gotRootObject(self._root)
开发者ID:rhaejr,项目名称:canasta,代码行数:8,代码来源:PBUtil.py
示例7: run
def run(self, *args, **kwargs):
def connected(reference):
self._reference = reference
return super(Client, self).run(*args, **kwargs)
client = PBClientFactory()
d = client.getRootObject()
d.addCallback(connected)
self._reactor.connectTCP('127.0.0.1', self._port, client)
return d
开发者ID:AlekSi,项目名称:twisted-benchmarks,代码行数:9,代码来源:pb.py
示例8: main
def main(
reactor,
cred,
masterIP,
masterPort,
masterPassword,
infraPasswd,
bridgeIF,
internalIP,
bridgeIP,
envPort,
rosproxyPort,
rootfsDir,
confDir,
dataDir,
pkgDir,
ubuntuRel,
rosRel,
data,
):
log.startLogging(sys.stdout)
def _err(reason):
print(reason)
reactor.stop()
factory = PBClientFactory()
reactor.connectTCP(masterIP, masterPort, factory)
client = ContainerClient(
reactor,
masterIP,
masterPort,
masterPassword,
infraPasswd,
bridgeIF,
internalIP,
bridgeIP,
envPort,
rosproxyPort,
rootfsDir,
confDir,
dataDir,
pkgDir,
ubuntuRel,
rosRel,
data,
)
d = factory.login(cred, (client, data))
d.addCallback(lambda ref: setattr(client, "_avatar", ref))
d.addErrback(_err)
reactor.addSystemEventTrigger("before", "shutdown", client.terminate)
reactor.run()
开发者ID:roboearth-neu,项目名称:rce,代码行数:55,代码来源:container.py
示例9: clientConnectionMade
def clientConnectionMade(self, broker):
zenlog.debug("Connected")
self._cancelConnectTimeout()
self.resetDelay()
PBClientFactory.clientConnectionMade(self, broker)
if self._doingLogin:
self._startConnectTimeout("Login")
self.doLogin(self._root)
if self._doingGetPerspective:
self.doGetPerspective(self._root)
self.gotRootObject(self._root)
开发者ID:c0ns0le,项目名称:zenoss-4,代码行数:11,代码来源:PBUtil.py
示例10: clientConnectionFailed
def clientConnectionFailed(self, connector, reason):
zenlog.debug("Failed to create connection to %s:%s - %s", connector.host, connector.port, reason)
self._perspective = None
self._cancelConnectTimeout()
PBClientFactory.clientConnectionFailed(self, connector, reason)
# Twisted-1.3 erroneously abandons the connection on non-UserErrors.
# To avoid this bug, don't upcall, and implement the correct version
# of the method here.
if self.continueTrying:
self.connector = connector
self.retry()
开发者ID:jpeacock-zenoss,项目名称:zenoss-prodbin,代码行数:11,代码来源:PBUtil.py
示例11: __init__
def __init__(self, connectTimeout=30, pingPerspective=True, pingInterval=30, pingtimeout=120):
PBClientFactory.__init__(self)
self._creds = None
self._scheduledConnectTimeout = None
self._connectTimeout = connectTimeout
# should the perspective be pinged. Perspective must have a ping method. Deprecated => Always False.
self._shouldPingPerspective = pingPerspective
# how often to ping
self._pingInterval = pingInterval
# how long to wait for a ping before closing connection
self._pingTimeoutTime = pingtimeout
# ref to the scheduled ping timeout call
self._pingTimeout = None
# looping call doing the ping
self._pingCheck = None
self._perspective = None
开发者ID:zenoss,项目名称:zenoss-prodbin,代码行数:16,代码来源:PBUtil.py
示例12: ForwardOutput
class ForwardOutput(Output):
implements(IOutput)
def configure(self, section):
self.forwardserver = section.getString('forwarding address', None)
self.forwardport = section.getInt('forwarding port', None)
self.retryinterval = section.getInt('retry interval', 10)
self.forwardedevents = getStat("terane.output.%s.forwardedevents" % self.name, 0)
self.stalerefs = getStat("terane.output.%s.stalerefs" % self.name, 0)
def startService(self):
Output.startService(self)
self._client = None
self._listener = None
self._remote = None
self._backoff = None
self._reconnect()
def _reconnect(self):
try:
if self._client:
self._client.disconnect()
self._client = PBClientFactory()
if self._listener:
self._listener.disconnect()
self._listener = reactor.connectTCP(self.forwardserver, self.forwardport, self._client)
self._remote = self._client.login(Anonymous())
self._remote.addCallback(self._login)
self._remote.addErrback(self._loginFailed)
except Exception, e:
logger.error("[output:%s] failed to connect to remote collector: %s" % (self.name,str(e)))
logger.error("[output:%s] will retry to connect in %i seconds" % (self.name,self.retryinterval))
self._backoff = reactor.callLater(self.retryinterval, self._reconnect)
开发者ID:DSDev-NickHogle,项目名称:terane,代码行数:34,代码来源:forward.py
示例13: UbuntuOneClient
class UbuntuOneClient(object):
"""Root object that provides access to all the remote objects."""
def __init__(self):
"""Create a new instance."""
self.status = None
self.events = None
self.sync_daemon = None
self.file_system = None
self.shares = None
self.config = None
self.folders = None
self.public_files = None
self.factory = None
self.client = None
@defer.inlineCallbacks
def _request_remote_objects(self, root):
"""Request all the diff remote objects used for the communication."""
status = yield root.callRemote('get_status')
self.status = StatusClient(status)
events = yield root.callRemote('get_events')
self.events = EventsClient(events)
sync_daemon = yield root.callRemote('get_sync_daemon')
self.sync_daemon = SyncDaemonClient(sync_daemon)
file_system = yield root.callRemote('get_file_system')
self.file_system = FileSystemClient(file_system)
shares = yield root.callRemote('get_shares')
self.shares = SharesClient(shares)
config = yield root.callRemote('get_config')
self.config = ConfigClient(config)
folders = yield root.callRemote('get_folders')
self.folders = FoldersClient(folders)
public_files = yield root.callRemote('get_public_files')
self.public_files = PublicFilesClient(public_files)
defer.returnValue(self)
@defer.inlineCallbacks
def connect(self):
"""Connect to the syncdaemon service."""
# pylint: disable=W0702
try:
# connect to the remote objects
self.factory = PBClientFactory()
self.client = yield ipc_client_connect(self.factory)
root = yield self.factory.getRootObject()
yield self._request_remote_objects(root)
yield self.register_to_signals()
defer.returnValue(self)
except Exception, e:
raise SyncDaemonClientConnectionError(
'Could not connect to the syncdaemon ipc.', e)
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:60,代码来源:ipc_client.py
示例14: _sendMessage
def _sendMessage(channel, message):
"""
Establish a connection to the bot and direct it to send the given message
to the given channel.
@type channel: C{str}
@type message: C{str}
"""
messageFactory = PBClientFactory()
reactor.connectTCP(BOT_HOST, BOT_PORT, messageFactory)
def cbGotRoot(rootObj):
return rootObj.callRemote('message', channel, message)
rootDeferred = messageFactory.getRootObject()
rootDeferred.addCallback(cbGotRoot)
rootDeferred.addErrback(err)
rootDeferred.addCallback(lambda ign: reactor.stop())
开发者ID:rodrigc,项目名称:braid,代码行数:18,代码来源:message.py
示例15: connectionMade
def connectionMade(self):
""" Create a PBClientFactory and connect to master when ConsoleClient
connected to StandardIO. Prompt user for Username
"""
HistoricRecvLine.connectionMade(self)
self._factory = PBClientFactory()
reactor.connectTCP(self._masterIP, self._console_port, self._factory) #@UndefinedVariable
self.terminal.write("Username: ")
开发者ID:dhananjaysathe,项目名称:rce,代码行数:9,代码来源:console.py
示例16: connect
def connect(self):
"""Connect to the remote service."""
self.factory = PBClientFactory()
self.client = yield client_connect(self.factory,
self.service_name,
self.service_cmdline,
self.service_port)
root = yield self.factory.getRootObject()
yield self._request_remote_objects(root)
yield self.register_to_signals()
开发者ID:thnguyn2,项目名称:ECE_527_MP,代码行数:10,代码来源:ipc.py
示例17: main
def main(reactor, cred, masterIP, masterPort, internalIF, bridgeIF, envPort,
rootfsDir, confDir, dataDir, srcDir, pkgDir, maxNr):
log.startLogging(sys.stdout)
def _err(reason):
print(reason)
reactor.stop()
factory = PBClientFactory()
reactor.connectTCP(masterIP, masterPort, factory)
client = ContainerClient(reactor, masterIP, internalIF, bridgeIF, envPort,
rootfsDir, confDir, dataDir, srcDir, pkgDir)
d = factory.login(cred, (client, maxNr))
d.addCallback(lambda ref: setattr(client, '_avatar', ref))
d.addErrback(_err)
reactor.addSystemEventTrigger('before', 'shutdown', client.terminate)
reactor.run()
开发者ID:dreamfrog,项目名称:rce,代码行数:20,代码来源:container.py
示例18: main
def main():
"""
Connect to a PB server running on port 8800 on localhost and log in to
it, both anonymously and using a username/password it will recognize.
"""
startLogging(stdout)
factory = PBClientFactory()
reactor.connectTCP("localhost", 8800, factory)
anonymousLogin = factory.login(Anonymous())
anonymousLogin.addCallback(connected)
anonymousLogin.addErrback(error, "Anonymous login failed")
usernameLogin = factory.login(UsernamePassword("user1", "pass1"))
usernameLogin.addCallback(connected)
usernameLogin.addErrback(error, "Username/password login failed")
bothDeferreds = gatherResults([anonymousLogin, usernameLogin])
bothDeferreds.addCallback(finished)
reactor.run()
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:21,代码来源:pbAnonClient.py
示例19: main
def main(reactor, cred, masterIP, masterPort, consolePort,
extIP, extPort, commPort, pkgPath, customConverters):
log.startLogging(sys.stdout)
def _err(reason):
print(reason)
reactor.stop()
factory = PBClientFactory()
reactor.connectTCP(masterIP, masterPort, factory)
rosPath = []
for path in get_ros_paths() + [p for p, _ in pkgPath]:
if path not in rosPath:
rosPath.append(path)
loader = Loader(rosPath)
converter = Converter(loader)
for customConverter in customConverters:
# Get correct path/name of the converter
module, className = customConverter.rsplit('.', 1)
# Load the converter
mod = __import__(module, fromlist=[className])
converter.addCustomConverter(getattr(mod, className))
client = RobotClient(reactor, masterIP, consolePort, commPort, extIP,
extPort, loader, converter)
d = factory.login(cred, client)
d.addCallback(lambda ref: setattr(client, '_avatar', ref))
d.addErrback(_err)
# portal = Portal(client, (client,))
robot = CloudEngineWebSocketFactory(client,
'ws://localhost:{0}'.format(extPort))
listenWS(robot)
reactor.addSystemEventTrigger('before', 'shutdown', client.terminate)
reactor.run()
开发者ID:micpalmia,项目名称:rce,代码行数:40,代码来源:robot.py
示例20: reconnect
def reconnect(self):
"""Reconnect with the server."""
self.factory = PBClientFactory()
self.client = yield client_connect(self.factory,
self.service_name,
self.service_cmdline,
self.service_description)
root = yield self.factory.getRootObject()
# loop over the already present remote clients and reset their remotes
for name in self.clients:
remote = yield root.callRemote('get_%s' % name)
remote_client = getattr(self, name)
remote_client.remote = remote
yield self.register_to_signals()
开发者ID:ArslanRafique,项目名称:dist-packages,代码行数:14,代码来源:ipc.py
注:本文中的twisted.spread.pb.PBClientFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论