How to use exec_on_interpreter method in tox

Best Python code snippet using tox_python

interpreters.py

Source:interpreters.py Github

copy

Full Screen

...38 if not info.executable:39 return ""40 envdir = str(envdir)41 try:42 res = exec_on_interpreter(info.executable,43 [inspect.getsource(sitepackagesdir),44 "print (sitepackagesdir(%r))" % envdir])45 except ExecFailed:46 val = sys.exc_info()[1]47 print ("execution failed: %s -- %s" %(val.out, val.err))48 return ""49 else:50 return res["dir"]51def run_and_get_interpreter_info(name, executable):52 assert executable53 try:54 result = exec_on_interpreter(executable,55 [inspect.getsource(pyinfo), "print (pyinfo())"])56 except ExecFailed:57 val = sys.exc_info()[1]58 return NoInterpreterInfo(name, executable=val.executable,59 out=val.out, err=val.err)60 else:61 return InterpreterInfo(name, executable, **result)62def exec_on_interpreter(executable, source):63 if isinstance(source, list):64 source = "\n".join(source)65 from subprocess import Popen, PIPE66 args = [str(executable)]67 popen = Popen(args, stdin=PIPE, stdout=PIPE, stderr=PIPE)68 popen.stdin.write(source.encode("utf8"))69 out, err = popen.communicate()70 if popen.returncode:71 raise ExecFailed(executable, source, out, err)72 try:73 result = eval(out.strip())74 except Exception:75 raise ExecFailed(executable, source, out,76 "could not decode %r" % out)...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

...37 if not info.executable:38 return ""39 envdir = str(envdir)40 try:41 res = exec_on_interpreter(str(info.executable), SITE_PACKAGE_QUERY_SCRIPT, str(envdir))42 except ExecFailed as e:43 reporter.verbosity1("execution failed: {} -- {}".format(e.out, e.err))44 return ""45 else:46 return res["dir"]47def run_and_get_interpreter_info(name, executable):48 assert executable49 try:50 result = exec_on_interpreter(str(executable), VERSION_QUERY_SCRIPT)51 result["version_info"] = tuple(result["version_info"]) # fix json dump transformation52 del result["name"]53 del result["version"]54 result["executable"] = str(executable)55 except ExecFailed as e:56 return NoInterpreterInfo(name, executable=e.executable, out=e.out, err=e.err)57 else:58 return InterpreterInfo(name, **result)59def exec_on_interpreter(*args):60 from subprocess import Popen, PIPE61 popen = Popen(args, stdout=PIPE, stderr=PIPE, universal_newlines=True)62 out, err = popen.communicate()63 if popen.returncode:64 raise ExecFailed(args[0], args[1:], out, err)65 if err:66 sys.stderr.write(err)67 try:68 result = json.loads(out)69 except Exception:70 raise ExecFailed(args[0], args[1:], out, "could not decode {!r}".format(out))71 return result72class ExecFailed(Exception):73 def __init__(self, executable, source, out, err):...

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 tox 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