Changeset 14039 for trunk/ippScripts/scripts/ipp_serial_inject.pl
- Timestamp:
- Jul 5, 2007, 6:16:04 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/ipp_serial_inject.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/ipp_serial_inject.pl
r14021 r14039 3 3 # this program injects a list of single-file exposures into the db, 4 4 # taking the filename (without .fits) as the exp_tag. the user 5 # supplies a temporary telescope and instrumentname. these are used5 # supplies a temporary telescope and camera name. these are used 6 6 # for informational purposes only until the registration step can 7 # determine the true telescope and instrumentname from the image7 # determine the true telescope and camera name from the image 8 8 # headers. 9 9 … … 24 24 25 25 # Parse the command-line arguments 26 my ($workdir, $dbname, $telescope, $ instrument, $help);26 my ($workdir, $dbname, $telescope, $camera, $help); 27 27 GetOptions( 28 28 'workdir|w=s' => \$workdir, # working directory for output files 29 29 'dbname|d=s' => \$dbname, # Database name 30 30 'telescope|t=s' => \$telescope, # user-supplied telescope name 31 ' instrument|i=s' => \$instrument, # user-supplied instrumentname31 'camera|i=s' => \$camera, # user-supplied camera name 32 32 'help' => \$help # give help listing 33 33 ) or pod2usage( 2 ); 34 34 35 pod2usage( -msg => "inject one or many files into the IPP pipeline database", -exitval => 2 35 pod2usage( -msg => "inject one or many files into the IPP pipeline database", 36 -exitval => 2) if 37 defined $help; 36 38 37 pod2usage( -msg => "Usage: $0 --telescope (name) -- instrument(name) [--workdir path] [--dbname dbname] (files)",39 pod2usage( -msg => "Usage: $0 --telescope (name) --camera (name) [--workdir path] [--dbname dbname] (files)", 38 40 -exitval => 2 ) if 39 scalar @ARGV == 0;41 scalar @ARGV == 0; 40 42 41 pod2usage( -msg => "Required options: --telescope (name) -- instrument(name)",43 pod2usage( -msg => "Required options: --telescope (name) --camera (name)", 42 44 -exitval => 3) unless 43 defined $telescope and44 defined $instrument;45 defined $telescope and 46 defined $camera; 45 47 46 48 my $pxinject = can_run('pxinject') or die "Can't find pxinject\n"; … … 54 56 my $num = 0; 55 57 foreach my $file ( @ARGV ) { 58 # check for file existence 59 if (! -e $file) { die "file $file not found\n"; } 56 60 my $absfile = File::Spec->rel2abs( $file ); 57 inject($absfile, $workdir, $dbname, $telescope, $ instrument);61 inject($absfile, $workdir, $dbname, $telescope, $camera); 58 62 $num ++; 59 63 } … … 67 71 my $dbname = shift; # IPP database to use 68 72 my $telescope = shift; # user-specified telescope 69 my $ instrument = shift; # user-specified instrument73 my $camera = shift; # user-specified camera 70 74 71 75 my ( $vol, $path, $name ) = File::Spec->splitpath( $absfile ); … … 74 78 my $relfile = $ipprc->convert_filename_relative( $absfile ); 75 79 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; 80 87 81 88 my ( $success_exp, $error_code_exp, $full_buf_exp, $stdout_buf_exp, $stderr_buf_exp ) = … … 86 93 my $exp_id = $line[2]; # The exposure tag 87 94 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); 93 101 94 102 my ( $success_imfile, $error_code_imfile, $full_buf_imfile, $stdout_buf_imfile, $stderr_buf_imfile ) = run( command => $command_imfile, verbose => 1 ); 95 103 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; 96 113 97 114 return 1;
Note:
See TracChangeset
for help on using the changeset viewer.
