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


Python Network.getIPAddress方法代码示例

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


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

示例1: handle_help

# 需要导入模块: import Network [as 别名]
# 或者: from Network import getIPAddress [as 别名]
 def handle_help(command):
   mainString = "Try out the website! {}\n(Password: "+command.group.getPassword()+")"
   try:
     return mainString.format(Network.getIPAddress())
   except RuntimeError:
     IP = Network.readIPFile()
     if IP:
       return mainString.format(Network.readIPFile() + " (hopefully...)")
     return mainString.format("I have no idea what it is, but it probably exists! (Go yell at Daniel)")
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:11,代码来源:Commands.py

示例2: postInit

# 需要导入模块: import Network [as 别名]
# 或者: from Network import getIPAddress [as 别名]
 def postInit(self): #We want group data to be loaded by "load" before we initialize all users
   if self.groupID:
     groupRegister(self) #Register new connections
     #Set up handler with groupID and info
     self.handler.postInit()
     try:
       #Must be done after handler initialized
       self.loadUsersFromWeb()
       if self.markedForDeletion:
         raise AssertionError("Group is marked for deletion, not trying to update bots")
        #If the IP address has changed since the last server restart
       if self.bot != None: #We don't do getBot here because that could actually create a new bot
         response = self.handler.getBotData()
         if response:
           try: #Filter out the bots for the one we have registered to this group
             ownBot = [bot for bot in response if bot['bot_id'] == self.getBot()][0]
           except IndexError: #If we haven't found one, we don't have a bot, and our data is faulty
             log.group.web("No external bot found, rectifying/creating new bot")
             if not self.handler.rectifyBot(response):
               self.bot = self.handler.createBotsly()
               if not self.bot:
                 log.error("Could not get bot for", self)
                 raise RuntimeError("BOT SHOULD EXIST FOR " + repr(self) + " BUT COULD NOT BE FOUND")
           else: #If the bot we found doesn't have the proper ip address, update it's ip address
             if ownBot['callback_url'] != Network.getIPAddress():
               log.group("IP has changed! Updating bot id")
               self.handler.updateBots(self.getBot())
         
       #After all that is done, update the message list
       MsgSearch.getSearcher(self).GenerateCache()
     except ConnectionError: #Indicates internet is down
       log.group.error("Failed to update users from web")
   else:
     log.group.error("WARNING: Group", self.ID,"has no groupID")
   
   self.save()
开发者ID:civilwargeeky,项目名称:GroupMeServer3,代码行数:38,代码来源:Groups.py


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