本文整理汇总了Python中util.Log.log方法的典型用法代码示例。如果您正苦于以下问题:Python Log.log方法的具体用法?Python Log.log怎么用?Python Log.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util.Log
的用法示例。
在下文中一共展示了Log.log方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _start
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import log [as 别名]
def _start(self):
# Some common tasks that need to be done when an operation starts
Log.log("Executing %s to %s" % (self.CommandType, self.DestIP))
self.DestName = IP.reverseDNS(self.DestIP)
self.DestAddress = IP.ip2int(self.DestIP)
# Current time
self.StartTime = str(datetime.utcnow()).strip("0")
self.LocalStartTime = str(datetime.now()).strip("0")
示例2: __init__
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import log [as 别名]
def __init__(self, scriptPath):
# Load the script into memory
self.scriptPath = scriptPath
self.xml = etree.parse(self.scriptPath)
self.id = self.xml.find("Script").get("id")
self.exid = self.xml.find("Script").get("ExID")
# Parse the script operations
operations = self.xml.find("Script").text.splitlines()
for operation in operations:
if len(operation) == 0:
continue
operation = operation.split()
if operation[0] == "PING":
op = PingOperation.PingOperation(self, operation[1])
elif operation[0] == "TRACEROUTE":
op = TracerouteOperation.TracerouteOperation(self, operation[1])
else:
raise Exceptions.ScriptParseException("Unknown operation: %s in script %s, PLEASE REPORT THIS!" %
(operation[0], self.scriptPath))
self.operationQ.put(op)
Log.log("Loaded script %s, %d operations to run" % (self.scriptPath, self.operationQ.qsize()), 1)
示例3: __init__
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import log [as 别名]
def __init__(self, script):
threading.Thread.__init__(self)
self.script = script
Log.log("Thread is %s, script is %s" % (self.name, self.script.id))
示例4:
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import log [as 别名]
from dimes import Script
from util import Log
from util import Config
import threading, time
script = Script.Script("default_script.xml")
script.execute()
try:
while threading.active_count() > 1:
time.sleep(0.1)
#Log.log("%d pending, %d complete" % (script.operationQ.qsize(), script.resultQ.qsize()))
Log.log("All done, exiting!", 2)
except KeyboardInterrupt:
Log.log("Received Ctrl+C, ending %d threads... (This may take a moment)" % threading.active_count(), 2)
示例5: ircController
# 需要导入模块: from util import Log [as 别名]
# 或者: from util.Log import log [as 别名]
class ircController(serverDispatcher, viewHandler):
def __init__(self, servername):
viewHandler.__init__(self)
serverDispatcher.__init__(self)
self.model = model.ircModel()
# local, view related state
self.channels = casedict()
self.queries = casedict()
#
# Add ourself to the model as a server
self.serverState = model.server()
# save serverid in case we ever need to refer to it
self.serverid = self.model.addServer(self.serverState)
self.view = ircView.getIrcView()
self.viewtext = self.view.new_view(servername)
self.viewtext.setname(servername)
self.cfg = getCfg()
self.logger = Log(servername)
self.notify = self.cfg('servers.notify', [])
for i in self.notify:
self.viewtext.notify_offline(i)
self.notify_delayer = delay.Delayed()
self.notify_delayer.ticktime = 10 # 1 tick = 10 sec
self.notify_delayer.loop(self.send_notify, 2)
main.addDelayed(self.notify_delayer)
def setcallback(self, cb):
self.handler = cb
def set_handler(self, handler):
self.new_handler = handler
def run(self, nick, name, host, port=6667):
self.viewtext.announce("Welcome to Most %s" % version)
self.viewtext.set_handler(self)
self.connect(host, port)
self.serverState.state = model.server.STATE_CONNECTING
self.serverState.name = name
self.serverState.nick = nick
def quit(self, msg = None):
""" invoked to terminate this connection / the entire client (?) """
if self.serverState.state != model.server.STATE_NOTCONNECTED:
self.irc.quit(msg or default_quit)
self.close()
def connect(self, host, port=6667):
""" connect to a new server """
# what about server.STATE_CONNECTING ?
if self.serverState.state in (model.server.STATE_CONNECTED,
model.server.STATE_CONNECTING):
self.viewtext.announce("Changing to server %s %d" % (host, port))
self.quit("Changing servers")
self.serverState.reset()
self.viewtext.announce("Connecting to server %s %d" % (host, port))
serverDispatcher.connect(self, host, port)
self.serverState.state = model.server.STATE_CONNECTING
# connect to new server
def disconnect(self, msg="User disconnect"):
""" simple disconnect, no reconnect, no quit """
if self.serverState.state in (model.server.STATE_CONNECTED,
model.server.STATE_CONNECTING):
self.viewtext.announce("Disconnecting...")
self.quit(msg)
self.stop()
self.serverState.reset()
self.reset()
def reset(self):
""" adjust widgets, etc after connection is closed """
self.serverState.reset() # resets notify, etc.
self.viewtext.reset()
def send_notify(self):
""" send notifies. This method runs in a Delayed """
str = ""
if self.serverState.state == model.server.STATE_CONNECTED:
for i in self.notify:
if len(str) + len(i) + 1 + 4 <= 512:
str = "%s %s" % (str, i)
else:
self.irc.ison(str)
str = ""
if str != "":
self.irc.ison(str)
# utility methods
def isme(self, nick):
return lower(self.nick()) == lower(nick)
def nick(self):
""" a shortcut """
#.........这里部分代码省略.........