本文整理汇总了Python中Logging.command方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.command方法的具体用法?Python Logging.command怎么用?Python Logging.command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logging
的用法示例。
在下文中一共展示了Logging.command方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle_baddresses
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import command [as 别名]
def handle_baddresses(command): #Copied from handle_addresses
#Note: This only works while Jacob's name is "Dingus Eck"
log.debug("Sender obj:", command.senderObj)
JACOB_CONSTANT = (any(name in command.senderObj.getGMName().lower() for name in ['eck','dan'])) if command.senderObj else False
log.debug("JACOB: ", JACOB_CONSTANT)
log.debug("Name checking:", command.senderObj.getGMName().lower())
for i in ['eck','dan']:
log.debug("Checking",i,":",i in command.senderObj.getGMName().lower())
names = []
add = []
users = command.group.users.getUsersSorted(lambda user: user.getName())
for user in users:
baseAddress = user.getAddress()
if baseAddress:
names.append("Addresses for " + user.getName() + ":\n")
add.append("--" + baseAddress + "\n")
for modifier in Events.ADDRESS_MODIFIERS: #Goes through all possible address types
subAddress = user.getAddress(modifier)
if subAddress:
add[-1] += "--" + modifier.title() + ": " + subAddress + "\n"
random.shuffle(names)
random.shuffle(add)
if JACOB_CONSTANT:
log.command("JACOB_CONSTANT ACTIVE")
add = [(''.join(random.sample(i[:-1], len(i)-1)))+"\n" for i in add]
return "".join([(names[i] + add[i]) for i in range(len(names))])
示例2: _handleMessage
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import command [as 别名]
def _handleMessage(self, message):
self.checkForEndedEvents()
### Everything to do with modifying events and their users ###
if message.hasAttachments("event"):
log.command("Running Event Code")
originalEvent = message.getAttachments("event")[0]['event_id']
if message.isUser() and "created event" in message.text: #This should be sent by a user
eventData = self.handler.getEventData(originalEvent)
if eventData:
self.newEventGroup(eventData)
return
log.group.error("No event found in group for event ID",originalEvent['event_id'])
elif message.isSystem(): #System informs people are going to/not going to/undecided about events
if "canceled" in message.text:
try:
log.group.debug("Event cancelled. Deleting group associated with",originalEvent)
self.eventGroups[originalEvent].deleteSelf()
log.group.debug("Deletion succeeded")
except KeyError:
log.group.debug("Deletion Failed. Group is not a child of receiver")
return
else:
for string in ['is going to', 'is not going to']:
if string in message.text:
userString = message.text[:message.text.rfind(string)]
try:
group = self.eventGroups[originalEvent]
except KeyError:
log.group.error("ERROR: No event group for event " + originalEvent + " not adding/removing users")
return
log.group("Removing" if "not" in string else "Adding","user '"+userString+"' for event",group)
if "not" in string:
#User may not exist in other group due to timing delays or what not, but should definitely exist in this group
user = group.users.getUserFromID(self.users.getUser(userString).ID)
if user:
group.removeEventUser(user)
else:
log.group.debug("Could not find user '"+userString+"' in event group, not removing")
else:
group.addEventUsers(self.users.getUser(userString))
break #Don't bother with other one if not done
return
elif message.isCalendar(): #Calendar sends event update notifications
eventData = self.handler.getEventData(originalEvent)
if eventData:
try:
self.eventGroups[eventData['event_id']].updateEvent(eventData)
except KeyError:
log.group.error("Tried updating event but event did not exist. Creating new instead")
self.newEventGroup(eventData)
super()._handleMessage(message)
示例3: handle_shutdown
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import command [as 别名]
def handle_shutdown(command):
Events.NonBlockingShutdownLock.acquire(blocking = False)
log.command("SIGNALLING SERVER SHUTDOWN")
return "Shutting Down Server!"
示例4: handle_restart
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import command [as 别名]
def handle_restart(command):
Events.NonBlockingRestartLock.acquire(blocking = False)
log.command("SIGNALLING SERVER RESTART")
return "Restarting Server!"
示例5: do_happy_birthday
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import command [as 别名]
def do_happy_birthday(self):
log.command("Wishing a happy birthday!")
self.recipientObj = self.group.users.getUser(self.wholeString)
示例6: do_human_affection
# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import command [as 别名]
def do_human_affection(self):
log.command("Searching for human affection")
self.recipientObj = self.group.users.getUser(self.wholeString)