IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 22427


Ignore:
Timestamp:
Feb 24, 2009, 10:58:24 AM (17 years ago)
Author:
Paul Price
Message:

We're using multiple versions of 'run' in this script: IPC::Cmd and
IPC::Run (the former is convenient, the latter works for pipes; we're
also using system). Need to disambiguate them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/register_imfile.pl

    r22421 r22427  
    1717use Storable qw(freeze thaw);
    1818use File::Basename qw( basename);
    19 use IPC::Run qw( harness run );
     19use IPC::Run;
     20use IPC::Cmd 0.36 qw( can_run );
    2021use PS::IPP::Config 1.01 qw( :standard );
    2122use PS::IPP::Metadata::Config;
     
    3031# Look for programs we need
    3132my $missing_tools;
    32 my $regtool = `which regtool` or (warn "Can't find regtool" and $missing_tools = 1);
    33 my $ppStats = `which ppStats` or (warn "Can't find ppStats" and $missing_tools = 1);
    34 my $ppStatsFromMetadata = `which ppStatsFromMetadata` or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    35 chomp $regtool;
    36 chomp $ppStats;
    37 chomp $ppStatsFromMetadata;
     33my $regtool = can_run( 'regtool' ) or (warn "Can't find regtool" and $missing_tools = 1);
     34my $ppStats = can_run( 'ppStats' ) or (warn "Can't find ppStats" and $missing_tools = 1);
     35my $ppStatsFromMetadata = can_run( 'ppStatsFromMetadata' ) or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    3836
    3937my ($cache, $exp_id, $tmp_class_id, $tmp_exp_name, $uri, $dbname, $verbose, $no_update, $no_op, $logfile);
     
    9593    # Run ppStats
    9694    my ($in1, $out1, $err1);    # Buffers for ppStats
    97     my $h1 = harness \@command1, \$in1, \$out1, \$err1;
     95    my $h1 = IPC::Run::harness \@command1, \$in1, \$out1, \$err1;
    9896    print "[Running $command1]\n";
    99     my $result1 = run $h1;
    100     print $out1;
    101     print $err1;
     97    my $result1 = IPC::Run::run $h1;
     98    print "STDOUT:\n$out1";
     99    print "STDERR:\n$err1";
    102100    &my_die("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h1->result() ) unless $result1;
    103101
    104102    print "[Running " . join(' ', @command2) . "]\n";
    105103    my ($out2, $err2);          # Buffers for ppStatsFromMetadata
    106     my $h2 = harness \@command2, \$out1, \$out2, \$err2;
     104    my $h2 = IPC::Run::harness \@command2, \$out1, \$out2, \$err2;
    107105    print "[Running $command2]\n";
    108     my $result2 = run $h2;
    109     print $out2;
    110     print $err2;
     106    my $result2 = IPC::Run::run $h2;
     107    print "STDOUT:\n$out2";
     108    print "STDERR:\n$err2";
    111109    &my_die("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $h2->result() ) unless $result2;
    112110    chomp $out2;
     
    168166# Push the results into the database
    169167unless ($no_update) {
     168    my ($in1, $out1, $err1);    # Buffers for ppStats
     169    my $h1 = harness \@command1, \$in1, \$out1, \$err1;
     170    print "[Running $command1]\n";
     171    my $result1 = run $h1;
     172
    170173    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    171         run(command => $command, verbose => $verbose);
     174        IPC::Cmd::run(command => $command, verbose => $verbose);
    172175    unless ($success) {
    173176        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     
    190193        return @{thaw $cmd_output};
    191194    } else {
    192         my @output = run(%p);
     195        my @output = IPC::Cmd::run(%p);
    193196        $c->set($p{command}, freeze \@output) if $cache;
    194197        return @output;
Note: See TracChangeset for help on using the changeset viewer.