当前位置: 首页>>代码示例>>Python>>正文


Python ClientCreator.addErrback方法代码示例

本文整理汇总了Python中twisted.internet.protocol.ClientCreator.addErrback方法的典型用法代码示例。如果您正苦于以下问题:Python ClientCreator.addErrback方法的具体用法?Python ClientCreator.addErrback怎么用?Python ClientCreator.addErrback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.internet.protocol.ClientCreator的用法示例。


在下文中一共展示了ClientCreator.addErrback方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def execute(host, port, defer):
	d = ClientCreator(reactor, ClientCommandTransport, defer,
					'pedroarthur', '19216806010104', 'server',
					'ps aux | grep ossec | grep -v grep',
	).connectTCP(host, port)

	d.addErrback(defer.errback)
开发者ID:ComputerNetworks-UFRGS,项目名称:ManP2P-ng,代码行数:9,代码来源:monitoring.py

示例2: callCommand

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def callCommand(signaler, host, port, user, password, command):
	print "at callCommand"
	print "Running", command, "at", host, port
	d = ClientCreator(reactor, ClientCommandTransport, signaler,
						user, password, command).connectTCP(host, int(port))

	d.addErrback(signaler.errback)
开发者ID:ComputerNetworks-UFRGS,项目名称:ManP2P-ng,代码行数:9,代码来源:sshRPC.py

示例3: execute

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def execute(host, port, df):
	d = ClientCreator(reactor, ClientCommandTransport, df,
					'root', '192168061', 'server',
					'/etc/init.d/ossec restart',
	).connectTCP(host, port)

	d.addErrback(df.errback, **{'how': False})
开发者ID:ComputerNetworks-UFRGS,项目名称:ManP2P-ng,代码行数:9,代码来源:healing.py

示例4: main

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def main(all_args=None):
    """The main"""
    all_args = all_args or []
    parser = optparse.OptionParser()
    options, args = parse_cmd_line(parser, all_args)
    (port, example, message, count_, topics) = check_cmd_line(
        options, args, parser.error)

    host = 'localhost'
    vhost = '/'
    username = 'guest'
    password = 'guest'
    spec = txamqp.spec.load('your_specs_path.xml')

    delegate = TwistedDelegate()

    d = ClientCreator(reactor, AMQClient, delegate=delegate, vhost=vhost,
                      spec=spec).connectTCP(host, port)

    d.addCallback(gotConnection, username, password)
    if example in PUBLISH_EXAMPLES:
        d.addCallback(ALL_EXAMPLES[example], message, count_)
    else:
        d.addCallback(ALL_EXAMPLES[example], topics)
    d.addCallback(publisher_cleanup)
    d.addErrback(lambda f: sys.stderr.write(str(f)))
    reactor.run()
开发者ID:olegpshenichniy,项目名称:RabbitMQ-Python,代码行数:29,代码来源:rabbit.py

示例5: main

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def main(all_args=None):
    """The main"""
    #    all_args = all_args or []
    #    parser = optparse.OptionParser()
    #    options, args = parse_cmd_line(parser, all_args)
    #    (port, example, message, count_, topics) = check_cmd_line(
    #        options, args, parser.error)

    host = "localhost"
    port = 5672
    vhost = "/"
    username = "guest"
    password = "guest"
    example = "publish2"
    topics = "#"
    message = "hello"
    count = 1000

    spec = txamqp.spec.load("./specs/rabbitmq/amqp0-8.stripped.rabbitmq.xml")

    delegate = TwistedDelegate()

    d = ClientCreator(reactor, AMQClient, delegate=delegate, vhost=vhost, spec=spec).connectTCP(host, port)

    d.addCallback(gotConnection, username, password)
    if example in PUBLISH_EXAMPLES:
        d.addCallback(ALL_EXAMPLES[example], message, count)
    else:
        d.addCallback(ALL_EXAMPLES[example], topics)
    d.addCallback(publisher_cleanup)
    d.addErrback(lambda f: sys.stderr.write(str(f)))
    reactor.run()
开发者ID:pushdotccgzs,项目名称:beaglebone-iot,代码行数:34,代码来源:txamqp-example.py

示例6: callback

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
            def callback(res): # res zawiera dane serwera na ktorym moze byc klucz
                # podłączamy się do niego
                d1 = ClientCreator(reactor, amp.AMP).connectTCP(res['address'], res['port'])
                d1.addCallback(lambda p: p.callRemote(commands.Get, key=key))

                def trapError(result):
                    result.trap(Exception)
                    raise result.type()
                d1.addErrback(trapError)
                
                return d1 # deffer, który zawierać będzie wynik metody get na właściwym serwerze
开发者ID:grapo,项目名称:dht-database,代码行数:13,代码来源:server.py

示例7: setup

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def setup(vm):
    print 'Connecting with new domain...'
    
    creator = ClientCreator(reactor,
                          TTwisted.ThriftClientProtocol,
                          RelayService.Client,
                          TBinaryProtocol.TBinaryProtocolFactory(),
                          ).connectTCP(DEFAULT_SETUP_IP, config.RELAY_PORT)
    creator.addCallback(lambda conn: conn.client)
    
    creator.addCallback(connection_established, vm)
    creator.addErrback(error, vm)
开发者ID:strategist922,项目名称:sonar,代码行数:14,代码来源:clone.py

示例8: addcall

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
 def addcall(self, obj, callback=None, **kwargs):
     d = ClientCreator(reactor, amp.AMP).connectTCP(self.address, self.port)
     d.addCallback(lambda p: p.callRemote(obj, **kwargs))
     if callback is None:
         def callback(res):
             print "Otrzymano: ", res
     d.addCallback(callback)
     def trapError(result):
         result.trap(Exception)
         print "Błąd!: {0}".format(result.type)
     d.addErrback(trapError)
     return d
开发者ID:grapo,项目名称:dht-database,代码行数:14,代码来源:client.py

示例9: connect

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
 def connect(self):
     d = ClientCreator(reactor,
             TTwisted.ThriftClientProtocol,
             Scheduler.Client,
             TBinaryProtocol.TBinaryProtocolFactory(),
         ).connectTCP(self.host, 
             self.port, self.timeout)
     d.addCallback(self.set_connect)
     d.addErrback(self.close_conn)
     log.msg("try connect to Master[%s:%s]" % \
         (self.host, self.port))
     return d
开发者ID:falood,项目名称:smart-buyer,代码行数:14,代码来源:masterclient.py

示例10: start

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
    def start(self):
        vhost = self.amqp_conn['vhost']
        host = self.amqp_conn['host']
        port = self.amqp_conn['port']

        d = ClientCreator(reactor,
                          AMQClient,
                          delegate=TwistedDelegate(),
                          vhost=vhost,
                          spec=self.spec).connectTCP(host, port)

        d.addCallback(self.gotConnection)
        d.addErrback(self.whoops)
开发者ID:dmtmalin,项目名称:jasmin-smsdev,代码行数:15,代码来源:sms_logger.py

示例11: _try_connecting

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def _try_connecting(domain, defer):
    '''
    Connects with the domain's Relay service. If it does not respond in 5 seconds
    it is assumed that the domain is not available right now 
    '''
    creator = ClientCreator(reactor,
                          TTwisted.ThriftClientProtocol,
                          RelayService.Client,
                          TBinaryProtocol.TBinaryProtocolFactory(),
                          ).connectTCP(domain, config.RELAY_PORT, timeout=10)
    creator.addCallback(lambda conn: conn.client)
    
    creator.addCallback(lambda value: defer.callback(True))
    creator.addErrback(lambda value: defer.callback(False))
开发者ID:jacksonicson,项目名称:paper.IS2015,代码行数:16,代码来源:clone.py

示例12: configure_domain

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
 def configure_domain(self, clone_entry):
     '''
     Reconfigures a domain by running the reconfiguration drone 
     '''
     
     print 'Connecting with new domain.'
     creator = ClientCreator(reactor,
                           TTwisted.ThriftClientProtocol,
                           RelayService.Client,
                           TBinaryProtocol.TBinaryProtocolFactory(),
                           ).connectTCP(DEFAULT_SETUP_IP, config.RELAY_PORT, timeout=10)
     creator.addCallback(lambda conn: conn.client)
     creator.addCallback(self._launch_drone, clone_entry)
     creator.addErrback(self._configuration_error, clone_entry)
开发者ID:jacksonicson,项目名称:paper.IS2015,代码行数:16,代码来源:configure.py

示例13: get_coins

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
    def get_coins(self, amount=5):
        packet = [constants.Header.SIGN]
        blinding_factors = list()

        for _ in range(int(amount)):
            msg = pick_random()
            blinding_factor = pick_random()
            key = RSA.importKey(constants.B.public_key)
            blind = b64encode(key.blind(msg, blinding_factor))
            packet.append(blind)
            blinding_factors.append((blinding_factor, msg))

        d = ClientCreator(reactor, BankClient).connectTCP(constants.B.external_ip, constants.B.port)
        d.addCallback(self._send_blinds, blinding_factors, packet)
        d.addErrback(self._error, "Bank")
开发者ID:t2d,项目名称:pyanotel,代码行数:17,代码来源:user.py

示例14: _connect

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
  def _connect(self):
    spec_path = os.path.dirname(__file__) + "/amqp0-8.stripped.rabbitmq.xml"
    spec = txamqp.spec.load(spec_path)
    self.delegate = TwistedDelegate()

    d = ClientCreator(reactor, AMQClient, delegate=self.delegate, vhost=self._configuration["vhost"], spec=spec).connectTCP(self._configuration["host"], self._configuration["port"])

    d.addCallback(self._connected)

    def whoops(err):
      if reactor.running:
        log.err(err)
        self.shutdown()
        reactor.stop()

    d.addErrback(whoops)
开发者ID:israelshirk,项目名称:task-receiver,代码行数:18,代码来源:message_helper.py

示例15: connect_to_server

# 需要导入模块: from twisted.internet.protocol import ClientCreator [as 别名]
# 或者: from twisted.internet.protocol.ClientCreator import addErrback [as 别名]
def connect_to_server():
    host = conf.BROKER_HOST
    port = conf.BROKER_PORT
    vhost = conf.BROKER_VHOST
    username = conf.BROKER_USER
    password = conf.BROKER_PASSWORD

    delegate = TwistedDelegate()
    d = ClientCreator(reactor, AMQClient, delegate=delegate, vhost=vhost, spec=spec).connectTCP(host, int(port))
    d.addCallback(got_connection, username, password)

    def errback(err):
        if reactor.running:
            log.err(err)
            reactor.stop()

    d.addErrback(errback)
开发者ID:jasonbaker,项目名称:apvy,代码行数:19,代码来源:amqp.py


注:本文中的twisted.internet.protocol.ClientCreator.addErrback方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。