How to use _execute_child method in robotframework-androidlibrary

Best Python code snippet using robotframework-androidlibrary_python

__init__.py

Source:__init__.py Github

copy

Full Screen

1#2# Copyright 2012 Red Hat, Inc.3#4# This program is free software; you can redistribute it and/or modify5# it under the terms of the GNU General Public License as published by6# the Free Software Foundation; either version 2 of the License, or7# (at your option) any later version.8#9# This program is distributed in the hope that it will be useful,10# but WITHOUT ANY WARRANTY; without even the implied warranty of11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12# GNU General Public License for more details.13#14# You should have received a copy of the GNU General Public License15# along with this program; if not, write to the Free Software16# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA17#18# Refer to the README and COPYING files for full details of the license19#20"""21Python's implementation of Popen forks back to python before execing.22Forking a python proc is a very complex and volatile process.23This is a simpler method of execing that doesn't go back to python after24forking. This allows for faster safer exec.25"""26import inspect27import os28import sys29from subprocess import Popen, PIPE30from cpopen import createProcess31SUPPORTS_RESTORE_SIGPIPE = (32 'restore_sigpipe' in inspect.getargspec(Popen.__init__).args33)34class CPopen(Popen):35 def __init__(self, args, close_fds=False, cwd=None, env=None,36 deathSignal=0, childUmask=None,37 stdin=PIPE, stdout=PIPE, stderr=PIPE,38 restore_sigpipe=False):39 if not isinstance(args, list):40 args = list(args)41 self._childUmask = childUmask42 self._deathSignal = int(deathSignal)43 if SUPPORTS_RESTORE_SIGPIPE:44 kw = {'restore_sigpipe': restore_sigpipe}45 else:46 kw = {}47 Popen.__init__(self, args,48 close_fds=close_fds, cwd=cwd, env=env,49 stdin=stdin, stdout=stdout,50 stderr=stderr,51 **kw)52 def _execute_child_v276(53 self, args, executable, preexec_fn, close_fds,54 cwd, env, universal_newlines,55 startupinfo, creationflags, shell, to_close,56 p2cread, p2cwrite,57 c2pread, c2pwrite,58 errread, errwrite,59 restore_sigpipe=False60 ):61 return self._execute_child_v275(62 args, executable, preexec_fn,63 close_fds, cwd, env, universal_newlines,64 startupinfo, creationflags, shell,65 p2cread, p2cwrite,66 c2pread, c2pwrite,67 errread, errwrite,68 restore_sigpipe=restore_sigpipe,69 _to_close=to_close70 )71 def _execute_child_v275(72 self, args, executable, preexec_fn, close_fds,73 cwd, env, universal_newlines,74 startupinfo, creationflags, shell,75 p2cread, p2cwrite,76 c2pread, c2pwrite,77 errread, errwrite,78 restore_sigpipe=False,79 _to_close=None80 ):81 if env is not None and not isinstance(env, list):82 env = list(("=".join(item) for item in env.iteritems()))83 if _to_close is None:84 _to_close = self._fds_to_close(p2cread, p2cwrite,85 c2pread, c2pwrite,86 errread, errwrite)87 def close_fd(fd):88 _to_close.remove(fd)89 os.close(fd)90 try:91 pid, stdin, stdout, stderr = createProcess(92 args, close_fds,93 p2cread or -1, p2cwrite or -1,94 c2pread or -1, c2pwrite or -1,95 errread or -1, errwrite or -1,96 cwd, env,97 self._deathSignal,98 self._childUmask,99 restore_sigpipe100 )101 self.pid = pid102 except:103 # Keep the original exception and reraise it after all fds are104 # closed, ignoring error during close. This is needed only for105 # Python 2.6, as Python 2.7 already does this when _execute_child106 # raises.107 t, v, tb = sys.exc_info()108 for fd in list(_to_close):109 try:110 close_fd(fd)111 except OSError:112 pass113 raise t, v, tb114 # If child was started, close the unused fds on the parent side. Note115 # that we don't want to hide exceptions here.116 for fd in (p2cread, c2pwrite, errwrite):117 if fd in _to_close:118 close_fd(fd)119 def _fds_to_close(self, p2cread, p2cwrite,120 c2pread, c2pwrite,121 errread, errwrite):122 """123 Return a set of fds owned by us and may be closed for version of Python124 that do not provide the to_close argument in _execute_child.125 When calling Popen with PIPE, we create new pipe, and both sides of the126 pipe may be closed.127 When calling Popen with existing file descriptor or file like object,128 one side of the pipe will be None, and we may not close the other129 side, since it belongs to the caller.130 """131 to_close = set()132 for fdpair in ((p2cread, p2cwrite),133 (c2pread, c2pwrite),134 (errread, errwrite)):135 if None not in fdpair:136 to_close.update(fdpair)137 return to_close138 if 'to_close' in inspect.getargspec(Popen._execute_child).args:139 _execute_child = _execute_child_v276140 else:...

Full Screen

Full Screen

win_subprocess.py

Source:win_subprocess.py Github

copy

Full Screen

...87 pi.dwProcessId, pi.dwThreadId)88 raise WinError()89class Popen(subprocess.Popen):90 """This superseeds Popen and corrects a bug in cPython 2.7 implem"""91 def _execute_child(self, args, executable, preexec_fn, close_fds,92 cwd, env, universal_newlines,93 startupinfo, creationflags, shell, to_close,94 p2cread, p2cwrite,95 c2pread, c2pwrite,96 errread, errwrite):97 """Code from part of _execute_child from Python 2.7 (9fbb65e)98 There are only 2 little changes concerning the construction of99 the the final string in shell mode: we preempt the creation of100 the command string when shell is True, because original function101 will try to encode unicode args which we want to avoid to be able to102 sending it as-is to ``CreateProcess``.103 """104 if not isinstance(args, subprocess.types.StringTypes):105 args = subprocess.list2cmdline(args)106 if startupinfo is None:107 startupinfo = subprocess.STARTUPINFO()108 if shell:109 startupinfo.dwFlags |= _subprocess.STARTF_USESHOWWINDOW110 startupinfo.wShowWindow = _subprocess.SW_HIDE111 comspec = os.environ.get("COMSPEC", unicode("cmd.exe"))112 args = unicode('{} /c "{}"').format(comspec, args)113 if (_subprocess.GetVersion() >= 0x80000000 or114 os.path.basename(comspec).lower() == "command.com"):115 w9xpopen = self._find_w9xpopen()116 args = unicode('"%s" %s') % (w9xpopen, args)117 creationflags |= _subprocess.CREATE_NEW_CONSOLE118 super(Popen, self)._execute_child(args, executable,119 preexec_fn, close_fds, cwd, env, universal_newlines,120 startupinfo, creationflags, False, to_close, p2cread,121 p2cwrite, c2pread, c2pwrite, errread, errwrite)...

Full Screen

Full Screen

README.py

Source:README.py Github

copy

Full Screen

...4Image.open('twitterkey.png')5print(pytesseract.image_to_string(Image.open('twitterkey.png')))6'''Error7 File "c:\users\hknmz\appdata\local\programs\python\python38\lib\subprocess.py", line 854, in __init__8 self._execute_child(args, executable, preexec_fn, close_fds,9 File "c:\users\hknmz\appdata\local\programs\python\python38\lib\subprocess.py", line 1307, in _execute_child10 hp, ht, pid, tid = _winapi.CreateProcess(executable, args,11PermissionError: [WinError 5] Erişim engellendi...

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 robotframework-androidlibrary 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