def parseOptions(self, options): config = registry.getConfig() usage.Options.parseOptions(self, options) # check options gameType = self.get(const.GAME_TYPE) if gameType and gameType not in self.legalGameTypes: msg = "'%s' is not a supported game type'" % gameType raise exceptions.UnsupportedGameType(msg) storyDir = self.get(const.STORY_DIR) storyFile = self.get(const.STORY_FILE) storyModule = self.get(const.STORY_MODULE) bannerFile = os.path.abspath(os.path.join(storyDir, self.get(const.BANNER_FILE))) if not storyDir == config.game.storydir: config.game.storydir = storyDir config.game.storyfile = os.path.abspath(os.path.join(storyDir, storyFile)) config.game.storymodule = storyModule with open(bannerFile) as bannerFile: config.game.banner = util.renderBanner(config.ssh.banner, bannerFile.read(), config.game.helpprompt) if self.subCommand == const.KEYGEN: scripts.KeyGen() sys.exit(const.OK) elif self.subCommand == const.SHELL: scripts.ConnectToShell() sys.exit(const.OK) elif self.subCommand == const.STOP: scripts.StopDaemon() sys.exit(const.OK) # do the non-twisted game types if gameType == const.LOCAL: util.setupLogging(self.get(const.LOG_FILE)) runner.runLocal()
def __init__(self, main, ssh, game): super(MyriadConfigurator, self).__init__(main, ssh) self.game = game with open(game.bannerfile) as banner_file: self.banner = util.renderBanner( self.ssh.banner, banner_file.read(), game.helpprompt)