本文整理汇总了Python中neubot.poller.POLLER类的典型用法代码示例。如果您正苦于以下问题:Python POLLER类的具体用法?Python POLLER怎么用?Python POLLER使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了POLLER类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
示例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()
示例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)
示例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()
示例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()
示例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()
示例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()
示例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()
示例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()
示例10: main
def main(args):
''' main() function '''
CONFIG['verbose'] = 1
ctx = {'uri': args[1]}
RunnerDload(ctx)
POLLER.loop()
示例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()
示例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())
示例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()
示例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)
示例15: main
def main(args):
""" main() function """
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
LOG.verbose()
ctx = {"uri": args[1]}
RunnerDload(ctx)
POLLER.loop()