IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 12:49:05 PM (16 years ago)
Author:
eugene
Message:

merging changes from trunk into branches/pap

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/ippScripts/scripts/lossy_compress_imfile.pl

    r27193 r28003  
    88use Sys::Hostname;
    99my $host = hostname();
     10my $date = `date`;
    1011print "\n\n";
    11 print "Starting script $0 on $host\n\n";
     12print "Starting script $0 on $host at $date\n\n";
    1213
    1314use vars qw( $VERSION );
     
    8687if ($state eq 'goto_compressed') {
    8788    # 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));
    9091    my $uriReal = $ipprc->file_resolve( $uri );
    9192
    9293    # Create a compressed version:
    9394    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));
    9697    my $compReal= $ipprc->file_resolve( $compUri, 'create');
    9798    # Apparently we need to funpack before fpacking.  Probably should have realized that beforehand.
    9899    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');
    102103    my $tempReal = $tempfile->filename;
    103104
    104105    my $uncompress_command = "$funpack -S $uriReal > $tempReal";
    105106    my ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
    106         run(command => $uncompress_command, verbose => $verbose);
     107        run(command => $uncompress_command, verbose => $verbose);
    107108    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);
    111112    }
    112113    my $compress_command = "$fpack -h -s 8 -S $tempReal >  $compReal";
    113114    print STDERR "$compReal $uriReal $compress_command\n";
    114115    ($success, $error_code, $full_buf, $stdout_buf, $stderr_buf) =
    115         run(command => $compress_command, verbose => $verbose);
     116        run(command => $compress_command, verbose => $verbose);
    116117    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);
    120121    }
    121122    my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state compressed";
     
    123124
    124125    &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));
    126127
    127128    if ($no_update || $no_op) {
    128         print STDERR "NOUPDATE: $database_command\n";
     129        print STDERR "NOUPDATE: $database_command\n";
    129130    }
    130131    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        }
    138139    }
    139140    exit(0);
     
    149150    # Confirm we have both files
    150151    &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));
    152153    my $uriReal = $ipprc->file_resolve( $uri );
    153    
     154
    154155    my $compUri = $uri . ".fz";
    155156    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#       }
    175176    }
    176177
     
    181182
    182183    unless ($no_op) {
    183         $neb->replicate($compUri);
    184         $neb->swap($uri,$compUri) or
    185             &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
    189190
    190191    my $database_command = "$regtool -updateprocessedimfile -exp_id $exp_id -class_id $class_id -set_state lossy ";
     
    192193
    193194    $database_command .= " -dbname $dbname" if defined $dbname;
    194    
     195
    195196    if ($no_update || $no_op) {
    196         print STDERR "NOUPDATE: $database_command\n";
     197        print STDERR "NOUPDATE: $database_command\n";
    197198    }
    198199    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) or
    204                 &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 version
     200        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
    210211    $neb->delete($compUri);
    211212    }
Note: See TracChangeset for help on using the changeset viewer.