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


Python Server.msg方法代码示例

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


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

示例1: MSG

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import msg [as 别名]
 def MSG(self, args):
     target = args[0]
     message = " ".join(args[1:])
     
     # can't send a message if not logged in
     if self.__nickname is None:
         ERRMSG(self.__sobj, "Not logged in")
         return
     
     # we won't ACK this on this side - the server has to do it,
     # before it fires the callback.  kind of lame and sphagetti like
     try:
         Server.msg(self.__nickname, target, message, self)
     except Exception, errmsg:
         ERRMSG(self.__sobj, errmsg)
开发者ID:unshift,项目名称:ita,代码行数:17,代码来源:client.py

示例2: BaskitCLI

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import msg [as 别名]

#.........这里部分代码省略.........
                                    impending server outage.
        
        -p/--no-players             Wait to stop server until no players are
                                    online.  Please note that this will cause
                                    baskit to wait a potentially long period
                                    of time.
        
        -n/--notify                 Notifies the players of the current wait
                                    status for the server shutdown.
        '''
        if not self.server.running():
            print 'Minecraft service already stopped.'
            return
        
        notify = False
        pwait = False
        wait = datetime.datetime.now()
        opts, args = getopt.getopt(s.split(), 'npt:', 
                                   ['timer=', 'no-players', 'notify'])
        for opt, val in opts:
            if opt in ('-t', '--timer'):
                wait = wait + datetime.timedelta(seconds=int(val))
            if opt in ('-p', '--no-players'):
                players = True
            if opt in ('-n', '--notify'):
                notify = True
        
        # Here is the wait loop for shutting down the server.
        while wait > datetime.datetime.now() and not players:
            if players:
                if len(self.server.players) < 1:
                    players = False
            if notify:
                msg = 'SERVER WILL SHUT DOWN IN %s SECONDS' %\
                      (wait - datetime.datetime.now()).seconds
                if players:
                    msg += ' WHEN ALL PLAYERS HAVE LEFT'
                self.server.msg(msg)
            time.sleep(10)
        self.server.stop()
        print 'Minecraft service has been stopped'
    

    def do_restart(self, s):
        '''restart
        Convenience function to restart the server.  No options are provided.
        '''
        self.server.stop()
        self.server.start()
    

    def do_server(self, s):
        '''server
        Returns the current server status as well as some known configuration
        information about the server.
        '''
        d1 = {True: 'running', False: 'stopped'}
        print 'Server Binary Information\n-------------------------'
        print 'Status : %s' % d1[self.server.running()]
        print 'Type   : %s' % self.server.server_type
        print 'Branch : %s' % self.server.server_branch
        print 'Build  : %s' % self.server.server_build
        print 'Worlds : %s' % ', '.join(self.server.worlds)


    def do_status(self, s):
开发者ID:SteveMcGrath,项目名称:baskit,代码行数:70,代码来源:cli.py


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