How to use usageExit method in autotest

Best Python code snippet using autotest_python

package_unittest.py

Source:package_unittest.py Github

copy

Full Screen

...25 -v, --verbose Verbose output26 -q, --quiet Minimal output27 -d, --debug Debug mode28"""29def usageExit(msg=None):30 """Print usage and exit."""31 if msg:32 print msg33 print USAGE34 sys.exit(2)35def parseArgs(argv=sys.argv):36 """Parse command line arguments and set TestFramework state.37 State is to be acquired by test_* modules by a grotty hack:38 ``from TestFramework import *``. For this stylistic39 transgression, I expect to be first up against the wall40 when the revolution comes. --Garth"""41 global verbosity, debug42 try:43 options, args = getopt.getopt(argv[1:], 'hHvqd',44 ['help', 'verbose', 'quiet', 'debug'])45 for opt, value in options:46 if opt in ('-h', '-H', '--help'):47 usageExit()48 if opt in ('-q', '--quiet'):49 verbosity = 050 if opt in ('-v', '--verbose'):51 verbosity = 252 if opt in ('-d', '--debug'):53 debug =154 if len(args) != 0:55 usageExit("No command-line arguments supported yet.")56 except getopt.error, msg:57 usageExit(msg)58def loadTestModules(path, name='', packages=None):59 """60 Return a test suite composed of all the tests from modules in a directory.61 Search for modules in directory `path`, beginning with `name`. If62 `packages` is true, search subdirectories (also beginning with `name`)63 recursively. Subdirectories must be Python packages; they must contain an64 '__init__.py' module.65 """66 testLoader = unittest.defaultTestLoader67 testSuite = unittest.TestSuite()68 testModules = []69 path = os.path.abspath(path) # current working dir if `path` empty70 paths = [path]71 while paths:...

Full Screen

Full Screen

check_parser.py

Source:check_parser.py Github

copy

Full Screen

1#!/usr/bin/env python2import os3import subprocess4import sys5sys.path.append(os.path.abspath(sys.argv[0]))6def UsageExit(message=''):7 """Missing DocString8 :param message:9 :return:10 """11 if message != '':12 print('Error: %s' % message)13 print('Usage: %s [parser type] [frames number] [command line]' %14 os.path.basename(sys.argv[0]))15 exit(1)16if len(sys.argv) < 4:17 UsageExit()18try:19 framesNum = int(sys.argv[2])20except: # TODO: Too broad exception clause21 UsageExit('%s\nInvalid frames number.' % str(sys.exc_info()[1]))22parserType = sys.argv[1]23parserModule = __import__('parsers', globals(), locals(), [parserType])24cmd = 'parserModule.%s.%s()' % (parserType, parserType)25print(cmd)26parser = eval(cmd)27taskInfo = dict()28taskInfo['frames_num'] = framesNum29taskInfo['wdir'] = os.getcwd()30parser.setTaskInfo(taskInfo)31arguments = []32for i in range(3, len(sys.argv)):33 arguments.append(sys.argv[i])34process = subprocess.Popen(arguments, shell=False, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)35#process = subprocess.Popen(' '.join(arguments), shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)36process.stdin.close()37stdout = process.stdout38stderr = process.stderr39#stdout = process.stderr40#stderr = process.stdout41def printMuted( i_str):42 sys.stdout.write('\033[1;30m')43 sys.stdout.write( i_str)44 sys.stdout.write('\033[0m')45 sys.stdout.flush()46while True:47 stdout.flush()48 data = stdout.readline()49 if data is None: break50 if len(data) < 1: break51 printMuted( data)52 parser.parse( data,'mode')53 info = 'Parse:'54 info += ' %d%%: %d frame %d%%;' % (parser.percent, parser.frame, parser.percentframe)55 if len( parser.activity):56 info += ' Activity: %s;' % parser.activity57 if len( parser.report):58 info += ' Report: %s;' % parser.report59 sys.stdout.write('%s\n' % info)60 sys.stdout.flush()61info = ''62if len( parser.files):63 info += '\nFiles:'64 for afile in parser.files:65 info += '\n' + afile66sys.stdout.write('%s\n' % info)67sys.stdout.flush()...

Full Screen

Full Screen

__main__.py

Source:__main__.py Github

copy

Full Screen

1# Author: Lisandro Dalcin2# Contact: dalcinl@gmail.com3"""Run Python code using ``mpi4py.futures``.4Python code (scripts, modules, zip files) is run in the process with rank 0 in5``MPI.COMM_WORLD`` and creates `MPIPoolExecutor` instances to submit tasks. The6other processes team-up in a static-size shared pool of workers executing tasks7submitted from the master process.8"""9from __future__ import print_function10def main():11 """Entry point for ``python -m mpi4py.futures ...``."""12 # pylint: disable=missing-docstring13 import os14 import sys15 from ..run import run_command_line16 from ..run import set_abort_status17 from ._lib import SharedPoolCtx18 class UsageExit(SystemExit):19 pass20 def usage(error=None):21 from textwrap import dedent22 usage = dedent("""23 usage: python{0} -m {prog} <pyfile> [arg] ...24 or: python{0} -m {prog} -m <module> [arg] ...25 or: python{0} -m {prog} -c <string> [arg] ...26 """).strip().format(sys.version[0], prog=__package__)27 if error:28 print(error, file=sys.stderr)29 print(usage, file=sys.stderr)30 raise UsageExit(1)31 else:32 print(usage, file=sys.stdout)33 raise UsageExit(0)34 def chk_command_line():35 args = sys.argv[1:]36 if len(args) < 1:37 usage("No path specified for execution")38 elif args[0] == '-':39 pass40 elif args[0] in ('-h', '--help'):41 usage()42 elif args[0] in ('-m', '-c'):43 if len(args) < 2:44 usage("Argument expected for option: " + args[0])45 elif args[0].startswith('-'):46 usage("Unknown option: " + args[0])47 elif not os.path.exists(args[0]):48 usage("Path does not exist: " + args[0])49 try:50 with SharedPoolCtx() as context:51 if context is not None:52 chk_command_line()53 run_command_line()54 except UsageExit:55 raise56 except SystemExit as exc:57 set_abort_status(exc.code)58 raise59 except:60 set_abort_status(1)61 raise62if __name__ == '__main__':...

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