Changeset 25195
- Timestamp:
- Aug 25, 2009, 3:24:19 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_parser_run.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_parser_run.pl
r25058 r25195 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_die("--req_id --uri --product are required", $req_id, $PS_EXIT_CONFIG_ERROR) 42 50 if !defined($req_id) or 43 51 !defined($uri) or 44 52 !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 53 64 54 my $ipprc = PS::IPP::Config->new(); # IPP Configuration … … 80 70 my $datedir = "$pstamp_workdir/$datestr"; 81 71 if (! -e $datedir ) { 82 mkdir $datedir or die "failed to create working directory $datedir for request id $req_id"; 72 mkdir $datedir or my_die( "failed to create working directory $datedir for request id $req_id", $req_id, 73 $PS_EXIT_CONFIG_ERROR); 83 74 } 84 75 85 76 my $workdir = "$datedir/$req_id"; 86 77 if (! -e $workdir ) { 87 mkdir $workdir or die "failed to create working directory $workdir for request id $req_id"; 78 mkdir $workdir or my_die("failed to create working directory $workdir for request id $req_id", $req_id, 79 $PS_EXIT_CONFIG_ERROR); 88 80 } 89 81 … … 119 111 run(command => $command, verbose => $verbose); 120 112 unless ($success) { 121 die("Unable to perform $command error code: $error_code");113 my_die("Unable to perform $command error code: $error_code", $req_id, $error_code >> 8); 122 114 } 123 115 } elsif ($uri ne $new_uri) { 124 116 # put a link to the file into the workdir 125 117 if (-e $new_uri) { 126 unlink $new_uri or die "failed to unlink $new_uri";118 unlink $new_uri or my_die("failed to unlink $new_uri", $req_id, $PS_EXIT_UNKNOWN_ERROR); 127 119 } 128 120 if (! symlink $uri, $new_uri) { 129 die ("failed to link request file $uri to workdir $workdir");121 my_die ("failed to link request file $uri to workdir $workdir", $req_id, $PS_EXIT_UNKNOWN_ERROR); 130 122 } 131 123 } 132 124 $uri = $new_uri; 133 125 134 die "request file $uri not found"if ! -e $uri;126 my_die("request file $uri not found", $req_id, $PS_EXIT_UNKNOWN_ERROR) if ! -e $uri; 135 127 136 128 # if product was not defined (in database), use the default … … 263 255 } 264 256 } 257 258 sub my_die { 259 my $msg = shift; 260 my $req_id = shift; 261 my $fault = shift; 262 263 carp($msg); 264 265 my $command = "$pstamptool -updatereq -req_id $req_id -fault $fault"; 266 $command .= " -dbname $dbname" if $dbname; 267 $command .= " -dbserver $dbserver" if $dbserver; 268 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 269 run(command => $command, verbose => $verbose); 270 unless ($success) { 271 die("Unable to perform $command error code: $error_code"); 272 } 273 exit $fault; 274 }
Note:
See TracChangeset
for help on using the changeset viewer.
