本文整理汇总了Python中kol.util.Report.trace方法的典型用法代码示例。如果您正苦于以下问题:Python Report.trace方法的具体用法?Python Report.trace怎么用?Python Report.trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kol.util.Report
的用法示例。
在下文中一共展示了Report.trace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseResponse
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def parseResponse(self):
ignorePattern = PatternManager.getOrCompilePattern("traderIgnoringUs")
if ignorePattern.search(self.responseText):
raise Error.Error("That player has you on his/her ignore list.", Error.USER_IS_IGNORING)
roninPattern = PatternManager.getOrCompilePattern("traderIsInRoninHC")
if roninPattern.search(self.responseText):
raise Error.Error("That player is in Ronin or HC and cannot receive trade offers.", Error.USER_IN_HARDCORE_RONIN)
itemsPattern = PatternManager.getOrCompilePattern("traderHasNotEnoughItems")
if itemsPattern.search(self.responseText):
raise Error.Error("You don't have enough of one or more of the items you're trying to trade.", Error.NOT_ENOUGH_ITEMS)
meatPattern = PatternManager.getOrCompilePattern("traderHasNotEnoughMeat")
if meatPattern.search(self.responseText):
raise Error.Error("You don't have as much meat as you're trying to trade.", Error.NOT_ENOUGH_MEAT)
chatBannedPattern = PatternManager.getOrCompilePattern("traderBannedFromChat")
if chatBannedPattern.search(self.responseText):
raise Error.Error("You are banned from chat and consequently cannot trade.", Error.BANNED_FROM_CHAT)
successPattern = PatternManager.getOrCompilePattern("tradeSentSuccessfully")
if successPattern.search(self.responseText):
Report.trace("request", "Trade offer sent successfully.")
else:
raise Error.Error("Other error sending trade offer.", Error.ERROR)
示例2: discoverMissingItems
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def discoverMissingItems(session):
global __isLoaded
if not __isLoaded:
loadItemsFromFile()
newInformation = False
from kol.request.InventoryRequest import InventoryRequest
from kol.request.ItemInformationRequest import ItemInformationRequest
invRequest = InventoryRequest(session)
invRequest.ignoreItemDatabase = True
invData = invRequest.doRequest()
for item in invData["items"]:
if item["id"] not in __itemsById:
try:
itemRequest = ItemInformationRequest(session, item["id"])
itemData = itemRequest.doRequest()
item = itemData["item"]
addItem(item)
Report.trace("itemdatabase", "Discovered new item: %s" % item["name"])
context = { "item" : item }
FilterManager.executeFiltersForEvent("discoveredNewItem", context, session=session, item=item)
newInformation = True
except:
pass
if newInformation or not __isLoaded:
saveItemsToFile()
__isLoaded = True
示例3: parseResponse
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def parseResponse(self):
# First parse for errors
notEnoughPattern = PatternManager.getOrCompilePattern("dontHaveThatManyInStore")
if notEnoughPattern.search(self.responseText):
raise Error.Error("You either don't have that item, or not enough", Error.ITEM_NOT_FOUND)
# Check if responseText matches the success pattern. If not, raise error.
itemTakenSuccessfully = PatternManager.getOrCompilePattern("itemTakenSuccessfully")
if itemTakenSuccessfully.search(self.responseText):
Report.trace('request', 'Item appears to have been taken')
else:
raise Error.Error("Something went wrong with the taking of the item.", Error.ITEM_NOT_FOUND)
示例4: parseResponse
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def parseResponse(self):
# Get the timestamp we should send to the server next time we make a request.
lastSeenPattern = PatternManager.getOrCompilePattern("chatLastSeen")
match = lastSeenPattern.search(self.responseText)
self.responseData["lastSeen"] = match.group(1)
# Parse the chat messages.
text = self.responseText[:self.responseText.find('<!--lastseen')]
self.responseData["chatMessages"] = ChatUtils.parseMessages(self.responseText, True)
# Trace out unknown messages.
for chat in self.responseData["chatMessages"]:
if chat["type"] == "unknown":
Report.trace("chat", "Unable to parse chat message: %s" % chat)
示例5: run
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def run(self):
Report.trace('relay', 'Starting RelayServer on port %s...' % self.port)
started = False
numTries = 0
while not started:
try:
server = HTTPServer(('', self.port), RelayRequestHandler)
started = True
except socket.error, inst:
numTries += 1
if numTries == 10:
raise inst
Report.trace('relay', 'Could not listen on port %s. Trying %s instead.' % (self.port, self.port + 1))
self.port += 1
示例6: couldNotFindItem
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def couldNotFindItem(context, **kwargs):
if "session" not in kwargs:
return
session = kwargs["session"]
item = None
r = ClosetContentsRequest(session)
r.skipParseResponse = True
r.doRequest()
if "descId" in kwargs:
descId = kwargs["descId"]
pattern = re.compile("<option value='([0-9]+)' descid='%s'>([^<>]*) \([0-9]+\)<\/option>" % descId)
match = pattern.search(r.responseText)
if match:
item = {"id":int(match.group(1)), "descId":descId, "name":match.group(2)}
else:
raise ItemNotFoundError("Could not find item associated with description ID '%s'." % descId)
elif "itemId" in kwargs:
itemId = kwargs["itemId"]
pattern = re.compile("<option value='%s' descid='([0-9]+)'>([^<>]*) \([0-9]+\)<\/option>" % itemId)
match = pattern.search(r.responseText)
if match:
item = {"id":itemId, "descId":int(match.group(1)), "name":match.group(2)}
else:
raise ItemNotFoundError("Could not find item associated with ID '%s'." % itemId)
elif "itemName" in kwargs:
itemName = kwargs["itemName"]
pattern = re.compile("<option value='([0-9]+)' descid='([0-9]+)'>%s \([0-9]+\)<\/option>" % itemName)
match = pattern.search(r.responseText)
if match:
item = {"id":int(match.group(1)), "descId":int(match.group(2)), "name":itemName}
else:
raise ItemNotFoundError("Could not find item with name '%s'." % itemName)
if item != None:
r = ItemDescriptionRequest(session, item["descId"])
itemInfo = r.doRequest()
for k,v in itemInfo.iteritems():
item[k] = v
Report.trace("itemdatabase", "Discovered new item: %s" % item)
context["item"] = item
FilterManager.executeFiltersForEvent("discoveredNewItem", session=session, item=item)
示例7: parseResponse
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def parseResponse(self):
# First parse for errors
notEnoughPattern = PatternManager.getOrCompilePattern("dontHaveEnoughOfItem")
if notEnoughPattern.search(self.responseText):
raise Error.Error("You don't have that many of that item.", Error.ITEM_NOT_FOUND)
dontHaveItemPattern = PatternManager.getOrCompilePattern("dontHaveThatItem")
if dontHaveItemPattern.search(self.responseText):
raise Error.Error("You don't have that item.", Error.ITEM_NOT_FOUND)
# Check if responseText matches the success pattern. If not, raise error.
itemAddedSuccessfully = PatternManager.getOrCompilePattern("itemAddedSuccessfully")
if itemAddedSuccessfully.search(self.responseText):
Report.trace('request', 'Item appears to have been added')
else:
raise Error.Error("Something went wrong with the adding.", Error.ITEM_NOT_FOUND)
示例8: parseResponse
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def parseResponse(self):
noMeatPattern = PatternManager.getOrCompilePattern('traderHasNotEnoughMeat')
if noMeatPattern.search(self.responseText):
raise Error.Error("You don't have as much meat as you're promising.", Error.NOT_ENOUGH_MEAT)
noItemsPattern = PatternManager.getOrCompilePattern('traderHasNotEnoughItems')
if noItemsPattern.search(self.responseText):
raise Error.Error("You don't have as many items as you're promising.", Error.NOT_ENOUGH_ITEMS)
#Not testing for an offer being cancelled due to a bug in KoL - space reserved
successPattern = PatternManager.getOrCompilePattern('tradeResponseSentSuccessfully')
if successPattern.search(self.responseText):
Report.trace("request", "Response to trade " + str(self.requestData['whichoffer']) + ' sent successfully.')
else:
raise Error.Error("Unknown error sending response to trade " + str(self.requestData['whichoffer']), Error.REQUEST_GENERIC)
示例9: openAllGiftPackages
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def openAllGiftPackages(self):
Report.trace("kmail", "Opening gift package(s).")
giftPackages = {}
# Get a list of all gift packages in our inventory.
r = InventoryRequest(self.session, which=3)
responseData = r.doRequest()
items = responseData["items"]
for item in items:
if "type" in item and item["type"] == "gift package":
giftPackages[item["id"]] = item["quantity"]
# Open all of the gift packages.
for itemId,quantity in giftPackages.iteritems():
for i in range(quantity):
r = UseItemRequest(self.session, itemId)
r.doRequest()
示例10: botEndCycle
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def botEndCycle(context, **kwargs):
returnCode = FilterManager.CONTINUE
bot = kwargs['bot']
# Check for new kmails?
aleabot.kmail_check_timer += aleabot.config.get('time_to_sleep')
if aleabot.kmail_check_timer >= aleabot.config.get('time_to_sleep_kmail'):
Report.trace('bot', 'Enabling doWork:kmail')
bot.params['doWork:kmail'] = True
aleabot.kmail_check_timer = 0
else:
Report.trace('bot', 'Disabling doWork:kmail')
bot.params.pop('doWork:kmail', None)
# Update clan state in regular intervals (as configured)
try:
aleabot.clanstate.set_session(bot.session)
if aleabot.clanstate.update(aleabot.config.get('clan_state_refresh_time')):
Report.info('bot', 'Clan state update successful.')
Report.trace('bot', 'I am in clan: ' + repr(aleabot.clanstate.my_clan()))
Report.trace('bot', 'I have ' + str(len(aleabot.clanstate.my_whitelists())) + ' whitelists')
# Set timer to switch back to home clan
if aleabot.home_clan_timer < 0:
aleabot.home_clan_timer = 0
except alea.clan.ClanRequestError as err:
Report.error('bot', 'Unable to update clan state! Error: ' + str(err))
# Switch to home clan after some delay
if aleabot.home_clan_timer >= 0:
aleabot.home_clan_timer += aleabot.config.get('time_to_sleep')
if aleabot.home_clan_timer >= aleabot.config.get('home_clan_delay'):
aleabot.home_clan_timer = -1
# Breakfast now if not yet breakfasted today
if 'breakfast' not in bot.states['rollover']:
alea.breakfast.breakfast(bot.session)
bot.states['rollover']['breakfast'] = True
bot.writeState('rollover')
# Switch to home clan now
home_clan_id = aleabot.config.get('home_clan_id')
if home_clan_id > 0 and aleabot.clanstate.my_clan().id() != home_clan_id:
Report.info('bot', 'Switching back to home clan.')
try:
aleabot.clanstate.switch(alea.clan.Clan(home_clan_id, ''))
except alea.clan.ClanRequestError as err:
Report.error('bot', 'Unable to switch clan! Error: ' + str(err))
return returnCode
示例11: whois
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def whois(bot, name):
Report.trace('bot', 'Whois: ' + name)
response = bot.sendChatMessage('/whois ' + name)
responsetext = ''.join(x['text'] for x in response)
match = re.search(r'<a[^>]*showplayer.php[^>]*><b[^>]*>([A-Za-z0-9_ ]+) \(#([0-9]+)\)</b></a>', responsetext)
if match:
player_name = match.group(1)
player_id = match.group(2)
Report.trace('bot', 'Whois resolved: Name: ' + str(player_name))
Report.trace('bot', 'Whois resolved: ID: ' + str(player_id))
return player_name, player_id
elif 'Unknown Player: ' in responsetext:
raise Error.Error("That player could not be found.", Error.USER_NOT_FOUND)
else:
Report.warning('bot', 'Unable to parse /whois response: ' + repr(responsetext))
raise Error.Error("Unable to parse /whois response.", Error.REQUEST_GENERIC)
示例12: run
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def run(self):
Report.trace('relay', 'Starting RelayServer on port %s...' % self.port)
server = HTTPServer(('', 8557), RelayRequestHandler)
server.relayServer = self
Report.trace('relay', 'RelayServer started.')
# Launch the relay server URL in a browser window.
url = 'http://localhost:%s/main.html' % self.port
sysname = os.uname()[0]
if sysname == "darwin":
os.spawnlp(os.P_NOWAIT, "open", "open", url)
else:
os.startfile(url)
# Handle requests for as long as we can.
while (not self.haltEvent.isSet()):
server.handle_request()
# Shut down the RelayServer.
Report.trace('relay', 'Shutting down RelayServer.')
server.socket.close()
示例13: init
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def init():
"""
Initializes the SkillDatabase. This method should be called before the
database is ever accessed as it ensures that the database is populated
with all of the data it needs.
"""
global __isInitialized
if __isInitialized == True:
return
Report.trace("skilldatabase", "Initializing the skill database.")
returnCode = FilterManager.executeFiltersForEvent("preInitializeSkillDatabase")
if returnCode == FilterManager.FINISHED:
Report.trace("skilldatabase", "Skill database initialized.")
__isInitialized = True
return
for skill in Skills.skills:
addSkill(skill)
FilterManager.executeFiltersForEvent("postInitializeSkillDatabase")
__isInitialized = True
Report.trace("skilldatabase", "Skill database initialized.")
示例14: init
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def init():
"""
Initializes the ItemDatabase. This method should be called before the
database is ever accessed as it ensures that the database is populated
with all of the data it needs.
"""
global __isInitialized
if __isInitialized == True:
return
Report.trace("itemdatabase", "Initializing the item database.")
returnCode = FilterManager.executeFiltersForEvent("preInitializeItemDatabase")
if returnCode == FilterManager.FINISHED:
Report.trace("itemdatabase", "Item database initialized.")
__isInitialized = True
return
for item in Items.items:
addItem(item)
FilterManager.executeFiltersForEvent("postInitializeItemDatabase")
__isInitialized = True
Report.trace("itemdatabase", "Item database initialized.")
示例15: init
# 需要导入模块: from kol.util import Report [as 别名]
# 或者: from kol.util.Report import trace [as 别名]
def init():
"""
Initializes the QkillDatabase. This method should be called before the
database is ever accessed as it ensures that the database is populated
with all of the data it needs.
"""
global __isInitialized
if __isInitialized == True:
return
Report.trace("questdatabase", "Initializing the quest database.")
returnCode = FilterManager.executeFiltersForEvent("preInitializeQuestDatabase")
if returnCode == FilterManager.FINISHED:
Report.trace("questdatabase", "Quest database initialized.")
__isInitialized = True
return
for quest in Quests.quests:
addQuest(quest)
FilterManager.executeFiltersForEvent("postInitializeQuestDatabase")
__isInitialized = True
Report.trace("questdatabase", "Quest database initialized.")