
from subprocess import call


def call_and_check_errors():
	call_args = ('wc', '-l', 'my_file')

	call_args_str = ' '.join(call_args)
	print(call_args_str)

	result = call(call_args)

	if 0 != result:
		print('Error during call.')


if '__main__' == __name__:
	call_and_check_errors()


from subprocess import CalledProcessError, call, check_output
import sys


def call_and_check_errors():
	call_args = ('touch', sys.argv[0])

	call_args_str = ' '.join(call_args)
	print(call_args_str)

	result = call(call_args)

	if 0 != result:
		print('Error during call.')


def call_and_get_output():
	call_args = ('wc', '-l', sys.argv[0])

	call_args_str = ' '.join(call_args)
	print(call_args_str)

	try:
		stdout = check_output(call_args)
		print(stdout)
	except CalledProcessError:
		print('Error during call.')


if '__main__' == __name__:
	call_and_get_output()

Add call subprocess and print output
Add call subprocess and print output

  
- from subprocess import call
+ from subprocess import CalledProcessError, call, check_output
+ import sys
  
  
  def call_and_check_errors():
- 	call_args = ('wc', '-l', 'my_file')
+ 	call_args = ('touch', sys.argv[0])
  
  	call_args_str = ' '.join(call_args)
  	print(call_args_str)
  
  	result = call(call_args)
  
  	if 0 != result:
  		print('Error during call.')
  
  
+ def call_and_get_output():
+ 	call_args = ('wc', '-l', sys.argv[0])
+ 
+ 	call_args_str = ' '.join(call_args)
+ 	print(call_args_str)
+ 
+ 	try:
+ 		stdout = check_output(call_args)
+ 		print(stdout)
+ 	except CalledProcessError:
+ 		print('Error during call.')
+ 
+ 
  if '__main__' == __name__:
- 	call_and_check_errors()
+ 	call_and_get_output()
  
Add call subprocess and print output
## Code Before:

from subprocess import call


def call_and_check_errors():
	call_args = ('wc', '-l', 'my_file')

	call_args_str = ' '.join(call_args)
	print(call_args_str)

	result = call(call_args)

	if 0 != result:
		print('Error during call.')


if '__main__' == __name__:
	call_and_check_errors()

## Instruction:
Add call subprocess and print output
## Code After:

from subprocess import CalledProcessError, call, check_output
import sys


def call_and_check_errors():
	call_args = ('touch', sys.argv[0])

	call_args_str = ' '.join(call_args)
	print(call_args_str)

	result = call(call_args)

	if 0 != result:
		print('Error during call.')


def call_and_get_output():
	call_args = ('wc', '-l', sys.argv[0])

	call_args_str = ' '.join(call_args)
	print(call_args_str)

	try:
		stdout = check_output(call_args)
		print(stdout)
	except CalledProcessError:
		print('Error during call.')


if '__main__' == __name__:
	call_and_get_output()
