def save_config(self, download=False): path = os.path.join(MEDIA_ROOT, 'mods', self.mod.title) config = TwConfig( os.path.join(path, 'servers', self.owner.username, '{0}'.format(self.id), self.random_key, 'generated.cfg')) for option in self.config_options.all(): if option.widget == Option.WIDGET_SELECT: value = option.value.split(',', 1)[0] widget = 'select:{0}'.format(option.value.split(',', 1)[1]) config.add_option(option.command, value, widget) else: if download and option.widget == Option.WIDGET_PASSWORD: config.add_option(option.command, '', option.get_widget_display()) else: config.add_option(option.command, option.value, option.get_widget_display()) if download: config.add_option('sv_port', '8303') else: config.add_option('sv_port', self.port.port) config.add_option('ec_port', self.port.port) config.add_option('ec_password', 'uptee') for tune in self.config_tunes.all(): config.add_tune(tune.command, tune.value) for vote in self.config_votes.all(): config.add_vote(vote.command, vote.title) for rcon_command in self.config_rconcommands.all(): config.add_rcon_command(rcon_command.command, rcon_command.value) config.write()
def save_config(self, download=False): path = os.path.join(MEDIA_ROOT, 'mods', self.mod.title) config = TwConfig(os.path.join(path, 'servers', self.owner.username, '{0}'.format(self.id), self.random_key, 'generated.cfg')) for option in self.config_options.all(): if option.widget == Option.WIDGET_SELECT: value = option.value.split(',', 1)[0] widget = 'select:{0}'.format(option.value.split(',', 1)[1]) config.add_option(option.command, value, widget) else: if download and option.widget == Option.WIDGET_PASSWORD: config.add_option(option.command, '', option.get_widget_display()) else: config.add_option(option.command, option.value, option.get_widget_display()) if download: config.add_option('sv_port', '8303') else: config.add_option('sv_port', self.port.port) config.add_option('ec_port', self.port.port) config.add_option('ec_password', 'uptee') for tune in self.config_tunes.all(): config.add_tune(tune.command, tune.value) for vote in self.config_votes.all(): config.add_vote(vote.command, vote.title) for rcon_command in self.config_rconcommands.all(): config.add_rcon_command(rcon_command.command, rcon_command.value) config.write()