def external_program_check(<EOL>to_check=frozenset([PSQL_BIN, LZOP_BIN, PV_BIN])):
could_not_run = []<EOL>error_msgs = []<EOL>def psql_err_handler(popen):<EOL><INDENT>assert popen.returncode != <NUM_LIT:0><EOL>error_msgs.append(textwrap.fill(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'))<EOL>raise EnvironmentError('<STR_LIT>'<EOL>'<STR_LIT>')<EOL><DEDENT>with open(os.devnull, '<STR_LIT:wb>') as nullf:<EOL><INDENT>for program in to_check:<EOL><INDENT>try:<EOL><INDENT>if program is PSQL_BIN:<EOL><INDENT>psql_csv_run('<STR_LIT>', error_handler=psql_err_handler)<EOL><DEDENT>else:<EOL><INDENT>if program is PV_BIN:<EOL><INDENT>extra_args = ['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>extra_args = []<EOL><DEDENT>proc = popen_sp([program] + extra_args,<EOL>stdout=nullf, stderr=nullf,<EOL>stdin=subprocess.PIPE)<EOL>proc.stdin.close()<EOL>proc.wait()<EOL><DEDENT><DEDENT>except EnvironmentError:<EOL><INDENT>could_not_run.append(program)<EOL><DEDENT><DEDENT><DEDENT>if could_not_run:<EOL><INDENT>error_msgs.append(<EOL>'<STR_LIT>' +<EOL>'<STR_LIT:U+002CU+0020>'.join(could_not_run))<EOL><DEDENT>if error_msgs:<EOL><INDENT>raise UserException(<EOL>'<STR_LIT>',<EOL>'<STR_LIT:\n>'.join(error_msgs))<EOL><DEDENT>return None<EOL>
Validates the existence and basic working-ness of other programs

Implemented because it is easy to get confusing error output when
one does not install a dependency because of the fork-worker model
that is both necessary for throughput and makes more obscure the
cause of failures.  This is intended to be a time and frustration
saving measure.  This problem has confused The Author in practice
when switching rapidly between machines.