async def process(self, message, args): # args = [(var name)?, (var value)?] if len(args) == 0: out = config.all_config_vars_str() await discord_funcs.reply_to_message(message, out) elif len(args) == 1: var_name = args[0] if not config.check_var_exists(var_name): import error_messages return await error_messages.error_var_does_not_exist( message, var_name) config_vars = config.get_config_vars() var_val = config.get_var_val_from_vars(var_name, config_vars) out = config.var_to_str(var_name, var_val) await discord_funcs.reply_to_message(message, out) elif len(args) == 2: var_name = args[0] if not config.check_var_exists(var_name): import error_messages return await error_messages.error_var_does_not_exist( message, var_name) var_val = args[1] config_vars = await config.set_var(message, var_name, var_val) if config_vars is None: return min_percent = config.get_var_val_from_vars( config.ConfigVars.percent.value.var_name(), config_vars) no_players = config.get_var_val_from_vars( config.ConfigVars.players.value.var_name(), config_vars) problems_table.update_activity_all_problems( min_percent, no_players) await config.display_successful_set_var(message, var_name, var_val)
async def process(self, message, args): # args = [(command)?] if len(args) == 0: await help.display_general_help(message) else: command_name = args[0] command_found = False # A variable and a command shouldn't have the same name # but in the case they somehow do, the user should see both help messages for user_command in UserCommands: uc_val = user_command.value if uc_matches_command_name(uc_val, command_name): await help.display_help_message(message, uc_val) command_found = True for var in config.ConfigVars: if command_name == var.value.var_name(): out = config.var_to_help_str(var.value, config.get_config_vars()) await discord_funcs.reply_to_message(message, out) command_found = True if command_found: return out = "No command with name \"{}\" was found.\n".format( command_name) out += help.list_all_commands() await discord_funcs.reply_to_message(message, out)
async def process(self, message, args): # args = [(problem ID || -1)?] if len(args) == 0: active_problems = problems_table.get_active_problems() if len(active_problems) == 0: return await problems_table.send_no_active_problems( message, False) if not discord_funcs.is_a_dm(message): out = "Here are the active problems: " await discord_funcs.reply_to_message(message, out) await problems_table.send_problems(message, active_problems) else: name = discord_funcs.get_username(message) config_vars = config.get_config_vars() min_percent = config.get_var_val_from_vars( config.ConfigVars.percent.value.var_name(), config_vars) new_problem_ids = [] for p in active_problems: problem_id = p[constants.ProblemTableStruct.ID.value] attempts = problem_files.get_all_attempts(problem_id) userAttempt = [ a for a in attempts if a[constants.ProblemFileStruct.NAME.value] == name ] if len(userAttempt) == 0 or problems_table.attempt_fails( userAttempt[0], min_percent): new_problem_ids.append(problem_id) new_active_problems = [ p for p in active_problems if p[constants.ProblemTableStruct.ID.value] in new_problem_ids ] if len(new_active_problems) == 0: return await problems_table.send_no_active_problems( message, True) out = "Here are your active problems" await discord_funcs.reply_to_message(message, out) await problems_table.send_problems(message, new_active_problems) elif args[0] == constants.ALL_ID: all_problems = problems_table.get_all_problems() if len(all_problems) == 0: out = "There are currently no problems" await discord_funcs.reply_to_message(message, out) return out = "Here are all of the problems: " await discord_funcs.reply_to_message(message, out) await problems_table.send_problems(message, all_problems) else: if not problems_table.problem_id_exists(args[0]): import error_messages return await error_messages.error_problem_does_not_exist( message, args[0]) problem = problems_table.get_problem_table_problem_by_id(args[0]) out = "Here is problem {}: ".format(args[0]) await discord_funcs.reply_to_message(message, out) await problems_table.send_problem(message, problem)
async def error_wrong_var_type(message, var_name, e): import config title = var_name body = str(e) + "\n" body += "\n" for var in config.ConfigVars: if var.value.var_name() == var_name: body += config.var_to_help_str(var.value, config.get_config_vars()) break await send_error(message, title, body)
def help_message(self): out = "Used to display and change variable values." out += " With no arguments, it will display all variables and their values." out += " With 1 argument, it will display just that variable's value." out += " With 2 arguments, it will set the variable to the new value." out += " All variables have default values.\n" out += "The possible variables that can be changed are: \n" config_vars = config.get_config_vars() for var in config.ConfigVars: out += "\n" out += config.var_to_help_str(var.value, config_vars) out += "." return out
def explain_inactive_str(): import config config_vars = config.get_config_vars() min_percent = config.get_var_val_from_vars( config.ConfigVars.percent.value.var_name(), config_vars) no_players = config.get_var_val_from_vars( config.ConfigVars.players.value.var_name(), config_vars) out = " A problem is inactive for everyone if {} or more players attempt".format( no_players) out += " (or forfeit a problem) and get above {}%.".format(min_percent) out += " A problem is inactive for a user if the user forfeits or attempts the problem" out += " and gets above {}%.".format(min_percent) out += " Inactive problems are hidden from standard lists to reduce clutter." return out
async def update_active_val(message, attempts, problem_id): # attempts include forfeit attempts config_vars = config.get_config_vars() no_players = config.get_var_val_from_vars(config.ConfigVars.players.value.var_name(), config_vars) min_percent = config.get_var_val_from_vars(config.ConfigVars.percent.value.var_name(), config_vars) active = is_problem_active(attempts, min_percent, no_players) problems = get_problem_table() prob_name = "" for p in problems: if p[constants.ProblemTableStruct.ID.value] == problem_id: p[constants.ProblemTableStruct.ACTIVE.value] = active prob_name = p[constants.ProblemTableStruct.NAME.value] break save_problem_table(problems) if not active: await display_problem_marked_inactive(message, problem_id, prob_name)
scalapack = False hdf5 = False # User provided customizations: execfile(customize) if platform_id != '': my_platform = distutils.util.get_platform() + '-' + platform_id def my_get_platform(): return my_platform distutils.util.get_platform = my_get_platform if compiler is not None: msg += ['* Compiling gpaw with %s' % compiler] # A hack to change the used compiler and linker: vars = get_config_vars() if remove_default_flags: for key in ['BASECFLAGS', 'CFLAGS', 'OPT', 'PY_CFLAGS', 'CCSHARED', 'CFLAGSFORSHARED', 'LINKFORSHARED', 'LIBS', 'SHLIBS']: if key in vars: value = vars[key].split() # remove all gcc flags (causing problems with other compilers) for v in list(value): value.remove(v) vars[key] = ' '.join(value) for key in ['CC', 'LDSHARED']: if key in vars: value = vars[key].split() # first argument is the compiler/linker. Replace with mpicompiler: value[0] = compiler
hdf5 = False # User provided customizations: execfile(customize) if platform_id != '': my_platform = distutils.util.get_platform() + '-' + platform_id def my_get_platform(): return my_platform distutils.util.get_platform = my_get_platform if compiler is not None: msg += ['* Compiling gpaw with %s' % compiler] # A hack to change the used compiler and linker: vars = get_config_vars() if remove_default_flags: for key in ['BASECFLAGS', 'CFLAGS', 'OPT', 'PY_CFLAGS', 'CCSHARED', 'CFLAGSFORSHARED', 'LINKFORSHARED', 'LIBS', 'SHLIBS']: if key in vars: value = vars[key].split() # remove all gcc flags (causing problems with other compilers) for v in list(value): value.remove(v) vars[key] = ' '.join(value) for key in ['CC', 'LDSHARED']: if key in vars: value = vars[key].split() # first argument is the compiler/linker. Replace with mpicompiler: value[0] = compiler