import subprocess
import os

out_path = os.path.join(_tempdir, out_filename)

convert_command = (
    'vips',
    'tiffsave',
    '"%s"' % in_path,
    '"%s"' % out_path,
    '--compression', 'jpeg',
    '--Q', '90',
    '--tile',
    '--tile-width', '256',
    '--tile-height', '256',
    '--pyramid',
    '--bigtiff'
)

proc = subprocess.Popen(convert_command)
proc.wait()

if proc.returncode:
    raise Exception('VIPS process failed (rc=%d).' % proc.returncode)

import subprocess
import os

out_path = os.path.join(_tempdir, out_filename)

convert_command = (
    'vips',
    'tiffsave',
    '"%s"' % in_path,
    '"%s"' % out_path,
    '--compression', 'jpeg',
    '--Q', '90',
    '--tile',
    '--tile-width', '256',
    '--tile-height', '256',
    '--pyramid',
    '--bigtiff'
)

proc = subprocess.Popen(convert_command)
proc.wait()

if proc.returncode:
    raise Exception('VIPS command failed (rc=%d): %s' % (
        proc.returncode, ' '.join(convert_command)))

Print command in failure case
Print command in failure case

  import subprocess
  import os
  
  out_path = os.path.join(_tempdir, out_filename)
  
  convert_command = (
      'vips',
      'tiffsave',
      '"%s"' % in_path,
      '"%s"' % out_path,
      '--compression', 'jpeg',
      '--Q', '90',
      '--tile',
      '--tile-width', '256',
      '--tile-height', '256',
      '--pyramid',
      '--bigtiff'
  )
  
  proc = subprocess.Popen(convert_command)
  proc.wait()
  
  if proc.returncode:
-     raise Exception('VIPS process failed (rc=%d).' % proc.returncode)
+     raise Exception('VIPS command failed (rc=%d): %s' % (
+         proc.returncode, ' '.join(convert_command)))
  
Print command in failure case
## Code Before:
import subprocess
import os

out_path = os.path.join(_tempdir, out_filename)

convert_command = (
    'vips',
    'tiffsave',
    '"%s"' % in_path,
    '"%s"' % out_path,
    '--compression', 'jpeg',
    '--Q', '90',
    '--tile',
    '--tile-width', '256',
    '--tile-height', '256',
    '--pyramid',
    '--bigtiff'
)

proc = subprocess.Popen(convert_command)
proc.wait()

if proc.returncode:
    raise Exception('VIPS process failed (rc=%d).' % proc.returncode)

## Instruction:
Print command in failure case
## Code After:
import subprocess
import os

out_path = os.path.join(_tempdir, out_filename)

convert_command = (
    'vips',
    'tiffsave',
    '"%s"' % in_path,
    '"%s"' % out_path,
    '--compression', 'jpeg',
    '--Q', '90',
    '--tile',
    '--tile-width', '256',
    '--tile-height', '256',
    '--pyramid',
    '--bigtiff'
)

proc = subprocess.Popen(convert_command)
proc.wait()

if proc.returncode:
    raise Exception('VIPS command failed (rc=%d): %s' % (
        proc.returncode, ' '.join(convert_command)))
