本文整理汇总了Python中twisted.python.log.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _sighup_handler
def _sighup_handler(self, signum, frame):
self.ufc.configure()
# Si hemos cambiado la configuración de base de datos debemos abrir
# de nuevo todas las conexiones.
log.info("Restarting threadpool...")
reactor.getThreadPool().stop()
reactor.getThreadPool().start()
示例2: dispatch
def dispatch(self, msg):
match = self.regex.search(msg)
if not match:
log.debug('Failed to match snort rule-sid in msg: {!r}'.format(msg))
return msg
sid = match.group('sid')
if self.gid_ignore:
try: gid = match.group('gid')
except IndexError: pass
else:
if gid in self.gid_ignore: return msg
ts = time()
if self.sid_db_ts < ts - self.conf.sid_db_mtime_check_interval:
if not os.path.exists(self.conf.paths.sid_db)\
or max(0, *( os.stat(p).st_mtime
for p in [self.conf.paths.sid_src, self.conf.paths.refs]
if os.path.exists(p) )) > os.stat(self.conf.paths.sid_db).st_mtime:
self.update_sid_db()
self.sid_db = anydbm.open(self.conf.paths.sid_db)
try: ref = force_unicode(self.sid_db[force_bytes(sid)])
except KeyError:
log.info('Failed to find refs for sid: {!r} (msg: {!r})'.format(sid, msg))
else: msg += u'\n refs: {}'.format(ref)
return msg
示例3: handle_data
def handle_data(self, pt, timestamp, sample, marker):
if self.Done:
if self._cbDone:
self._cbDone()
return
# We need to keep track of whether we were in silence mode or not -
# when we go from silent->talking, set the marker bit. Other end
# can use this as an excuse to adjust playout buffer.
if not self.sending:
if not hasattr(self, 'warnedaboutthis'):
log.info(("%s.handle_media_sample() should only be called" +
" only when it is in sending mode.") % (self,))
if VERBOSE:
print "WARNING: warnedaboutthis"
self.warnedaboutthis = True
return
incTS = True
#Marker is on first packet after a silent
if not self._silent:
if marker:
marker = 0
self._silent = True
incTS = False
else:
marker = 1
self._silent = False
if incTS:
#Taking care about ts
self.ts += int(timestamp)
# Wrapping
if self.ts >= TWO_TO_THE_32ND:
self.ts = self.ts - TWO_TO_THE_32ND
self._send_packet(pt, sample, marker=marker)
示例4: prompt_user_for_chaincom_details
def prompt_user_for_chaincom_details():
"""
"""
config_file = get_config_file()
parser = SafeConfigParser()
parser.read(config_file)
if not parser.has_section('chain_com'):
message = '-' * 15 + '\n'
message += 'NOTE: Blockstore currently requires API access to chain.com\n'
message += 'for getting unspent outputs. We will add support for using\n'
message += 'bitcoind and/or other API providers in the next release.\n'
message += '-' * 15
log.info(message)
api_key_id = raw_input("Enter chain.com API Key ID: ")
api_key_secret = raw_input("Enter chain.com API Key Secret: ")
if api_key_id != '' and api_key_secret != '':
parser.add_section('chain_com')
parser.set('chain_com', 'api_key_id', api_key_id)
parser.set('chain_com', 'api_key_secret', api_key_secret)
fout = open(config_file, 'w')
parser.write(fout)
# update in config as well (which was already initialized)
config.CHAIN_COM_API_ID = api_key_id
config.CHAIN_COM_API_SECRET = api_key_secret
示例5: init_bitcoind
def init_bitcoind():
"""
"""
config_file = get_config_file()
parser = SafeConfigParser()
parser.read(config_file)
if parser.has_section('bitcoind'):
try:
return create_bitcoind_connection()
except:
return prompt_user_for_bitcoind_details()
else:
pass
else:
user_input = raw_input(
"Do you have your own bitcoind server? (yes/no): ")
if user_input.lower() == "yes" or user_input.lower() == "y":
return prompt_user_for_bitcoind_details()
else:
log.info(
"Using default bitcoind server at %s", config.BITCOIND_SERVER)
return create_bitcoind_connection()
示例6: onOpen
def onOpen(self):
log.info("WebSocket connection open.")
self.users = self.factory.users
self.factory.maxuid+=1
self.uid = self.factory.maxuid
self.users[self.uid]=self
self.sendMessage(json.dumps({"setuid":self.uid}))
示例7: request_exit_status
def request_exit_status(self, data):
# exit status is a 32-bit unsigned int in network byte format
status = struct.unpack_from(">L", data, 0)[0]
log.info("Received exit status request: %d", status)
self.exit_status = status
self.exit_defer.callback(self)
self.running = False
return True
示例8: vncdo
def vncdo():
usage = '%prog [options] (CMD CMDARGS|-|filename)'
description = 'Command line control of a VNC server'
op = VNCDoToolOptionParser(usage=usage, description=description)
add_standard_options(op)
op.add_option('--delay', action='store', metavar='MILLISECONDS',
default=os.environ.get('VNCDOTOOL_DELAY', 0), type='int',
help='delay MILLISECONDS between actions [%defaultms]')
op.add_option('--force-caps', action='store_true',
help='for non-compliant servers, send shift-LETTER, ensures capitalization works')
op.add_option('--localcursor', action='store_true',
help='mouse pointer drawn client-side, useful when server does not include cursor')
op.add_option('--nocursor', action='store_true',
help='no mouse pointer in screen captures')
op.add_option('-t', '--timeout', action='store', type='int', metavar='TIMEOUT',
help='abort if unable to complete all actions within TIMEOUT seconds')
op.add_option('-w', '--warp', action='store', type='float',
metavar='FACTOR', default=1.0,
help='pause time is accelerated by FACTOR [x%default]')
options, args = op.parse_args()
if not len(args):
op.error('no command provided')
setup_logging(options)
options.host, options.port = parse_host(options.server)
log.info('connecting to %s:%s', options.host, options.port)
factory = build_tool(options, args)
factory.password = options.password
if options.localcursor:
factory.pseudocusor = True
if options.nocursor:
factory.nocursor = True
if options.force_caps:
factory.force_caps = True
if options.timeout:
message = 'TIMEOUT Exceeded (%ss)' % options.timeout
failure = Failure(TimeoutError(message))
reactor.callLater(options.timeout, error, failure)
reactor.run()
sys.exit(reactor.exit_status)
示例9: receiveUnimplemented
def receiveUnimplemented( self, seqnum ):
"""
Called when an unimplemented packet message was received from the device.
@param seqnum: SSH message code
@type seqnum: integer
"""
message= "Got 'unimplemented' SSH message, seqnum= %d" % seqnum
log.info( message )
transport.SSHClientTransport.receiveUnimplemented(self, seqnum)
示例10: run_blockstored
def run_blockstored():
""" run blockstored
"""
global bitcoin_opts
parser = argparse.ArgumentParser(description="Blockstore Core Daemon version {}".format(config.VERSION))
parser.add_argument("--bitcoind-server", help="the hostname or IP address of the bitcoind RPC server")
parser.add_argument("--bitcoind-port", type=int, help="the bitcoind RPC port to connect to")
parser.add_argument("--bitcoind-user", help="the username for bitcoind RPC server")
parser.add_argument("--bitcoind-passwd", help="the password for bitcoind RPC server")
parser.add_argument("--bitcoind-use-https", action="store_true", help="use HTTPS to connect to bitcoind")
subparsers = parser.add_subparsers(dest="action", help="the action to be taken")
parser_server = subparsers.add_parser("start", help="start the blockstored server")
parser_server.add_argument("--foreground", action="store_true", help="start the blockstored server in foreground")
parser_server = subparsers.add_parser("stop", help="stop the blockstored server")
# Print default help message, if no argument is given
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
# propagate options
for (argname, config_name) in zip(
["bitcoind_server", "bitcoind_port", "bitcoind_user", "bitcoind_passwd"],
["BITCOIND_SERVER", "BITCOIND_PORT", "BITCOIND_USER", "BITCOIND_PASSWD"],
):
if hasattr(args, argname) and getattr(args, argname) is not None:
bitcoin_opts[argname] = getattr(args, argname)
setattr(config, config_name, getattr(args, argname))
if hasattr(args, "bitcoind_use_https"):
if args.bitcoind_use_https:
config.BITCOIND_USE_HTTPS = True
bitcoin_opts["bitcoind_use_https"] = True
if args.action == "start":
stop_server()
if args.foreground:
log.info("Initializing blockstored server in foreground ...")
run_server(foreground=True)
while 1:
stay_alive = True
else:
log.info("Starting blockstored server ...")
run_server()
elif args.action == "stop":
stop_server()
示例11: tryAuth
def tryAuth(self, kind):
kind = kind.replace("-", "_")
if kind != "publickey":
log.info("skipping auth method %s (not supported)" % kind)
return
log.info("trying to auth with %s!" % kind)
f = getattr(self, "auth_%s" % kind, None)
if f:
return f()
else:
return
示例12: vnclog
def vnclog():
usage = '%prog [options] OUTPUT'
description = 'Capture user interactions with a VNC Server'
op = optparse.OptionParser(usage=usage, description=description)
add_standard_options(op)
op.add_option('--listen', metavar='PORT', type='int',
help='listen for client connections on PORT [%default]')
op.set_defaults(listen=5902)
op.add_option('--forever', action='store_true',
help='continually accept new connections')
op.add_option('--viewer', action='store', metavar='CMD',
help='launch an interactive client using CMD [%default]')
options, args = op.parse_args()
setup_logging(options)
options.host, options.port = parse_host(options.server)
if len(args) != 1:
op.error('incorrect number of arguments')
output = args[0]
factory = build_proxy(options)
if options.forever and os.path.isdir(output):
factory.output = output
elif options.forever:
op.error('--forever requires OUTPUT to be a directory')
elif output == '-':
factory.output = sys.stdout
else:
factory.output = open(output, 'w')
if options.listen == 0:
log.info('accepting connections on ::%d', factory.listen_port)
factory.password = options.password
if options.viewer:
cmdline = '%s localhost::%s' % (options.viewer, factory.listen_port)
proc = reactor.spawnProcess(ExitingProcess(),
options.viewer, cmdline.split(),
env=os.environ)
reactor.run()
sys.exit(reactor.exit_status)
示例13: run_blockmirrord
def run_blockmirrord():
""" run blockmirrord
"""
global blockmirrord
global bitcoind
global namecoind
global cached_namespace
signal.signal(signal.SIGINT, signal_handler)
bitcoin_opts, parser = blockdaemon.parse_bitcoind_args( return_parser=True )
namecoin_opts, parser = parse_namecoind_args( return_parser=True, parser=parser )
parser.add_argument(
"--namespace",
help="path to the cached namespace JSON file")
subparsers = parser.add_subparsers(
dest='action', help='the action to be taken')
parser_server = subparsers.add_parser(
'start',
help='start the blockmirrord server')
parser_server.add_argument(
'--foreground', action='store_true',
help='start the blockmirrord server in foreground')
parser_server = subparsers.add_parser(
'stop',
help='stop the blockmirrord server')
args, _ = parser.parse_known_args()
# did we get a namespace JSON file?
if hasattr( args, "namespace" ) and getattr( args, "namespace" ) is not None:
namespace_path = args.namespace
namespace_json = None
log.info("Loading JSON from '%s'" % namespace_path)
with open(namespace_path, "r") as namespace_fd:
namespace_json = namespace_fd.read()
log.info("Parsing JSON")
try:
cached_namespace = json.loads( namespace_json )
except Exception, e:
log.exception(e)
exit(1)
示例14: run_blockstored
def run_blockstored():
""" run blockstored
"""
parser = argparse.ArgumentParser(
description='Blockstore Core Daemon version {}'.format(config.VERSION))
parser.add_argument(
'--bitcoind-server',
help='the hostname or IP address of the bitcoind RPC server')
parser.add_argument(
'--bitcoind-port', type=int,
help='the bitcoind RPC port to connect to')
parser.add_argument(
'--bitcoind-user',
help='the username for bitcoind RPC server')
parser.add_argument(
'--bitcoind-passwd',
help='the password for bitcoind RPC server')
subparsers = parser.add_subparsers(
dest='action', help='the action to be taken')
parser_server = subparsers.add_parser(
'start',
help='start the blockstored server')
parser_server.add_argument(
'--foreground', action='store_true',
help='start the blockstored server in foreground')
parser_server = subparsers.add_parser(
'stop',
help='stop the blockstored server')
# Print default help message, if no argument is given
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
if args.action == 'start':
stop_server()
if args.foreground:
log.info('Initializing blockstored server in foreground ...')
run_server(foreground=True)
while(1):
stay_alive = True
else:
log.info('Starting blockstored server ...')
run_server()
elif args.action == 'stop':
stop_server()
示例15: receiveDebug
def receiveDebug( self, alwaysDisplay, message, lang ):
"""
Called when a debug message was received from the device.
@param alwaysDisplay: boolean-type code to indicate if the message is to be displayed
@type alwaysDisplay: integer
@param message: debug message from remote device
@type message: string
@param lang: language code
@type lang: integer
"""
message= "Debug message from remote device (%s): %s" % ( str(lang), str(message) )
log.info( message )
transport.SSHClientTransport.receiveDebug(self, alwaysDisplay, message, lang )