IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 17, 2010, 10:05:43 AM (15 years ago)
Author:
eugene
Message:

merge from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/ippScripts/scripts/receive_file.pl

    r29574 r30102  
    3232my $receivetool = can_run('receivetool') or (warn "Can't find receivetool" and $missing_tools = 1);
    3333my $dsproductls = can_run('dsfilesetls') or (warn "Can't find dsfilesetls" and $missing_tools = 1);
     34my $gunzip = can_run('gunzip') or (warn "Can't find gunzip" and $missing_tools = 1);
    3435if ($missing_tools) {
    3536    warn("Can't find required tools.");
     
    404405    my $workdir = shift;
    405406
     407    my $filecmd_output = `file $src`;
     408    &my_die("failed to determinte file type of $src", $file_id, $PS_EXIT_UNKNOWN_ERROR) if !$filecmd_output;
     409    chomp $filecmd_output;
     410
     411    my $tmpName;
     412    if ($filecmd_output =~ /gzip/) {
     413        my $tmpfile;
     414        ($tmpfile, $tmpName) = tempfile( "/tmp/receive.XXXX", UNLINK => !$save_temps );
     415        close($tmpfile) or &my_die("failed to close $tmpName", $file_id, $PS_EXIT_UNKNOWN_ERROR);
     416
     417        my $command = "$gunzip -c $src > $tmpName";
     418        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     419            run(command => $command, verbose => $verbose);
     420        unless ($success) {
     421            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     422            &my_die("Unable to perform $command: $error_code", $component, $error_code);
     423        }
     424        $src = $tmpName;
     425    }
     426
    406427    open my $IN,  "<$src" or &my_die("failed to open $src for input", $file_id, $PS_EXIT_UNKNOWN_ERROR);
    407428    open my $OUT, ">$dest" or &my_die("failed to open $dest for output", $file_id, $PS_EXIT_UNKNOWN_ERROR);
Note: See TracChangeset for help on using the changeset viewer.