IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 5, 2007, 6:16:04 PM (19 years ago)
Author:
eugene
Message:

updates to new regtool / pxinject apis

File:
1 edited

Legend:

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

    r14021 r14039  
    33# this program injects a list of single-file exposures into the db,
    44# taking the filename (without .fits) as the exp_tag.  the user
    5 # supplies a temporary telescope and instrument name.  these are used
     5# supplies a temporary telescope and camera name.  these are used
    66# for informational purposes only until the registration step can
    7 # determine the true telescope and instrument name from the image
     7# determine the true telescope and camera name from the image
    88# headers.
    99
     
    2424
    2525# Parse the command-line arguments
    26 my ($workdir, $dbname, $telescope, $instrument, $help);
     26my ($workdir, $dbname, $telescope, $camera, $help);
    2727GetOptions(
    2828    'workdir|w=s'    => \$workdir, # working directory for output files
    2929    'dbname|d=s'     => \$dbname, # Database name
    3030    'telescope|t=s'  => \$telescope, # user-supplied telescope name
    31     'instrument|i=s' => \$instrument, # user-supplied instrument name
     31    'camera|i=s'     => \$camera, # user-supplied camera name
    3232    'help'           => \$help # give help listing
    3333) or pod2usage( 2 );
    3434
    35 pod2usage( -msg => "inject one or many files into the IPP pipeline database", -exitval => 2
     35pod2usage( -msg => "inject one or many files into the IPP pipeline database",
     36           -exitval => 2) if
     37    defined $help;
    3638
    37 pod2usage( -msg => "Usage: $0 --telescope (name) --instrument (name) [--workdir path] [--dbname dbname] (files)",
     39pod2usage( -msg => "Usage: $0 --telescope (name) --camera (name) [--workdir path] [--dbname dbname] (files)",
    3840           -exitval => 2 ) if
    39            scalar @ARGV == 0;
     41    scalar @ARGV == 0;
    4042
    41 pod2usage( -msg => "Required options: --telescope (name) --instrument (name)",
     43pod2usage( -msg => "Required options: --telescope (name) --camera (name)",
    4244           -exitval => 3) unless
    43            defined $telescope and
    44            defined $instrument;
     45    defined $telescope and
     46    defined $camera;
    4547
    4648my $pxinject = can_run('pxinject') or die "Can't find pxinject\n";
     
    5456my $num = 0;
    5557foreach my $file ( @ARGV ) {
     58    # check for file existence
     59    if (! -e $file) { die "file $file not found\n"; }
    5660    my $absfile = File::Spec->rel2abs( $file );
    57     inject($absfile, $workdir, $dbname, $telescope, $instrument);
     61    inject($absfile, $workdir, $dbname, $telescope, $camera);
    5862    $num ++;
    5963}
     
    6771    my $dbname = shift;         # IPP database to use
    6872    my $telescope = shift;      # user-specified telescope
    69     my $instrument = shift;     # user-specified instrument
     73    my $camera = shift; # user-specified camera
    7074
    7175    my ( $vol, $path, $name ) = File::Spec->splitpath( $absfile );
     
    7478    my $relfile = $ipprc->convert_filename_relative( $absfile );
    7579
    76     my $command_exp = "$pxinject -newExp -exp_name $exp_name -inst $instrument -telescope $telescope -imfiles 1 -workdir $workdir" ; # Command to run
    77     if ($dbname) {
    78         $command_exp = "$command_exp -dbname $dbname";
    79     }
     80    # the telescope, instrument, and exp_name used here are temporary : register replaces them with the true values
     81    my $command_exp = "$pxinject -newExp";
     82    $command_exp .= " -tmp_exp_name $exp_name";
     83    $command_exp .= " -tmp_inst $camera";
     84    $command_exp .= " -tmp_telescope $telescope";
     85    $command_exp .= " -workdir $workdir";
     86    $command_exp .= " -dbname $dbname" if defined $dbname;
    8087
    8188    my ( $success_exp, $error_code_exp, $full_buf_exp, $stdout_buf_exp, $stderr_buf_exp ) =
     
    8693    my $exp_id = $line[2];      # The exposure tag
    8794   
    88     # XXX the class_id used here should be temporary : register should replace it with the true class_id
    89     my $command_imfile = "$pxinject -newImfile -exp_id $exp_id -exp_name $exp_name -class fpa -class_id fpa -uri $relfile"; # Command to run
    90     if ($dbname) {
    91         $command_imfile = "$command_imfile -dbname $dbname";
    92     }
     95    # the class_id used here is temporary : register replaces it with the true class_id
     96    my $command_imfile = "$pxinject -newImfile";
     97    $command_imfile .= " -exp_id $exp_id";
     98    $command_imfile .= " -tmp_class_id fpa";
     99    $command_imfile .= " -uri $relfile";
     100    $command_imfile .= " -dbname $dbname" if defined ($dbname);
    93101   
    94102    my ( $success_imfile, $error_code_imfile, $full_buf_imfile, $stdout_buf_imfile, $stderr_buf_imfile ) = run( command => $command_imfile, verbose => 1 );
    95103    die "Unable to inject $exp_name imfile: $error_code_imfile\n" if not $success_imfile;
     104
     105    # the class_id used here is temporary : register replaces it with the true class_id
     106    my $command_update = "$pxinject -updatenewExp";
     107    $command_update .= " -exp_id $exp_id";
     108    $command_update .= " -state run";
     109    $command_update .= " -dbname $dbname" if defined ($dbname);
     110   
     111    my ( $success_update, $error_code_update, $full_buf_update, $stdout_buf_update, $stderr_buf_update ) = run( command => $command_update, verbose => 1 );
     112    die "Unable to update $exp_name: $error_code_update\n" if not $success_update;
    96113
    97114    return 1;
Note: See TracChangeset for help on using the changeset viewer.