本文整理汇总了Python中neubot.log.LOG类的典型用法代码示例。如果您正苦于以下问题:Python LOG类的具体用法?Python LOG怎么用?Python LOG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LOG类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_done
def test_done(self, *baton):
''' Invoked when the test is done '''
#
# Stop streaming test events to interested parties
# via the log streaming API.
#
LOG.stop_streaming()
# Paranoid
if baton[0] != 'testdone':
raise RuntimeError('Invoked for the wrong event')
# Notify the caller that the test is done
callback = self.queue.popleft()[2]
callback()
#
# Allow for more tests
# If callback() adds one more test, that would
# be run by the run_queue() invocation below.
#
self.running = False
# Eventually run next queued test
self.run_queue()
开发者ID:DavideAllavena,项目名称:neubot,代码行数:26,代码来源:runner_core.py
示例2: connection_made
def connection_made(self, sock, rtt=0):
if rtt:
LOG.debug("ClientHTTP: latency: %s" % utils.time_formatter(rtt))
self.rtt = rtt
stream = ClientStream(self.poller)
stream.attach(self, sock, self.conf, self.measurer)
self.connection_ready(stream)
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:7,代码来源:client.py
示例3: read_send_queue
def read_send_queue(self):
octets = ""
while self.send_queue:
octets = self.send_queue[0]
if isinstance(octets, basestring):
# remove the piece in any case
self.send_queue.popleft()
if octets:
break
else:
octets = octets.read(MAXBUF)
if octets:
break
# remove the file-like when it is empty
self.send_queue.popleft()
if octets:
if type(octets) == types.UnicodeType:
LOG.oops("Received unicode input")
octets = octets.encode("utf-8")
if self.encrypt:
octets = self.encrypt(octets)
return octets
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:25,代码来源:stream.py
示例4: lookup_country
def lookup_country(self, address):
''' Lookup for country entry '''
country = self.countries.country_code_by_addr(address)
if not country:
LOG.error("Geolocator: %s: not found" % address)
return ""
return utils.stringify(country)
开发者ID:DavideAllavena,项目名称:neubot,代码行数:7,代码来源:geoip_wrapper.py
示例5: 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
示例6: 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
示例7: run_queue
def run_queue(self):
''' If possible run the first test in queue '''
# Adapted from neubot/rendezvous/client.py
if not self.queue:
return
if self.running:
return
#
# Subscribe BEFORE starting the test, otherwise we
# may miss the 'testdone' event if the connection
# to the negotiator service fails, and we will stay
# stuck forever.
#
NOTIFIER.subscribe('testdone', self.test_done)
# Prevent concurrent tests
self.running = True
# Safely run first element in queue
try:
self._do_run_queue()
except (SystemExit, KeyboardInterrupt):
raise
except:
exc = asyncore.compact_traceback()
error = str(exc)
LOG.error('runner_core: catched exception: %s' % error)
NOTIFIER.publish('testdone')
开发者ID:felipebusnello,项目名称:neubot,代码行数:31,代码来源:runner_core.py
示例8: got_response_collecting
def got_response_collecting(self, stream, request, response):
LOG.complete()
if self.success:
#
# Always measure at the receiver because there is more
# information at the receiver and also to make my friend
# Enrico happier :-P.
# The following is not a bug: it's just that the server
# returns a result using the point of view of the client,
# i.e. upload_speed is _our_ upload speed.
#
m = json.loads(response.body.read())
self.my_side["upload_speed"] = m["upload_speed"]
upload = utils.speed_formatter(m["upload_speed"])
STATE.update("test_upload", upload)
if privacy.collect_allowed(self.my_side):
table_bittorrent.insert(DATABASE.connection(), self.my_side)
# Update the upstream channel estimate
target_bytes = int(m["target_bytes"])
if target_bytes > 0:
estimate.UPLOAD = target_bytes
stream.close()
开发者ID:DavideAllavena,项目名称:neubot,代码行数:27,代码来源:client.py
示例9: main
def main(args):
CONFIG.register_descriptions({
"speedtest.negotiate.address": "Address to listen to",
"speedtest.negotiate.auth_only": "Enable doing tests for authorized clients only",
"speedtest.negotiate.daemonize": "Enable going in background",
"speedtest.negotiate.port": "Port to listen to",
})
common.main("speedtest.negotiate", "Speedtest negotiation server", args)
conf = CONFIG.copy()
server = ServerSpeedtest(POLLER)
server.configure(conf)
server.listen((conf["speedtest.negotiate.address"],
conf["speedtest.negotiate.port"]))
if conf["speedtest.negotiate.daemonize"]:
system.change_dir()
system.go_background()
LOG.redirect()
system.drop_privileges(LOG.error)
POLLER.loop()
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:25,代码来源:negotiate.py
示例10: main
def main(args):
''' Run a subcommand's main() '''
# Args[0] must be the subcommand name
subcommand = args[0]
# Users are not supposed to prefix commands with 'neubot.'
subcommand = 'neubot.' + subcommand
# Dinamically load the selected subcommand's main() at runtime
__import__(subcommand)
mainfunc = sys.modules[subcommand].main
# Fix args[0]
args[0] = 'neubot ' + subcommand
# Run main()
try:
mainfunc(args)
except KeyboardInterrupt:
sys.exit(1)
except SystemExit:
raise
except:
LOG.exception()
sys.exit(1)
开发者ID:felipebusnello,项目名称:neubot,代码行数:26,代码来源:utils_module.py
示例11: merge_api
def merge_api(self, dictlike, database=None):
# enforce all-or-nothing
LOG.debug("config: reading properties from /api/config")
map(lambda t: self.merge_kv(t, dry=True), dictlike.iteritems())
map(self.merge_kv, dictlike.iteritems())
if database:
table_config.update(database, dictlike.iteritems())
开发者ID:DavideAllavena,项目名称:neubot,代码行数:7,代码来源:config.py
示例12: main
def main():
''' Merge Neubot databases '''
syslog.openlog('merge.py', syslog.LOG_PERROR, syslog.LOG_USER)
output = 'database.sqlite3'
try:
options, arguments = getopt.getopt(sys.argv[1:], 'o:v')
except getopt.error:
sys.exit('Usage: merge.py [-v] [-o output] file...')
if not arguments:
sys.exit('Usage: merge.py [-v] [-o output] file...')
for name, value in options:
if name == '-o':
output = value
elif value == '-v':
LOG.verbose()
beginning = {}
destination = __sqlite3_connect(output)
for argument in arguments:
source = __sqlite3_connect(argument)
for table in ('speedtest', 'bittorrent'):
# Just in case there are overlapping measurements
beginning[table] = __lookup_last(destination, table)
__copy_table(source, destination, table, beginning[table])
destination.commit()
开发者ID:bassosimone,项目名称:neubot-analyzer,代码行数:30,代码来源:merge.py
示例13: send_response
def send_response(self, request, response):
''' Send a response to the client '''
if self.response_rewriter:
self.response_rewriter(request, response)
if request['connection'] == 'close' or request.protocol == 'HTTP/1.0':
del response['connection']
response['connection'] = 'close'
self.send_message(response)
if response['connection'] == 'close':
self.close()
address = self.peername[0]
now = time.gmtime()
timestring = "%02d/%s/%04d:%02d:%02d:%02d -0000" % (now.tm_mday,
MONTH[now.tm_mon], now.tm_year, now.tm_hour, now.tm_min, now.tm_sec)
requestline = request.requestline
statuscode = response.code
nbytes = "-"
if response["content-length"]:
nbytes = response["content-length"]
if nbytes == "0":
nbytes = "-"
LOG.log("ACCESS",
"%s - - [%s] \"%s\" %s %s",
(address, timestring, requestline, statuscode, nbytes),
None)
开发者ID:claudiuperta,项目名称:neubot,代码行数:32,代码来源:server.py
示例14: _send_handshake
def _send_handshake(self):
''' Convenience function to send handshake '''
LOG.debug("> HANDSHAKE infohash=%s id=%s" %
(self.parent.infohash.encode("hex"),
self.parent.my_id.encode("hex")))
self.start_send("".join((chr(len(PROTOCOL_NAME)), PROTOCOL_NAME,
FLAGS, self.parent.infohash, self.parent.my_id)))
开发者ID:DavideAllavena,项目名称:neubot,代码行数:7,代码来源:stream.py
示例15: 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
示例16: _on_internal_error
def _on_internal_error(self, stream, request):
LOG.exception()
response = Message()
response.compose(code="500", reason="Internal Server Error",
body="500 Internal Server Error", keepalive=0)
stream.send_response(request, response)
stream.close()
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:7,代码来源:server.py
示例17: main
def main(args):
CONFIG.register_descriptions({
"rendezvous.server.address": "Set rendezvous server address",
"rendezvous.server.daemonize": "Enable daemon behavior",
"rendezvous.server.ports": "List of rendezvous server ports",
"rendezvous.server.update_uri": "Where to download updates from",
"rendezvous.server.update_version": "Update Neubot version number",
"rendezvous.geoip_wrapper.country_database": "Path of the GeoIP country database",
"rendezvous.server.default": "Default test server to use",
})
common.main("rendezvous.server", "Rendezvous server", args)
conf = CONFIG.copy()
HTTP_SERVER.configure(conf)
for port in conf["rendezvous.server.ports"].split(","):
HTTP_SERVER.listen((conf["rendezvous.server.address"], int(port)))
# Really start this module
run(POLLER, conf)
if conf["rendezvous.server.daemonize"]:
system.change_dir()
system.go_background()
LOG.redirect()
system.drop_privileges(LOG.error)
POLLER.loop()
开发者ID:ClaudioArtusio,项目名称:neubot,代码行数:29,代码来源:server.py
示例18: attach
def attach(self, parent, sock, conf):
self.parent = parent
self.conf = conf
self.filenum = sock.fileno()
self.myname = sock.getsockname()
self.peername = sock.getpeername()
self.logname = str((self.myname, self.peername))
LOG.debug("* Connection made %s" % str(self.logname))
if conf["net.stream.secure"]:
if not ssl:
raise RuntimeError("SSL support not available")
server_side = conf["net.stream.server_side"]
certfile = conf["net.stream.certfile"]
# wrap_socket distinguishes between None and ''
if not certfile:
certfile = None
ssl_sock = ssl.wrap_socket(sock, do_handshake_on_connect=False,
certfile=certfile, server_side=server_side)
self.sock = SSLWrapper(ssl_sock)
self.recv_ssl_needs_kickoff = not server_side
else:
self.sock = SocketWrapper(sock)
self.connection_made()
开发者ID:DavideAllavena,项目名称:neubot,代码行数:33,代码来源:stream.py
示例19: main
def main(args):
''' Main function '''
try:
options, arguments = getopt.getopt(args[1:], 'D:t:v')
except getopt.error:
sys.exit('usage: notifier_browser [-v] [-D setting] [-t time] page...')
if not arguments:
sys.exit('usage: notifier_browser [-v] [-D setting] [-t time] page...')
sleeptime = 0
for name, value in options:
if name == '-D':
CONFIG.register_property(value)
elif name == '-t':
sleeptime = int(value)
elif name == '-v':
LOG.verbose()
CONFIG.merge_properties()
for argument in arguments:
if argument == 'privacy':
NOTIFIER_BROWSER.notify_bad_privacy()
elif argument == 'update':
NOTIFIER_BROWSER.notify_update_avail()
else:
sys.exit('Invalid page. Valid pages are: privacy, update')
if sleeptime:
logging.debug('notifier_browser: sleep for %d seconds', sleeptime)
time.sleep(sleeptime)
开发者ID:felipebusnello,项目名称:neubot,代码行数:32,代码来源:notifier_browser.py
示例20: prettyprintbody
def prettyprintbody(self, prefix):
''' Pretty print body '''
if self["content-type"] not in ("application/json", "text/xml",
"application/xml"):
return
# Grab the whole body
if not isinstance(self.body, basestring):
body = self.body.read()
else:
body = self.body
# Decode the body
if self["content-type"] == "application/json":
string = compat.json.dumps(compat.json.loads(body),
indent=4, sort_keys=True)
elif self["content-type"] in ("text/xml", "application/xml"):
string = body
# Prettyprint
for line in string.split("\n"):
LOG.debug("%s %s" % (prefix, line.rstrip()))
# Seek to the beginning if needed
if not isinstance(self.body, basestring):
utils.safe_seek(self.body, 0)
开发者ID:DavideAllavena,项目名称:neubot,代码行数:26,代码来源:message.py
注:本文中的neubot.log.LOG类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论