def nameloader(**options): if 's' in options: return indexloader(**options) locals = { 'options': playernames(options), } return httpserver.load(os.path.join(DATADIR, 'name.html'), 'text/html', locals=locals)
def stoploader(self, headers, really=[], **options): count = len(gamesrv.clients) if count == 0 or really: locals = { 'self': self, #'metaserver': METASERVER, #'metapublish': gamesrv.game and my_server_meta_address(), #'localdir': LOCALDIR, } gamesrv.closeeverything() return httpserver.load(os.path.join(LOCALDIR, 'data', 'stop.html'), 'text/html', locals=locals) else: locals = { 'count': count, } return httpserver.load(os.path.join(LOCALDIR, 'data', 'confirm.html'), 'text/html', locals=locals)
def newloader(self, headers, **options): if not self.Game: raise HTTPRequestError, "Complete bub-n-bros installation needed" locals = { 'Game': self.Game, 'options': self.globaloptions, 'running': gamesrv.game is not None, } return httpserver.load(os.path.join(LOCALDIR, 'data', 'new.html'), 'text/html', locals=locals)
def mainpage(self, headers, juststarted=0, justconnected=0): running = my_server() count = len(gamesrv.clients) tim = time.time() #if running: # metapublish = my_server_meta_address() # fndesc = quote_plus(gamesrv.game.FnDesc) #else: # metapublish = None return httpserver.load(os.path.join(LOCALDIR, 'data', 'index.html'), 'text/html', locals=locals())
def optionsloader(self, headers, reset=[], savetime=[], **options): if reset: self.localoptions.clear() self.globaloptions.clear() self.saveoptions() elif savetime: self.localoptions.port_CLIENT = None self.localoptions.port_LISTEN = None self.localoptions.port_HTTP = None for key, value in options.items(): setattr(self.localoptions, key, value[0]) self.saveoptions() locals = { 'self' : self, 'options': self.localoptions, } return httpserver.load(os.path.join(LOCALDIR, 'data', 'options.html'), 'text/html', locals=locals)
def nameloader(self, headers, **options): MAX = len(PLAYERNAMES) if options: anyname = None for id in range(MAX): keyid = 'player%d' % id if keyid in options: value = options[keyid][0] anyname = anyname or value teamid = 'team%d' % id if teamid in options: team = options[teamid][0] if len(team) == 1: value = '%s (%s)' % (value, team) setattr(self.localoptions, keyid, value) if 'c' in options: for id in range(MAX): keyid = 'player%d' % id try: delattr(self.localoptions, keyid) except AttributeError: pass if 'f' in options: for id in range(MAX): keyid = 'player%d' % id if not getattr(self.localoptions, keyid): setattr(self.localoptions, keyid, anyname or PLAYERNAMES[id]) else: anyname = getattr(self.localoptions, keyid) self.saveoptions() if 's' in options: return self.mainpage(headers) locals = { 'options': self.localoptions.dict(), } return httpserver.load(os.path.join(LOCALDIR, 'data', 'name.html'), 'text/html', locals=locals)