• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python poller.POLLER类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中neubot.poller.POLLER的典型用法代码示例。如果您正苦于以下问题:Python POLLER类的具体用法?Python POLLER怎么用?Python POLLER使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: main

def main(args):
    ''' Main function '''

    try:
        options, arguments = getopt.getopt(args[1:], '6A:p:Sv')
    except getopt.error:
        sys.exit('usage: neubot skype_clnt [-6Sv] [-A address] [-p port]')
    if arguments:
        sys.exit('usage: neubot skype_clnt [-6Sv] [-A address] [-p port]')

    prefer_ipv6 = 0
    address = '127.0.0.1'
    port = 45678
    sslconfig = False
    verbose = 0
    for name, value in options:
        if name == '-6':
            prefer_ipv6 = 1
        elif name == '-A':
            address = value
        elif name == '-p':
            port = int(value)
        elif name == '-S':
            sslconfig = True
        elif name == '-v':
            verbose += 1

    level = logging.INFO
    if verbose > 0:
        level = logging.DEBUG
    logging.getLogger().setLevel(level)

    handler = SkypeClient()
    handler.connect((address, port), prefer_ipv6, sslconfig, {})
    POLLER.loop()
开发者ID:claudiuperta,项目名称:neubot,代码行数:35,代码来源:skype_clnt.py


示例2: main

def main(args):
    ''' Main function '''
    try:
        options, arguments = getopt.getopt(args[1:], '6A:P:p:Sv')
    except getopt.error:
        sys.exit(USAGE)
    if arguments:
        sys.exit(USAGE)

    prefer_ipv6 = 0
    address = 'mlab-ns.appspot.com'
    policy = ''
    port = 80
    sslconfig = 0
    level = logging.INFO
    for name, value in options:
        if name == '-6':
            prefer_ipv6 = 1
        elif name == '-A':
            address = value
        elif name == '-P':
            policy = value
        elif name == '-p':
            port = int(value)
        elif name == '-S':
            sslconfig = 1
        elif name == '-v':
            level = logging.DEBUG

    logging.getLogger().setLevel(level)

    handler = RunnerMlabns()
    extra = {'policy': policy}
    handler.connect((address, port), prefer_ipv6, sslconfig, extra)
    POLLER.loop()
开发者ID:EverlastingFire,项目名称:neubot,代码行数:35,代码来源:runner_mlabns.py


示例3: _waiting_rawtest

 def _waiting_rawtest(self, stream, data):
     ''' Waiting for RAWTEST message from client '''
     context = stream.opaque
     context.bufferise(data)
     tmp = context.pullup(len(RAWTEST))
     if not tmp:
         stream.recv(len(RAWTEST), self._waiting_rawtest)
         return
     if tmp[4:5] == PING_CODE:
         logging.debug('< PING')
         stream.send(PINGBACK, self._sent_pingback)
         logging.debug('> PINGBACK')
         return
     if tmp[4:5] != RAWTEST_CODE:
         raise RuntimeError('raw_srvr: received invalid message')
     logging.debug('< RAWTEST')
     logging.info('raw_srvr: waiting for RAWTEST message... complete')
     logging.info('raw_srvr: raw test... in progress')
     context.count = context.snap_count = stream.bytes_out
     context.ticks = context.snap_ticks = utils.ticks()
     context.snap_utime, context.snap_stime = os.times()[:2]
     message = PIECE_CODE + context.auth * int(LEN_MESSAGE / AUTH_LEN)
     context.message = struct.pack('!I', len(message)) + message
     stream.send(context.message, self._piece_sent)
     #logging.debug('> PIECE')
     POLLER.sched(1, self._periodic, stream)
     stream.recv(1, self._waiting_eof)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:27,代码来源:raw_srvr.py


示例4: main

def main(args):
    ''' Main function '''

    try:
        options, arguments = getopt.getopt(args[1:], '6A:p:Sv')
    except getopt.error:
        sys.exit(USAGE)
    if not arguments:
        sys.exit(USAGE)

    prefer_ipv6 = 0
    address = '127.0.0.1'
    sslconfig = 0
    port = 80
    level = logging.INFO
    for name, value in options:
        if name == '-6':
            prefer_ipv6 = 1
        elif name == '-A':
            address = value
        elif name == '-p':
            port = int(value)
        elif name == '-S':
            sslconfig = 1
        elif name == '-v':
            level = logging.DEBUG

    logging.getLogger().setLevel(level)

    handler = HttpClientSmpl(POLLER)
    handler.connect((address, port), prefer_ipv6, sslconfig,
      (address, port, collections.deque(arguments), [0]))
    POLLER.loop()
开发者ID:bassosimone,项目名称:neubot_altnet,代码行数:33,代码来源:__main__.py


示例5: main

def main(args):
    ''' Run the API server '''

    try:
        options, arguments = getopt.getopt(args[1:], 'O:v')
    except getopt.error:
        sys.exit('usage: neubot background_api [-v] [-O setting]')
    if arguments:
        sys.exit('usage: neubot background_api [-v] [-O setting]')

    settings = []
    for name, value in options:
        if name == '-O':
            settings.append(value)
        elif name == '-v':
            LOG.verbose()

    settings = utils_rc.parse_safe(iterable=settings)
    if not 'address' in settings:
        settings['address'] = '127.0.0.1 ::1'
    if not 'port' in settings:
        settings['port'] = '9774'

    start(settings['address'], settings['port'])
    POLLER.loop()
开发者ID:felipebusnello,项目名称:neubot,代码行数:25,代码来源:background_api.py


示例6: main

def main(args):
    ''' Main function '''
    try:
        options, arguments = getopt.getopt(args[1:], '6A:p:v')
    except getopt.error:
        sys.exit('usage: neubot skype_negotiate [-6v] [-A address] [-p port]')
    if arguments:
        sys.exit('usage: neubot skype_negotiate [-6v] [-A address] [-p port]')

    prefer_ipv6 = 0
    address = '127.0.0.1'
    port = 8080
    level = logging.INFO
    for name, value in options:
        if name == '-6':
            prefer_ipv6 = 1
        elif name == '-A':
            address = value
        elif name == '-p':
            port = int(value)
        elif name == '-v':
            level = logging.DEBUG

    logging.getLogger().setLevel(level)

    handler = SkypeNegotiate()
    handler.connect((address, port), prefer_ipv6, 0, {})
    POLLER.loop()
开发者ID:claudiuperta,项目名称:neubot,代码行数:28,代码来源:skype_negotiate.py


示例7: main

def main(args):
    ''' Main() function '''

    try:
        options, arguments = getopt.getopt(args[1:], '')
    except getopt.error:
        sys.exit('usage: neubot background_win32')
    if options or arguments:
        sys.exit('usage: neubot background_win32')

    # Read settings from database
    CONFIG.merge_database(DATABASE.connection())

    #
    # Save logs into the database, to easily access
    # and show them via the web user interface.
    #
    LOG.use_database()

    # Complain if privacy settings are not OK
    privacy.complain_if_needed()

    background_api.start('127.0.0.1 ::1', '9774')
    BACKGROUND_RENDEZVOUS.start()

    __start_updater()

    POLLER.loop()
开发者ID:felipebusnello,项目名称:neubot,代码行数:28,代码来源:background_win32.py


示例8: main

def main(args):
    ''' main() function '''

    try:
        options, arguments = getopt.getopt(args[1:], 'vy')
    except getopt.error:
        sys.exit('neubot updater_runner [-vy] [version]')
    if len(arguments) > 1:
        sys.exit('neubot updater_runner [-vy] [version]')

    privacy = False
    for tpl in options:
        if tpl[0] == '-v':
            LOG.verbose()
        elif tpl[0] == '-y':
            privacy = True

    # Honor -y and force privacy permissions
    if privacy:
        CONFIG.conf.update({'privacy.informed': 1, 'privacy.can_collect': 1,
                            'privacy.can_publish': 1})

    updater = UpdaterRunner('win32', os.path.dirname(ROOTDIR))

    if arguments:
        updater.retrieve_files(arguments[0])
    else:
        # Enable automatic updates if we arrive here
        CONFIG.conf['win32_updater'] = 1
        updater.retrieve_versioninfo()

    POLLER.loop()
开发者ID:felipebusnello,项目名称:neubot,代码行数:32,代码来源:updater_runner.py


示例9: main

def main(args):
    """ Main function """

    try:
        options, arguments = getopt.getopt(args[1:], "6A:p:Sv")
    except getopt.error:
        sys.exit("usage: neubot raw_clnt [-6Sv] [-A address] [-p port]")
    if arguments:
        sys.exit("usage: neubot raw_clnt [-6Sv] [-A address] [-p port]")

    prefer_ipv6 = 0
    address = "127.0.0.1"
    port = 12345
    sslconfig = False
    verbose = 0
    for name, value in options:
        if name == "-6":
            prefer_ipv6 = 1
        elif name == "-A":
            address = value
        elif name == "-p":
            port = int(value)
        elif name == "-S":
            sslconfig = True
        elif name == "-v":
            verbose += 1

    level = logging.INFO
    if verbose > 0:
        level = logging.DEBUG
    logging.getLogger().setLevel(level)

    handler = RawClient()
    handler.connect((address, port), prefer_ipv6, sslconfig, {})
    POLLER.loop()
开发者ID:neubot,项目名称:neubot,代码行数:35,代码来源:raw_clnt.py


示例10: main

def main(args):
    ''' main() function '''

    CONFIG['verbose'] = 1

    ctx = {'uri': args[1]}
    RunnerDload(ctx)
    POLLER.loop()
开发者ID:EverlastingFire,项目名称:neubot,代码行数:8,代码来源:runner_dload.py


示例11: _connect

 def _connect(self):
     ''' Connect first available epnt '''
     sock = utils_net.connect(self.epnts.popleft(), self.prefer_ipv6)
     if sock:
         self.sock = sock
         self.timestamp = utils.ticks()
         POLLER.set_writable(self)
     else:
         self._connection_failed()
开发者ID:EverlastingFire,项目名称:neubot,代码行数:9,代码来源:connector.py


示例12: handle_write

 def handle_write(self):
     POLLER.unset_writable(self)
     if not utils_net.isconnected(self.endpoint, self.sock):
         self._connection_failed()
         return
     deferred = Deferred()
     deferred.add_callback(self._handle_connect)
     deferred.add_errback(self._handle_connect_error)
     deferred.callback(utils.ticks())
开发者ID:EverlastingFire,项目名称:neubot,代码行数:9,代码来源:connector.py


示例13: _connection_failed

 def _connection_failed(self):
     ''' Failed to connect first available epnt '''
     if self.sock:
         POLLER.unset_writable(self)
         self.sock = None  # MUST be below unset_writable()
     if not self.epnts:
         self.aterror.callback_each_np(self)
         return
     self._connect()
开发者ID:EverlastingFire,项目名称:neubot,代码行数:9,代码来源:connector.py


示例14: _periodic

 def _periodic(self, args):
     """ Periodically snap goodput """
     stream = args[0]
     if stream.opaque:
         deferred = Deferred()
         deferred.add_callback(self._periodic_internal)
         deferred.add_errback(lambda err: self._periodic_error(stream, err))
         deferred.callback(stream)
         POLLER.sched(1, self._periodic, stream)
开发者ID:neubot,项目名称:neubot,代码行数:9,代码来源:raw_clnt.py


示例15: main

def main(args):
    """ main() function """

    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    LOG.verbose()

    ctx = {"uri": args[1]}
    RunnerDload(ctx)
    POLLER.loop()
开发者ID:felipebusnello,项目名称:neubot,代码行数:10,代码来源:runner_dload.py


示例16: __init__

    def __init__(self, parent, sock, endpoint):
        Pollable.__init__(self)
        self.parent = parent
        self.lsock = sock
        self.endpoint = endpoint

        # Want to listen "forever"
        self.watchdog = -1

        POLLER.set_readable(self)
        self.parent.handle_listen(self)
开发者ID:claudiuperta,项目名称:neubot,代码行数:11,代码来源:udp_listener.py


示例17: main

def main(args):
    """ Main function """
    try:
        options, arguments = getopt.getopt(args[1:], "6A:np:vy")
    except getopt.error:
        sys.exit("usage: neubot skype [-6nvy] [-A address] [-p port]")
    if arguments:
        sys.exit("usage: neubot skype [-6nvy] [-A address] [-p port]")

    prefer_ipv6 = 0
    # address = 'master.neubot.org'
    address = "localhost"
    runner = 1
    port = 8080
    noisy = 0
    fakeprivacy = 0
    for name, value in options:
        if name == "-6":
            prefer_ipv6 = 1
        elif name == "-A":
            address = value
        elif name == "-n":
            runner = 0
        elif name == "-p":
            port = int(value)
        elif name == "-v":
            noisy = 1
        elif name == "-y":
            fakeprivacy = 1

    if os.path.isfile(DATABASE.path):
        DATABASE.connect()
        CONFIG.merge_database(DATABASE.connection())
    else:
        logging.warning("skype: database file is missing: %s", DATABASE.path)
        BACKEND.use_backend("null")
    if noisy:
        log.set_verbose()
    if runner:
        result = runner_clnt.runner_client(
            CONFIG["agent.api.address"], CONFIG["agent.api.port"], CONFIG["verbose"], "skype"
        )
        if result:
            sys.exit(0)

    logging.info("skype: running the test in the local process context...")
    if not fakeprivacy and not privacy.allowed_to_run():
        privacy.complain()
        logging.info("skype: otherwise use -y option to temporarily provide " "privacy permissions")
        sys.exit(1)

    handler = SkypeNegotiate()
    handler.connect((address, port), prefer_ipv6, 0, {})
    POLLER.loop()
开发者ID:claudiuperta,项目名称:neubot,代码行数:54,代码来源:skype.py


示例18: send

    def send(self, send_octets, send_complete):
        ''' Async send() '''

        if self.isclosed:
            raise RuntimeError('stream: send() on a closed stream')
        if self.send_octets:
            raise RuntimeError('stream: already send()ing')

        self.send_octets = send_octets
        self.send_complete = send_complete

        if self.send_blocked:
            logging.debug('stream: send() is blocked')
            return

        POLLER.set_writable(self)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:16,代码来源:stream.py


示例19: handshake

 def handshake(self):
     ''' Async SSL handshake '''
     try:
         self.opaque.sock.sock.do_handshake()
     except ssl.SSLError:
         exception = sys.exc_info()[1]
         if exception.args[0] == ssl.SSL_ERROR_WANT_READ:
             POLLER.set_readable(self)
         elif exception.args[0] == ssl.SSL_ERROR_WANT_WRITE:
             POLLER.set_writable(self)
         else:
             raise
     else:
         stream = self.opaque
         self.opaque = None
         stream.atconnect.callback(stream)
开发者ID:EverlastingFire,项目名称:neubot,代码行数:16,代码来源:sslstream.py


示例20: _schedule_after

 def _schedule_after(self, interval):
     ''' Schedule next rendezvous after interval seconds '''
     logging.info('background_rendezvous: next rendezvous in %d seconds',
                  interval)
     timestamp = POLLER.sched(interval, self.run)
     STATE.update('idle', publish=False)
     STATE.update('next_rendezvous', timestamp)
开发者ID:servetti-polito,项目名称:neubot-dash,代码行数:7,代码来源:background_rendezvous.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python state.STATE类代码示例发布时间:2022-05-27
下一篇:
Python notify.NOTIFIER类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap