Changeset 27718 for trunk/ippScripts/scripts/lossy_compress_imfile.pl
- Timestamp:
- Apr 21, 2010, 11:35:15 AM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/lossy_compress_imfile.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/lossy_compress_imfile.pl
r27193 r27718 8 8 use Sys::Hostname; 9 9 my $host = hostname(); 10 my $date = `date`; 10 11 print "\n\n"; 11 print "Starting script $0 on $host \n\n";12 print "Starting script $0 on $host at $date\n\n"; 12 13 13 14 use vars qw( $VERSION ); … … 86 87 if ($state eq 'goto_compressed') { 87 88 # Find the actual filename for this run: 88 &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 89 unless ($ipprc->file_exists($uri));89 &my_die("Couldn't find input file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 90 unless ($ipprc->file_exists($uri)); 90 91 my $uriReal = $ipprc->file_resolve( $uri ); 91 92 92 93 # Create a compressed version: 93 94 my $compUri = $uri . ".fz"; 94 &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 95 if ($ipprc->file_exists($compUri));95 &my_die("Output compressed file already exists: $compUri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 96 if ($ipprc->file_exists($compUri)); 96 97 my $compReal= $ipprc->file_resolve( $compUri, 'create'); 97 98 # Apparently we need to funpack before fpacking. Probably should have realized that beforehand. 98 99 my $tempfile = new File::Temp ( TEMPLATE => "${exp_name}.XXXX", 99 DIR => '/tmp/',100 UNLINK => !$save_temps,101 SUFFIX => '.fits');100 DIR => '/tmp/', 101 UNLINK => !$save_temps, 102 SUFFIX => '.fits'); 102 103 my $tempReal = $tempfile->filename; 103 104 104 105 my $uncompress_command = "$funpack -S $uriReal > $tempReal"; 105 106 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 106 run(command => $uncompress_command, verbose => $verbose);107 run(command => $uncompress_command, verbose => $verbose); 107 108 unless ($success) { 108 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);109 &my_die("Unable to uncompress file: $uri -> $compUri: $error_code", 110 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);109 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 110 &my_die("Unable to uncompress file: $uri -> $compUri: $error_code", 111 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 111 112 } 112 113 my $compress_command = "$fpack -h -s 8 -S $tempReal > $compReal"; 113 114 print STDERR "$compReal $uriReal $compress_command\n"; 114 115 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 115 run(command => $compress_command, verbose => $verbose);116 run(command => $compress_command, verbose => $verbose); 116 117 unless ($success) { 117 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);118 &my_die("Unable to compress file: $uri -> $compUri: $error_code", 119 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);118 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 119 &my_die("Unable to compress file: $uri -> $compUri: $error_code", 120 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 120 121 } 121 122 my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state compressed"; … … 123 124 124 125 &my_die("Expected output compressed file not found: $compUri\n", $exp_id,$exp_name,$class_id, $uri,$PS_EXIT_SYS_ERROR) 125 unless ($ipprc->file_exists($compUri));126 unless ($ipprc->file_exists($compUri)); 126 127 127 128 if ($no_update || $no_op) { 128 print STDERR "NOUPDATE: $database_command\n";129 print STDERR "NOUPDATE: $database_command\n"; 129 130 } 130 131 else { 131 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =132 run(command => $database_command, verbose => $verbose);133 unless ($success) {134 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);135 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 136 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);137 }132 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 133 run(command => $database_command, verbose => $verbose); 134 unless ($success) { 135 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 136 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 137 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 138 } 138 139 } 139 140 exit(0); … … 149 150 # Confirm we have both files 150 151 &my_die("Couldn't find original file: $uri\n", $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 151 unless($ipprc->file_exists($uri));152 unless($ipprc->file_exists($uri)); 152 153 my $uriReal = $ipprc->file_resolve( $uri ); 153 154 154 155 my $compUri = $uri . ".fz"; 155 156 unless($ipprc->file_exists($compUri)) { 156 &my_die("Couldn't find compressed version of the file: $compUri\n", 157 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);158 159 # If that die is removed, this will compress things as well.160 # 161 # &my_die("Output compressed file already exists: $compUri\n",162 # $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR)163 # if ($ipprc->file_exists($compUri));164 # my $compReal= $ipprc->file_resolve( $compUri, 'create');165 166 # my $compress_command = "$fpack -h -s 8 -S $uriReal > $compReal";167 # print STDERR "$compReal $uriReal $compress_command\n";168 # my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =169 # run(command => $compress_command, verbose => $verbose);170 # unless ($success) {171 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);172 # &my_die("Unable to compress file: $uri -> $compUri: $error_code",173 # $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);174 # }157 &my_die("Couldn't find compressed version of the file: $compUri\n", 158 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR); 159 160 # If that die is removed, this will compress things as well. 161 # 162 # &my_die("Output compressed file already exists: $compUri\n", 163 # $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 164 # if ($ipprc->file_exists($compUri)); 165 # my $compReal= $ipprc->file_resolve( $compUri, 'create'); 166 167 # my $compress_command = "$fpack -h -s 8 -S $uriReal > $compReal"; 168 # print STDERR "$compReal $uriReal $compress_command\n"; 169 # my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 170 # run(command => $compress_command, verbose => $verbose); 171 # unless ($success) { 172 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 173 # &my_die("Unable to compress file: $uri -> $compUri: $error_code", 174 # $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 175 # } 175 176 } 176 177 … … 181 182 182 183 unless ($no_op) { 183 $neb->replicate($compUri);184 $neb->swap($uri,$compUri) or185 &my_die("Nebulous swap failed between $uri and $compUri", 186 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);187 } 188 # Update database 184 $neb->replicate($compUri); 185 $neb->swap($uri,$compUri) or 186 &my_die("Nebulous swap failed between $uri and $compUri", 187 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR); 188 } 189 # Update database 189 190 190 191 my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state lossy "; … … 192 193 193 194 $database_command .= " -dbname $dbname" if defined $dbname; 194 195 195 196 if ($no_update || $no_op) { 196 print STDERR "NOUPDATE: $database_command\n";197 print STDERR "NOUPDATE: $database_command\n"; 197 198 } 198 199 else { 199 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =200 run(command => $database_command, verbose => $verbose);201 unless($success) {202 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);203 $neb->swap($uri,$compUri) or204 &my_die("DB update failed and Nebulous swap-back failed between $uri and $compUri", 205 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR);206 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 207 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR);208 }209 # remove original version200 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 201 run(command => $database_command, verbose => $verbose); 202 unless($success) { 203 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 204 $neb->swap($uri,$compUri) or 205 &my_die("DB update failed and Nebulous swap-back failed between $uri and $compUri", 206 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR); 207 &my_die("Unable to update database file: $uri -> $compUri: $error_code", 208 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 209 } 210 # remove original version 210 211 $neb->delete($compUri); 211 212 }
Note:
See TracChangeset
for help on using the changeset viewer.
