10 examples of 'subprocess call' in Python

Every line of 'subprocess call' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
33def check_call(*args, **kwargs):
34 logging.log(logging.INFO, "subprocess check_call: %s" % " ".join(*args))
35 if not 'preexec_fn' in kwargs:
36 kwargs['preexec_fn'] = child_preexec_set_pdeathsig
37 return subprocess.check_call(*args, **kwargs)
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

179def _check_call(proc):
180 """
181 :type proc: shell.RunCmd
182 :raises: CalledProcessError if returncode != 0
183 """
184 if proc.re() != 0:
185 raise CalledProcessError(
186 proc.re(), proc.cmd_str,
187 proc.stdout().decode('utf-8'), proc.stderr().decode('utf-8'))
188 return proc
37def call(*cmd):
38 """Log and run the command, raising on errors."""
39 print >>sys.stderr, 'Run:', cmd
40 return subprocess.call(cmd)
160def call(args):
161 print ' '.join(args)
162 pipe = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
163 output, error = pipe.communicate()
164 if output:
165 print output
166 if error:
167 print error
168 return pipe.returncode
39def call(args, **kwargs):
40 print u'EXCECUTING: ', u' '.join(args)
41 print u'---------------------------------------------'
42 result = subprocess.check_output(args, **kwargs)
43 print result
44 print u'---------------------------------------------'
45 return result
41def call(command):
42 res = subprocess.call(command, shell=False)
43 if res != 0:
44 sys.exit(-1)
208def check_call(args, **kwargs):
209 """Emulate subprocess.check_call()."""
210 check_call_out(args, **kwargs)
211 return 0
20@staticmethod
21def call(cmdline, cwd=None):
22 from subprocess import call
23 try:
24 return call(cmdline, cwd=cwd)
25 except OSError, e:
26 raise ExecError("error invoking '%s': %s"
27 % ( " ".join(cmdline), e))
57def run_command(command, env_variables=None):
58 return subprocess.Popen(command, env=env_variables,
59 stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
184def create_subprocess(cmd):
185 """
186 Create a new subprocess in the OS
187 :param cmd: command to execute in the subprocess
188 :return: the output and errors of the subprocess
189 """
190 process = subprocess.Popen(cmd,
191 stdin=subprocess.PIPE,
192 stdout=subprocess.PIPE,
193 stderr=subprocess.PIPE)
194 return process.communicate()

Related snippets