当前位置: 首页>>代码示例>>Python>>正文


Python Logging.net方法代码示例

本文整理汇总了Python中Logging.net方法的典型用法代码示例。如果您正苦于以下问题:Python Logging.net方法的具体用法?Python Logging.net怎么用?Python Logging.net使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Logging的用法示例。


在下文中一共展示了Logging.net方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: deleteBot

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def deleteBot(self, botID): #Note: Bots are deleted when their group is deleted. No need to delete them manually
   log.net("Destroying bot for Group",self.group.ID)
   if Events.IS_TESTING:
     log.net("JK ALSO NOT DELETING BOTS BECAUSE TESTING SORRY")
     return False
   response = self.post("bots/destroy", query = {"bot_id": botID})
   return response.code == 200
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:9,代码来源:Network.py

示例2: write

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def write(self, message, image = None, fromPoster = False):
   function = self._writePoster if fromPoster else self._write
   if not log.net.low.enabled: #Don't want to print the same message twice here
     log.net("Human" if fromPoster else "Bot", "writing message:", message)
   while len(message) >= 1000: #There is a limit on the length of messages we can write
     end = message.rfind("\n", 600, 999) #See if we can find an enter, split there
     if end < 0:
       end = message.rfind(" ", 0, 999) #Is there at least a space somewhere?
       if end < 0: end = 999 #Screw it
     function(message[0:end])
     message = message[end+1:]
   return function(message, image)
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:14,代码来源:Network.py

示例3: _writePoster

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def _writePoster(self, message, image = None):
   log.net.low("Human writing message:", message)
   poster = self.getPoster()
   if not poster:
     raise RuntimeError("Group " + str(self.group.ID) + " could not acquire a poster for message writing")
   response = self.post("groups/"+self.group.groupID+"/messages", headers = {"Content-Type":"application/json"}, body = {"message": {"source_guid": str(uuid.uuid4()), "text":str(message), "attachments":(None if not image else [{"type":"image","url":image}])}})
   if response.code == 201:
     log.net("Message write successful")
     return True
   else:
     log.net.error("MESSAGE WRITE FAILED:",response.code)
     return False
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:14,代码来源:Network.py

示例4: handle

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def handle(self):
   Handler.requestsProcessed += 1
   log.net("(#{}) File Requested: '{}'".format(Handler.requestsProcessed, self.fileName) + \
     (" for group {}".format(self.group) if self.group else ""))
     
   #Checking for user authorization
   self.userID = getCookie(self.cookies, self.COOKIE_ID)
   if not securityCanAccess(self.userID, self.group) and not self.fileName.endswith("password.html"):
     log.security("User not allowed to access", self.fileName+", returning password page")
     return self.redirectFile("password.html"+addParams({"redirect":self.fileName})) #Redirect back to the requested page when done
   
   try:
     return self.sendFile(self.fileName)
   except Exception as e: #Not BaseException though
     #In the event of any error, set this
     self.sendError(str(e))
     raise e #Raise it again so I can see what's going on
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:19,代码来源:Website.py

示例5: _write

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def _write(self, message, image = None, attemptRectify = True): #This method is for messages guarenteed to be less than 1000 characters in length
   log.net.low("Bot writing message:", message)
   bot = self.getBot()
   if not bot:
     raise RuntimeError("Group " + str(self.group.ID) + " could not acquire a bot for message writing")
   response = self.post("bots/post", body = {"text":str(message), "bot_id":bot, "attachments":([] if not image else [{"type":"image","url":image}])}, addToken = False)
   if response.code == 202:
     log.net("Message write successful")
     return True
   elif response.code == 404 and attemptRectify:
     log.net.error("Message write failed. Probable bot ID mismatch. Fixing")
     if self.rectifyBot():
       return self._write(message, image, attemptRectify = False) #We only want to attempt to rectify once
     else:
       log.net.error("Rectification attempt failed. Cannot post message")
       return False
   else:
     log.net.error("MESSAGE WRITE FAILED:",response.code)
     return False
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:21,代码来源:Network.py

示例6: createBot

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def createBot(self, name, avatar = None, mainBot = True):
   log.net("Making a new bot for Group",self.group.ID)
   if Events.IS_TESTING:
     log.net("JK NOT MAKING A BOT BECAUSE TESTING SORRY")
     return False
   postBody = {"bot":{"name":name, "group_id":self.group.groupID}}
   if avatar:
     #Check if the picture is properly uploaded
     if "i.groupme.com" in avatar:
       #Checks a tuple to see if it has the proper start. If it doesn't, append it
       if not avatar.startswith(("http://","https://")):
         avatar = "http://"+avatar
     else:
       log.group.error("NOTE: Bot has an invalid Avatar Url! Picture will not show up as intended")
     postBody['bot']['avatar_url'] = avatar
   if mainBot:
     postBody['bot']['callback_url'] = getIPAddress()
   else:
     postBody['bot']['callback_url'] = "http://127.0.0.0"
   response = self.post("bots", body = postBody)
   if response.code == 201:
     log.net("Bot create successful")
     return response['bot']['bot_id']
   log.net.error("Bot create failed")
   return False
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:27,代码来源:Network.py

示例7: rectifyBot

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def rectifyBot(self, botData = None, saveData = True):
   log.net("Attempting to rectify main bot of",self.group)
   botInfo = botData or self.getBotData() #will use given data if it exists
   if botInfo:
     for bot in botInfo:
       #If the bot is the proper full bot for our group
       if bot['group_id'] == self.group.groupID and (Events.IS_TESTING or bot['callback_url'] == getIPAddress()): #Only check address if not testing.
         log.net("Rectify success")
         if saveData:
           self.bot = bot['bot_id']
           self.group.bot = bot['bot_id']
           self.group.save()
           return True
         else:
           return bot['bot_id']
   else:
     log.net("Rectify failure")
     return False
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:20,代码来源:Network.py

示例8: updateBots

# 需要导入模块: import Logging [as 别名]
# 或者: from Logging import net [as 别名]
 def updateBots(self, botsList):
   if type(botsList) == str:
     botsList = [botsList]
     
   for bot in botsList[:1]: #...only doing the first one for now
     log.net("Updating bot with ID",bot)
     if self.deleteBot(bot):
       log.net("Successfully deleted bot! (sleeping for them to update database)")
       time.sleep(3) #Arbitrary time, should be more than enough
       id = self.createBotsly()
       if id:
         self.bot = id #Update us
         self.group.bot = id #Update our parent group
         self.group.save()
       else:
         log.net.error("COULD NOT UPDATE BOT ON CREATE, ERRORING")
         raise RuntimeError("COULD NOT CREATE BOT FOR UPDATE")
     else:
       if Events.IS_TESTING:
         log.net("JK NOT UPDATING BOTS BECAUSE TESTING SORRY")
         return False
       log.net.error("COULD NOT UPDATE BOT, ERRORING")
       raise RuntimeError("COULD NOT DELETE BOT FOR UPDATE")
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:25,代码来源:Network.py


注:本文中的Logging.net方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。