def main(): parser = OptionParser() parser.add_option('-a', '--all', action='store_true', dest='run_all', default=False) parser.add_option('-d', '--data', default=None, dest='data') parser.add_option('-n', '--nobuild', action='store_false', dest='build', default=True) parser.add_option('-c', '--conf', default=None, dest='conf_path') (options, args) = parser.parse_args() if len(args) == 0 or args[0] == 'help': print ('usage: python srmtrainer.py [options] <operation> <args>') print ('\navailable operations:') print ('\tinit <search_term>:\t\tcreate a solution directory for an SRM so you can start working on it') print ('\ttest <folder_name> [problem_name]:\t\tbuild the solution of an SRM and run all example tests') print ('options:') print ('\t--all, -a\t\trun all tests, not just the examples') print ('\t--data, -d\t\tspecify custom data to use') print ('\t--nobuild, -n\t\tbypass building') print ('\t--conf, -c\t\tspecify custom configuration path') return 0 elif args[0] == 'init' or args[0] == 'test': if len(args) <= 1: print ('ERROR: SRM search term is missing. Run "python srmtrainer.py help" to see program usage.') return 1 else: print ('ERROR: unknown option "%s"' % args[0]) return 1 if not options.conf_path: options.conf_path = Configuration.DEFAULT_CONF_PATH global conf try: conf = load_conf(options.conf_path) except: print ('ERROR: Unable to load/initialize configuration from \'%s\'.' % options.conf_path) raise return 1 try: if not conf.app_data_exists(): conf.init_app_data() except: print ('ERROR: Couldn\'t initialize configuration data.') raise return 1 srmsearchterm = args[1] if args[0] == 'init': return init_srm_solution(srmsearchterm) elif args[0] == 'test': return test_srm_solution( srmsearchterm, \ problem = args[2] if len(args) > 2 else None, \ run_all = options.run_all, \ data = options.data, \ build = options.build)
def __init__(self, win): self.win = win # TODO: need to change members to private where appropriate (through whole of srmtrainer) self.action_group = None self.tools_menu_items = None self._srms = None self._console = None self._randomtemp = None self._arena_controller = None self._arena_login = None # TODO: Need to redo error handling. Right now the plugin will just fail to load self.conf = load_conf() if not self.conf.app_data_exists(): self.conf.init_app_data()