Changeset 24102
- Timestamp:
- May 7, 2009, 11:19:33 AM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/receive_file.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/receive_file.pl
r24038 r24102 36 36 37 37 # Parse the command-line arguments 38 my ( $file_id, $source, $product, $fileset, $fileset_id, $file, $ workdir, $dbname, $verbose, $no_update, $save_temps );38 my ( $file_id, $source, $product, $fileset, $fileset_id, $file, $component, $bytes, $md5sum, $workdir, $dbname, $verbose, $no_update, $save_temps ); 39 39 40 40 GetOptions( … … 45 45 'fileset_id=s' => \$fileset_id, # database id for the fileset 46 46 'file=s' => \$file, # File to retrieve 47 'component=s' => \$component, # component for this file (class_id, skycell_id or dbinfo) 48 'bytes=i' => \$bytes, # file size in bytes 49 'md5sum=s' => \$md5sum, # md5sum for file from data store 47 50 'workdir=s' => \$workdir, # Working directory for output 48 51 'dbname=s' => \$dbname, # Database name … … 60 63 defined $fileset and 61 64 defined $file and 65 defined $component and 66 defined $bytes and 67 defined $md5sum and 62 68 defined $workdir; 63 69 … … 72 78 my $uri = "$source/$product/$fileset/$file"; # URI for datastore file 73 79 my $command = "dsget --uri $uri --filename $filename"; # Command to execute 80 $command .= " --timeout 590"; 81 $command .= " --bytes $bytes --md5 $md5sum"; 74 82 75 83 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 76 84 run(command => $command, verbose => $verbose); 77 die "Unable to retrieve file from $uri\n"unless $success;85 &my_die( "Unable to retrieve file from $uri\n", $file_id, $PS_EXIT_DATA_ERROR) unless $success; 78 86 } 79 87 my $mjd_copy = DateTime->now->mjd; # MJD of finishing copy … … 87 95 my $fixFile; 88 96 89 open $fixFile, ">$fixName" or die "can't open $fixName\n";97 open $fixFile, ">$fixName" or &my_die( "can't open $fixName\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); 90 98 91 99 # Need to fix paths to point to new workdir 92 open my $inFile, $filename or die "Can't open $filename\n"; # Input file100 open my $inFile, $filename or &my_die( "Can't open $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); # Input file 93 101 my $workdir_old; # Old workdir 94 102 while (<$inFile>) { … … 112 120 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 113 121 run(command => $command, verbose => $verbose); 114 die "Unable to set dbinfo_uri for $fileset_id to $fixName\n"unless $success;122 &my_die( "Unable to set dbinfo_uri for $fileset_id to $fixName\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success; 115 123 #} 116 124 … … 122 130 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 123 131 run(command => $command, verbose => $verbose); 124 die "Unable to get listing of tar file $filename\n"unless $success;132 &my_die( "Unable to get listing of tar file $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success; 125 133 126 134 my @lines = split(/\n/, join "", @$stdout_buf); # Lines from output … … 140 148 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 141 149 run(command => $command, verbose => $verbose); 142 die "Unable to extract tar file $filename\n"unless $success;150 &my_die( "Unable to extract tar file $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR) unless $success; 143 151 } 144 152 … … 148 156 my $target = "$workdir/$file"; # Target destination for file 149 157 my $to = $ipprc->file_create( $target ); # Target for move 150 system("mv $from $to") == 0 or die "Unable to move $file into workdir $workdir: $!\n";158 system("mv $from $to") == 0 or &my_die( "Unable to move $file into workdir $workdir: $!\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); 151 159 } 152 160 } else { 153 die "Unrecognised file: $file\n";154 } 155 156 unlink $filename or die "Unable to unlink $filename\n";161 &my_die( "Unrecognised file: $file\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); 162 } 163 164 unlink $filename or &my_die( "Unable to unlink $filename\n", $file_id, $PS_EXIT_UNKNOWN_ERROR); 157 165 my $mjd_extract = DateTime->now->mjd; # MJD of finishing extract 158 166
Note:
See TracChangeset
for help on using the changeset viewer.
