def _snapshotted_process(input_conversion, output_conversion, snapshot_directory, binary, *args):
 process_request = input_conversion(*args)
 with temporary_dir(cleanup=False) as sandbox_dir:
  if process_request.snapshots:
   for snapshot in process_request.snapshots:
    _extract_snapshot(snapshot_directory.root, snapshot, sandbox_dir)
  if process_request.directories_to_create:
   for d in process_request.directories_to_create:
    safe_mkdir(os.path.join(sandbox_dir, d))
  popen = _run_command(binary, sandbox_dir, process_request)
  process_result = SnapshottedProcessResult(popen.stdout.read(), popen.stderr.read(), popen.returncode)
  if (process_result.exit_code != 0):
   raise Exception(u'Running {} failed with non-zero exit code: {}'.format(binary, process_result.exit_code))
  return output_conversion(process_result, sandbox_dir)

def _snapshotted_process ( input_conversion , output_conversion , snapshot_directory , binary , * args ) : process_request = input_conversion ( * args ) with temporary_dir ( cleanup = False ) as sandbox_dir : if process_request . snapshots : for snapshot in process_request . snapshots : _extract_snapshot ( snapshot_directory . root , snapshot , sandbox_dir ) if process_request . directories_to_create : for d in process_request . directories_to_create : safe_mkdir ( os . path . join ( sandbox_dir , d ) ) popen = _run_command ( binary , sandbox_dir , process_request ) process_result = SnapshottedProcessResult ( popen . stdout . read ( ) , popen . stderr . read ( ) , popen . returncode ) if ( process_result . exit_code != 0 ) : raise Exception ( u'Running {} failed with non-zero exit code: {}' . format ( binary , process_result . exit_code ) ) return output_conversion ( process_result , sandbox_dir )
a pickleable top-level function to execute a process .