How to use _print_control_list method in autotest

Best Python code snippet using autotest_python

cmdparser.py

Source:cmdparser.py Github

copy

Full Screen

...12 A client-side command wrapper for the autotest client.13 """14 COMMAND_LIST = ['help', 'list', 'run']15 @classmethod16 def _print_control_list(cls, pipe, path):17 """18 Print the list of control files available.19 @param pipe: Pipe opened to an output stream (may be a pager)20 @param path: Path we'll walk through21 """22 if not os.path.isdir(path):23 pipe.write("Test directory not available\n")24 return25 pipe.write(" %-50s %s\n" % ("[Control]", "[Description]"))26 # The strategy here is to walk the root directory27 # looking for "*control*" files in some directory28 # and printing them out29 for root, _, files in sorted(os.walk(path)):30 for name in files:31 if re.search("control", name):32 # strip full path33 basename = re.sub(path + "/", "", root)34 text = "%s/%s" % (basename, name)35 desc = "None"36 if name == "control":37 # Imply /control by listing only directory name38 text = "%s" % basename39 for line in open(root + "/" + name).readlines():40 if re.match("NAME", line):41 # We have a description line42 desc = re.split("=\s*", line,43 maxsplit=1)[1].rstrip()44 try:45 desc = desc[1:-1]46 except IndexError:47 pass48 break49 pipe.write(' %-50s %s\n' % (text, desc))50 @classmethod51 def help(cls):52 """53 List the commands and their usage strings.54 @param args is not used here.55 """56 print "Commands:"57 print "help\t\t\tOutput a list of supported commands"58 print "list\t\t\tOutput a list of available tests"59 print "run <test> [<args>]\tFind given <test> in path and run with args"60 raise SystemExit(0)61 @classmethod62 def list_tests(cls):63 """64 List the available tests for users to choose from65 """66 # One favorite feature from git :-)67 try:68 less_cmd = os_dep.command('less')69 pipe = os.popen('%s -FRSX' % less_cmd, 'w')70 except ValueError:71 pipe = sys.stdout72 pipe.write("List of tests available\n")73 pipe.write("Unless otherwise specified, outputs imply /control files\n")74 pipe.write("\n")75 # Walk local ./tests directory76 dirtest = os.path.join(os.path.abspath(os.path.curdir), LOCALDIRTEST)77 # Don't repeat autodirtest results78 if not dirtest == os.environ['AUTODIRTEST']:79 pipe.write("Local tests (%s)\n" % dirtest)80 cls._print_control_list(pipe, dirtest)81 pipe.write("\n")82 # Walk globaldirtests directory83 dirtest = GLOBALDIRTEST84 pipe.write("Globally imported tests (%s)\n" % dirtest)85 cls._print_control_list(pipe, dirtest)86 pipe.write("\n")87 # Walk autodirtest directory88 dirtest = os.environ['AUTODIRTEST']89 pipe.write("Autotest prepackaged tests (%s)\n" % dirtest)90 cls._print_control_list(pipe, dirtest)91 pipe.close()92 raise SystemExit(0)93 def parse_args(self, args):94 """95 Process a client side command.96 @param args: Command line args.97 """98 if len(args) and args[0] in self.COMMAND_LIST:99 cmd = args.pop(0)100 else:101 # Do things the traditional way102 return args103 # List is a python reserved word104 if cmd == 'list':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful