def make_cmd_fn(cmd): """ Dynamically define a twill shell command function based on an imported function name. (This is where the twill.commands functions actually get executed.) """ def do_cmd(rest_of_line, cmd=cmd): global_dict, local_dict = namespaces.get_twill_glocals() args = [] if rest_of_line.strip() != "": try: args = parse.arguments.parseString(rest_of_line)[0] args = parse.process_args(args, global_dict,local_dict) except Exception, e: logger.error('INPUT ERROR: %s\n', str(e)) return try: parse.execute_command(cmd, args, global_dict, local_dict, "<shell>") except SystemExit: raise except Exception, e: logger.error(str(e))
def make_cmd_fn(cmd): """ Dynamically define a twill shell command function based on an imported function name. (This is where the twill.commands functions actually get executed.) """ def do_cmd(rest_of_line, cmd=cmd): global_dict, local_dict = namespaces.get_twill_glocals() args = [] if rest_of_line.strip() != "": try: args = parse.arguments.parseString(rest_of_line)[0] args = parse.process_args(args, global_dict,local_dict) except Exception, e: print '\nINPUT ERROR: %s\n' % (str(e),) return try: parse.execute_command(cmd, args, global_dict, local_dict, "<shell>") except SystemExit: raise except Exception, e: print '\nERROR: %s\n' % (str(e),)
def do_cmd(rest_of_line, cmd=cmd): global_dict, local_dict = namespaces.get_twill_glocals() args = [] if rest_of_line.strip() != "": try: args = parse.arguments.parseString(rest_of_line)[0] args = parse.process_args(args, global_dict,local_dict) except Exception as e: print('\n INPUT ERROR: {} \n'.format(e)) return try: parse.execute_command(cmd, args, global_dict, local_dict, "<shell>") except SystemExit: raise except Exception as e: print('\nERROR: %s\n' % (str(e),))
def do_cmd(rest_of_line, cmd=cmd): global_dict, local_dict = namespaces.get_twill_glocals() args = [] if rest_of_line.strip() != "": try: args = parse.arguments.parseString(rest_of_line)[0] args = parse.process_args(args, global_dict, local_dict) except Exception as e: print('\nINPUT ERROR: %s\n' % (str(e), )) return try: parse.execute_command(cmd, args, global_dict, local_dict, "<shell>") except SystemExit: raise except Exception as e: print('\nERROR: %s\n' % (str(e), ))
def default(self, line): "Called when unknown command is executed." # empty lines ==> emptyline(); here we just want to remove # leading whitespace. line = line.strip() # look for command global_dict, local_dict = namespaces.get_twill_glocals() cmd, args = parse.parse_command(line, global_dict, local_dict) # ignore comments & empty stuff if cmd is None: return try: parse.execute_command(cmd, args, global_dict, local_dict, "<shell>") except SystemExit: raise except Exception, e: logger.error('%s\n' % (str(e),)) if self.fail_on_unknown: raise
def default(self, line): "Called when unknown command is executed." # empty lines ==> emptyline(); here we just want to remove # leading whitespace. line = line.strip() # look for command global_dict, local_dict = namespaces.get_twill_glocals() cmd, args = parse.parse_command(line, global_dict, local_dict) # ignore comments & empty stuff if cmd is None: return try: parse.execute_command(cmd, args, global_dict, local_dict, "<shell>") except SystemExit: raise except Exception, e: print '\nERROR: %s\n' % (str(e),) if self.fail_on_unknown: raise