- Timestamp:
- May 3, 2010, 8:50:52 AM (16 years ago)
- Location:
- branches/simtest_nebulous_branches
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
pstamp/scripts/pstamp_parser_run.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/simtest_nebulous_branches
- Property svn:mergeinfo changed
-
branches/simtest_nebulous_branches/pstamp/scripts/pstamp_parser_run.pl
r25058 r27840 13 13 use Getopt::Long qw( GetOptions ); 14 14 use File::Basename qw( basename dirname); 15 use File::Copy; 15 16 use POSIX qw( strftime ); 17 use Carp; 18 use IPC::Cmd 0.36 qw( can_run run ); 19 20 use PS::IPP::Metadata::Config; 21 use PS::IPP::Metadata::Stats; 22 use PS::IPP::Metadata::List qw( parse_md_list ); 23 24 use PS::IPP::Config qw( :standard ); 16 25 17 26 my $req_id; … … 19 28 my $redirect_output; 20 29 my $product; 30 my $label; 21 31 my $verbose; 22 32 my $dbname; … … 27 37 'uri=s' => \$uri, 28 38 'product=s' => \$product, 39 'label=s' => \$label, 29 40 'redirect-output' => \$redirect_output, 30 41 'verbose' => \$verbose, … … 39 50 } 40 51 41 die "--req_id --uri --product are required" 52 my $missing_tools; 53 54 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 55 my $pstampparse = can_run('pstampparse.pl') or (warn "Can't find pstampparse.pl" and $missing_tools = 1); 56 my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1); 57 my $dsget = can_run('dsget') or (warn "Can't find dsget" and $missing_tools = 1); 58 59 if ($missing_tools) { 60 warn("Can't find required tools."); 61 exit ($PS_EXIT_CONFIG_ERROR); 62 } 63 64 65 my_die("--req_id --uri --product are required", $req_id, $PS_EXIT_CONFIG_ERROR) 42 66 if !defined($req_id) or 43 67 !defined($uri) or 44 68 !defined($product); 45 46 use IPC::Cmd 0.36 qw( can_run run );47 48 use PS::IPP::Metadata::Config;49 use PS::IPP::Metadata::Stats;50 use PS::IPP::Metadata::List qw( parse_md_list );51 52 use PS::IPP::Config qw($PS_EXIT_SUCCESS53 $PS_EXIT_UNKNOWN_ERROR54 $PS_EXIT_SYS_ERROR55 $PS_EXIT_CONFIG_ERROR56 $PS_EXIT_PROG_ERROR57 $PS_EXIT_DATA_ERROR58 $PS_EXIT_TIMEOUT_ERROR59 metadataLookupStr60 metadataLookupBool61 caturi62 );63 69 64 70 my $ipprc = PS::IPP::Config->new(); # IPP Configuration … … 80 86 my $datedir = "$pstamp_workdir/$datestr"; 81 87 if (! -e $datedir ) { 82 mkdir $datedir or die "failed to create working directory $datedir for request id $req_id"; 88 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 89 $PS_EXIT_CONFIG_ERROR); 83 90 } 84 91 85 92 my $workdir = "$datedir/$req_id"; 86 93 if (! -e $workdir ) { 87 mkdir $workdir or die "failed to create working directory $workdir for request id $req_id"; 94 mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id, 95 $PS_EXIT_CONFIG_ERROR); 88 96 } 89 97 … … 96 104 exit ($PS_EXIT_CONFIG_ERROR) unless defined $defaultDSProduct; 97 105 98 my $missing_tools;99 100 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1);101 my $pstampparse = can_run('pstampparse.pl') or (warn "Can't find pstampparse.pl" and $missing_tools = 1);102 my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1);103 my $dsget = can_run('dsget') or (warn "Can't find dsget" and $missing_tools = 1);104 105 if ($missing_tools) {106 warn("Can't find required tools.");107 exit ($PS_EXIT_CONFIG_ERROR);108 }109 110 106 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 111 107 … … 119 115 run(command => $command, verbose => $verbose); 120 116 unless ($success) { 121 die("Unable to perform $command error code: $error_code");117 my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8); 122 118 } 123 119 } elsif ($uri ne $new_uri) { 124 120 # put a link to the file into the workdir 125 121 if (-e $new_uri) { 126 unlink $new_uri or die "failed to unlink $new_uri";127 } 128 if (! symlink$uri, $new_uri) {129 die ("failed to link request file $uri to workdir $workdir");122 unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR); 123 } 124 if (! copy $uri, $new_uri) { 125 my_die ("failed to copy request file $uri to workdir $workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR); 130 126 } 131 127 } 132 128 $uri = $new_uri; 133 129 134 die "request file $uri not found"if ! -e $uri;130 my_die("request file $uri not found", $req_id, $PS_EXIT_UNKNOWN_ERROR) if ! -e $uri; 135 131 136 132 # if product was not defined (in database), use the default … … 152 148 if ($request_type eq "PS1_PS_REQUEST") { 153 149 $reqType = 'pstamp'; 154 $parse_cmd = $pstampparse; 150 $parse_cmd = "$pstampparse"; 151 $parse_cmd .= " --label $label" if $label; 155 152 } elsif ($request_type eq "MOPS_DETECTABILITY_QUERY") { 156 153 $reqType = 'dquery'; … … 263 260 } 264 261 } 262 263 sub my_die { 264 my $msg = shift; 265 my $req_id = shift; 266 my $fault = shift; 267 268 carp($msg); 269 270 my $command = "$pstamptool -updatereq -req_id $req_id -fault $fault"; 271 $command .= " -dbname $dbname" if $dbname; 272 $command .= " -dbserver $dbserver" if $dbserver; 273 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 274 run(command => $command, verbose => $verbose); 275 unless ($success) { 276 die("Unable to perform $command error code: $error_code"); 277 } 278 exit $fault; 279 }
Note:
See TracChangeset
for help on using the changeset viewer.
