old_contents: import logging
  import subprocess
  
  import click
  
  from ..models import Scene
  from ..ingest import io
  from ..utils.exception_reporting import wrap_rollbar
  
  logger = logging.getLogger(__name__)
  
  
  @click.command(name='ingest-scene')
  @click.argument('scene_id')
  @wrap_rollbar
  def ingest_scene(scene_id):
      """Ingest a scene into Raster Foundry
  
      Args:
          scene_id (str): ID of scene to ingest
      """
      ingest(scene_id)
  
  
  def ingest(scene_id):
      """Separated into another function because the Click annotation messes with calling it from other tasks"""
      logger.info("Converting scene to COG: %s", scene_id)
      scene = Scene.from_id(scene_id)
      if scene.ingestStatus != 'INGESTED':
          scene.ingestStatus = 'INGESTING'
          scene.update()
      image_locations = [(x.sourceUri, x.filename) for x in sorted(
          scene.images, key=lambda x: io.sort_key(scene.datasource, x.bands[0]))]
      io.create_cog(image_locations, scene)
      logger.info('Cog created, writing histogram to attribute store')
      metadata_to_postgres(scene.id)
      logger.info('Histogram added to attribute store, notifying interested parties')
      notify_for_scene_ingest_status(scene.id)
  
  
  def metadata_to_postgres(scene_id):
      """Save histogram for the generated COG in the database
  
      Args:
          scene_id (str): ID of scene to save metadata for
      """
  
      bash_cmd = [
          'java', '-cp', '/opt/raster-foundry/jars/batch-assembly.jar',
          'com.rasterfoundry.batch.Main', 'cog-histogram-backfill',
          scene_id
      ]
  
      logger.debug('Bash command to store histogram: %s', ' '.join(bash_cmd))
      running_cmd = subprocess.Popen(bash_cmd)
      running_cmd.communicate()
      logger.info('Successfully completed metadata postgres write for scene %s',
                  scene_id)
      return True
  
  
  def notify_for_scene_ingest_status(scene_id):
      """Notify users that are using this scene as well as the scene owner that
      the ingest status of this scene has changed
  
      Args:
          scene_id (Scene): the scene which has an updated status
      """
  
      bash_cmd = [
          'java', '-cp', '/opt/raster-foundry/jars/batch-assembly.jar',
          'com.rasterfoundry.batch.Main', 'notify_ingest_status', scene_id
      ]
      running_process = subprocess.Popen(bash_cmd)
      running_process.communicate()
      return True
  
new_contents: import logging
  import subprocess
  
  import click
  
  from ..models import Scene
  from ..ingest import io
  from ..utils.exception_reporting import wrap_rollbar
  
  logger = logging.getLogger(__name__)
  
  
  @click.command(name='ingest-scene')
  @click.argument('scene_id')
  @wrap_rollbar
  def ingest_scene(scene_id):
      """Ingest a scene into Raster Foundry
  
      Args:
          scene_id (str): ID of scene to ingest
      """
      ingest(scene_id)
  
  
  def ingest(scene_id):
      """Separated into another function because the Click annotation messes with calling it from other tasks"""
      logger.info("Converting scene to COG: %s", scene_id)
      scene = Scene.from_id(scene_id)
      if scene.ingestStatus != 'INGESTED':
          scene.ingestStatus = 'INGESTING'
          scene.update()
      image_locations = [(x.sourceUri, x.filename) for x in sorted(
          scene.images, key=lambda x: io.sort_key(scene.datasource, x.bands[0]))]
      io.create_cog(image_locations, scene)
      logger.info('Cog created, writing histogram to attribute store')
      metadata_to_postgres(scene.id)
      logger.info('Histogram added to attribute store, notifying interested parties')
      notify_for_scene_ingest_status(scene.id)
  
  
  def metadata_to_postgres(scene_id):
      """Save histogram for the generated COG in the database
  
      Args:
          scene_id (str): ID of scene to save metadata for
      """
  
      bash_cmd = [
          'java', '-cp', '/opt/raster-foundry/jars/batch-assembly.jar',
          'com.rasterfoundry.batch.Main', 'cog-histogram-backfill',
          scene_id
      ]
  
      logger.debug('Bash command to store histogram: %s', ' '.join(bash_cmd))
      running_process = subprocess.check_call(bash_cmd, stdout=subprocess.PIPE)
      while running_process.poll() is None:
          logger.info(running_process.stdout.readline())
      logger.info(running_process.stdout.read())
      logger.info('Successfully completed metadata postgres write for scene %s',
                  scene_id)
      return True
  
  
  def notify_for_scene_ingest_status(scene_id):
      """Notify users that are using this scene as well as the scene owner that
      the ingest status of this scene has changed
  
      Args:
          scene_id (Scene): the scene which has an updated status
      """
  
      bash_cmd = [
          'java', '-cp', '/opt/raster-foundry/jars/batch-assembly.jar',
          'com.rasterfoundry.batch.Main', 'notify_ingest_status', scene_id
      ]
      try:
          running_process = subprocess.check_call(bash_cmd, stdout=subprocess.PIPE)
          while running_process.poll() is None:
              logger.info(running_process.stdout.readline())
          logger.info(running_process.stdout.read())
      except subprocess.CalledProcessError as e:
          logger.error('Error notifying users about ingest status:\n', e.output)
  
      return True
  
subject: Use subprocess.check_call instead of Popen (#5050)