- Timestamp:
- Sep 15, 2009, 4:02:42 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20090715/pstamp/scripts/pstamp_parser_run.pl
r25022 r25406 14 14 use File::Basename qw( basename dirname); 15 15 use POSIX qw( strftime ); 16 use Carp; 17 use IPC::Cmd 0.36 qw( can_run run ); 18 19 use PS::IPP::Metadata::Config; 20 use PS::IPP::Metadata::Stats; 21 use PS::IPP::Metadata::List qw( parse_md_list ); 22 23 use PS::IPP::Config qw( :standard ); 16 24 17 25 my $req_id; … … 39 47 } 40 48 41 die "--req_id --uri --product are required" 49 my $missing_tools; 50 51 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 52 my $pstampparse = can_run('pstampparse.pl') or (warn "Can't find pstampparse.pl" and $missing_tools = 1); 53 my $dqueryparse = can_run('dqueryparse.pl') or (warn "Can't find dqueryparse.pl" and $missing_tools = 1); 54 my $dsget = can_run('dsget') or (warn "Can't find dsget" and $missing_tools = 1); 55 56 if ($missing_tools) { 57 warn("Can't find required tools."); 58 exit ($PS_EXIT_CONFIG_ERROR); 59 } 60 61 62 my_die("--req_id --uri --product are required", $req_id, $PS_EXIT_CONFIG_ERROR) 42 63 if !defined($req_id) or 43 64 !defined($uri) or 44 65 !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 66 64 67 my $ipprc = PS::IPP::Config->new(); # IPP Configuration … … 80 83 my $datedir = "$pstamp_workdir/$datestr"; 81 84 if (! -e $datedir ) { 82 mkdir $datedir or die "failed to create working directory $datedir for request id $req_id"; 85 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 86 $PS_EXIT_CONFIG_ERROR); 83 87 } 84 88 85 89 my $workdir = "$datedir/$req_id"; 86 90 if (! -e $workdir ) { 87 mkdir $workdir or die "failed to create working directory $workdir for request id $req_id"; 91 mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id, 92 $PS_EXIT_CONFIG_ERROR); 88 93 } 89 94 … … 96 101 exit ($PS_EXIT_CONFIG_ERROR) unless defined $defaultDSProduct; 97 102 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 103 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 111 104 … … 119 112 run(command => $command, verbose => $verbose); 120 113 unless ($success) { 121 die("Unable to perform $command error code: $error_code");114 my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8); 122 115 } 123 116 } elsif ($uri ne $new_uri) { 124 117 # put a link to the file into the workdir 125 118 if (-e $new_uri) { 126 unlink $new_uri or die "failed to unlink $new_uri";119 unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR); 127 120 } 128 121 if (! symlink $uri, $new_uri) { 129 die ("failed to link request file $uri to workdir $workdir");122 my_die ("failed to link request file $uri to workdir $workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR); 130 123 } 131 124 } 132 125 $uri = $new_uri; 133 126 134 die "request file $uri not found"if ! -e $uri;127 my_die("request file $uri not found", $req_id, $PS_EXIT_UNKNOWN_ERROR) if ! -e $uri; 135 128 136 129 # if product was not defined (in database), use the default … … 200 193 unlink $error_file_name if (-e $error_file_name); 201 194 195 # Run the parser 196 202 197 my $command = "$parse_cmd"; 203 198 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 261 256 } 262 257 } 258 259 sub my_die { 260 my $msg = shift; 261 my $req_id = shift; 262 my $fault = shift; 263 264 carp($msg); 265 266 my $command = "$pstamptool -updatereq -req_id $req_id -fault $fault"; 267 $command .= " -dbname $dbname" if $dbname; 268 $command .= " -dbserver $dbserver" if $dbserver; 269 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 270 run(command => $command, verbose => $verbose); 271 unless ($success) { 272 die("Unable to perform $command error code: $error_code"); 273 } 274 exit $fault; 275 }
Note:
See TracChangeset
for help on using the changeset viewer.
