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


Python Server.update方法代码示例

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


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

示例1: main

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import update [as 别名]
def main():
	server = Server()

	title = "capton"
	mode = (600, 600, 0, 32)

	pygame.init()
	pygame.display.set_caption(title)
	screen = pygame.display.set_mode(mode[:2], mode[2], mode[3])

	client = Client()

#	ENTITY_COLOR = (255, 255, 255)
#	client.set_entity_color(ENTITY_COLOR)

	client.send_connect(server)

	I_COUNT = 30
	J_COUNT = 30
	FILL_PERCENT = 20
	client.send_create_random_world(I_COUNT, J_COUNT, FILL_PERCENT)

	BOT_COUNT = 20
	client.send_add_bot(BOT_COUNT)

	client.send_restart_game()

	while True:
		server.update()

		client.update()
		client.draw(screen)

		time.sleep(1.0 / 60)
开发者ID:Ring-r,项目名称:sandbox,代码行数:36,代码来源:capton.py

示例2: BaskitCLI

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import update [as 别名]
class BaskitCLI(cmd.Cmd):
    prompt = 'baskit> '
    server = None
    
    def __init__(self):
        cmd.Cmd.__init__(self)
        self.server = Server()
        
        # This is some initialization stuff to make sure that the directory
        # structure that baskit expects is in place.
        for item in [self.server.env,
                     os.path.join(self.server.env, 'archive', 'backups'),
                     os.path.join(self.server.env, 'archive', 'snaps'),
                     os.path.join(self.server.env, 'persistent'),
                     os.path.join(self.server.env, 'env')]:
            if not os.path.exists(item):
                os.makedirs(item)


    def do_help(self, s):
        if s == '': self.onecmd('help help')
        else:
            cmd.Cmd.do_help(self, s) 

    

    def help_help(self):
        print '''Welcome to the Baskit Minecraft Server Manager!
        
        Baskit is designed to be a minimalistic, yet powerful server management
        system.  Baskit uses GNU-Screen at the heart of the application and
        simply wrap around that.  This means that you can perform in-place
        upgrades of Baskit, or even remove it completely without worry of it
        impacting the running server. There are a lot of functions available to 
        help assist you in managing the server as well, below is a high-level
        list of what is available.  For further detail (including avalable
        options) for any command, type help [COMMAND].

        start                       Starts the server.
        
        stop                        Stops the server.

        restart                     Restarts the server.

        server                      Returns the running state & server binary
                                    information that we have on-hand about
                                    the running server.

        cmd [COMMAND]               Sends the command specified to the server.
                                    There is no limit as to what can be sent
                                    here, and it is quite easy to script
                                    commands into the server with this.

        players                     Returns the list of players currently logged
                                    into the server.

        console                     Will drop you directly into the server
                                    console.  From here you are directly
                                    interacting with the server.  To detach from
                                    the server console, hit CNTRL+A,D to exit.

        update                      Allows you to update the server binary based
                                    on the conditions you had specified.  It's 
                                    highly recommended you run help update to
                                    get some more detail.

        backup                      All backup related functions are housed
                                    within the backup command.  Running "backup"
                                    will present it's help.

        snapshot                    All snapshot related functions are housed
                                    within the snapshot command.  Running
                                    "snapshot" will present it's help.

        sync                        Handles syncing to/from ramdisk and
                                    persistent storage if ramdisk support is
                                    enabled (disabled by default)
        '''
    

    def do_exit(self, s):
        '''exit
        Exits the interactive CLI
        '''
        return True
    

    def do_cmd(self, s):
        '''cmd [COMMAND]
        Sends the specified command to the Minecraft server console
        '''
        self.server.command(s)
        print 'Sent to console: %s' % s
    

    def do_players(self, s):
        '''players
        Retuns a list of the currently connected players
        '''
        if not self.server.running():
#.........这里部分代码省略.........
开发者ID:SteveMcGrath,项目名称:baskit,代码行数:103,代码来源:cli.py

示例3: sighandle

# 需要导入模块: from server import Server [as 别名]
# 或者: from server.Server import update [as 别名]
class Application:
	""" Main application class. """
	server = None

	def sighandle(self, signum, frame):
		""" Used for asynchronous signal handling. """
		print(' ')
		print('Killing ScalyMUCK server...')
		self.server.shutdown()	
		logging.shutdown()

	def __init__(self, workdir, is_daemon=False):
		""" Called by main() or by the daemoniser code. """	
		workdir += '/'

		home_path = os.path.expanduser('~')
		data_path = '%s/.scalyMUCK/' % (home_path)

		config = settings.Settings('%sconfig/settings_server.cfg' % (workdir))

		# Make sure the folder exists. (doesn't cause any issues if it already exists)
		os.system('mkdir %s' % (data_path))

		# Reset any logs
		if (config.get_index('ClearLogsOnStart', bool) is True):
			if ('win' in sys.platform):
				os.system('del %s*.txt' % (data_path))
			elif ('linux' in sys.platform):
				os.system('rm %s*.txt' % (data_path))
			
		# Prepare the server log
		# NOTE: This code looks sucky, could it be improved to look better?
		formatting = logging.Formatter('%(levelname)s (%(asctime)s): %(message)s', '%d/%m/%y at %I:%M:%S %p')
		console_handle = logging.StreamHandler()
		if (config.get_index(index='LogConnections', datatype=bool)):
			logger = logging.getLogger('Connections')
			logger.setLevel(logging.INFO)

			file_handle = logging.FileHandler('%sconnection_log.txt' % (data_path))
			file_handle.setLevel(logging.DEBUG)
			file_handle.setFormatter(formatting)

			logger.info('ScalyMUCK Server Server Start')
			logger.addHandler(file_handle)
			if (is_daemon is False):
				logger.addHandler(console_handle)

		if (config.get_index(index='LogServer', datatype=bool)):
			logger = logging.getLogger('Server')
			logger.setLevel(logging.INFO)

			file_handle = logging.FileHandler('%sserver_log.txt' % (data_path))
			file_handle.setLevel(logging.INFO)
			file_handle.setFormatter(formatting)			

			logger.addHandler(file_handle)
			if (is_daemon is False):
				logger.addHandler(console_handle)
			logger.info('ScalyMUCK Server Server Start')

		# Check for if we're trying to run as root (if we're on linux)
		if ('linux' in sys.platform):
			run_as_root = config.get_index(index='I_DONT_KNOW_HOW_TO_SECURITY_LET_ME_RUN_AS_ROOT',datatype=bool)
			if (os.geteuid() == 0 and run_as_root is False):
				logger.error('FATAL -- You should not run this application as root!')
				return
			elif (os.geteuid() == 0 and run_as_root):
				logger.warn('WARNING -- It is your death wish running this application as root.')

		# Prepare the other logs
		if (config.get_index(index='LogMods', datatype=bool)):
			logger = logging.getLogger('Mods')
			logger.setLevel(logging.INFO)

			file_handle = logging.FileHandler('%smod_log.txt' % (data_path))
			file_handle.setLevel(logging.INFO)
			file_handle.setFormatter(formatting)

			logger.info('ScalyMUCK Server Server Start')
			logger.addHandler(file_handle)
			if (is_daemon is False):
				logger.addHandler(console_handle)

		self.server = Server(config=config, path=data_path, workdir=workdir)

		# Set the signals for asynchronous events
		signal.signal(signal.SIGINT, self.sighandle)
		signal.signal(signal.SIGTERM, self.sighandle)

		while (self.server.is_running):
			self.server.update()

		print(' ')
		print('Killing ScalyMUCK server ...')
		self.server.shutdown()	
		logging.shutdown()
开发者ID:Ragora,项目名称:ScalyMUCK,代码行数:98,代码来源:main.py


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