Changeset 27169
- Timestamp:
- Mar 3, 2010, 4:17:02 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/lossy_compress_imfile.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/lossy_compress_imfile.pl
r27164 r27169 21 21 use PS::IPP::Config 1.01 qw( :standard ); 22 22 use PS::IPP::Metadata::Config; 23 use File::Temp qw( tempfile ); 23 24 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 24 25 use Pod::Usage qw( pod2usage ); … … 28 29 my $regtool = can_run( 'regtool' ) or (warn "Can't find regtool" and $missing_tools = 1); 29 30 my $fpack = can_run( 'fpack' ) or (warn "Can't find fpack" and $missing_tools = 1); 30 my ($exp_id, $class_id, $exp_name, $uri, $bytes, $md5sum, $dbname, $state, $verbose, $no_update, $no_op, $logfile); 31 my $funpack = can_run( 'funpack' ) or (warn "Can't find funpack" and $missing_tools = 1); 32 my ($exp_id, $class_id, $exp_name, $uri, $bytes, $md5sum, $dbname, $state); 33 my ($verbose, $no_update, $no_op, $logfile, $save_temps); 31 34 my ($camera); 32 35 GetOptions( … … 44 47 'no-op' => \$no_op, 45 48 'logfile=s' => \$logfile, 49 'save-temps' => \$save_temps, 46 50 ) or pod2usage ( 2 ); 47 51 … … 91 95 if ($ipprc->file_exists($compUri)); 92 96 my $compReal= $ipprc->file_resolve( $compUri, 'create'); 93 my $compress_command = "$fpack -h -s 8 -S $uriReal > $compReal"; 97 # Apparently we need to funpack before fpacking. Probably should have realized that beforehand. 98 my $tempfile = new File::Temp ( TEMPLATE => "${exp_name}.XXXX", 99 DIR => '/tmp/', 100 UNLINK => !$save_temps, 101 SUFFIX => '.fits'); 102 my $tempReal = $tempfile->filename; 103 104 my $uncompress_command = "$funpack -S $uriReal > $tempReal"; 105 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 106 run(command => $uncompress_command, verbose => $verbose); 107 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); 111 } 112 my $compress_command = "$fpack -h -s 8 -S $tempReal > $compReal"; 94 113 print STDERR "$compReal $uriReal $compress_command\n"; 95 my($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =114 ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 96 115 run(command => $compress_command, verbose => $verbose); 97 116 unless ($success) { 98 117 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 99 &my_die("Unable to compress file: $uri -> $compUri: $error_code", $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 118 &my_die("Unable to compress file: $uri -> $compUri: $error_code", 119 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 100 120 } 101 121 my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state compressed"; … … 135 155 136 156 # If that die is removed, this will compress things as well. 137 &my_die("Output compressed file already exists: $compUri\n", 138 $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 139 if ($ipprc->file_exists($compUri)); 140 my $compReal= $ipprc->file_resolve( $compUri, 'create'); 141 my $compress_command = "$fpack -h -s 8 -S $uriReal > $compReal"; 142 print STDERR "$compReal $uriReal $compress_command\n"; 143 my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 144 run(command => $compress_command, verbose => $verbose); 145 unless ($success) { 146 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 147 &my_die("Unable to compress file: $uri -> $compUri: $error_code", 148 $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 149 } 157 # 158 # &my_die("Output compressed file already exists: $compUri\n", 159 # $exp_id,$exp_name,$class_id,$uri,$PS_EXIT_SYS_ERROR) 160 # if ($ipprc->file_exists($compUri)); 161 # my $compReal= $ipprc->file_resolve( $compUri, 'create'); 162 163 # my $compress_command = "$fpack -h -s 8 -S $uriReal > $compReal"; 164 # print STDERR "$compReal $uriReal $compress_command\n"; 165 # my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) = 166 # run(command => $compress_command, verbose => $verbose); 167 # unless ($success) { 168 # $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 169 # &my_die("Unable to compress file: $uri -> $compUri: $error_code", 170 # $exp_id,$exp_name,$class_id,$uri, $PS_EXIT_SYS_ERROR); 171 # } 150 172 } 151 173
Note:
See TracChangeset
for help on using the changeset viewer.
