IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29703


Ignore:
Timestamp:
Nov 8, 2010, 2:25:02 PM (16 years ago)
Author:
rhenders
Message:

improvments to temp file handling

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czartool/Plotter.pm

    r29686 r29703  
    44use warnings;
    55use strict;
     6
     7use File::Temp;
    68
    79my @allStages = ("burntool", "chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
     
    128130    print GP ";\n";
    129131    close GP;
     132
     133    # now delete temp dat files
     134    foreach my $stage (keys %gnuplotFiles) {unlink($gnuplotFiles->{$stage});}
    130135}
    131136
     
    207212    my $outputFile = createImageFileName($self, $label, undef, "h", 0);
    208213
    209     my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table
    210         open (GNUDAT, ">$inputFile");
     214    my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_".$label."_h.XXXXX", DIR => '/tmp', SUFFIX => '.dat');
     215    open (GNUDAT, ">".$tmpFile->filename);
    211216
    212217    my ($processed, $pending, $faults);
     
    254259        "set ylabel \"Exposures\";" .
    255260        "set boxwidth 0.75;" .
    256         "plot '$inputFile' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" .
     261        "plot '".$tmpFile->filename."' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" .
    257262        "\n";
    258263
    259264    close GP;
    260     unlink($inputFile);
    261265}
    262266
     
    403407
    404408    # now delete temp dat files
    405     foreach my $stage (keys %$gnuplotFiles) {
    406 
    407         unlink($gnuplotFiles->{$stage});
    408     }
     409    foreach my $stage (keys %$gnuplotFiles) {unlink($gnuplotFiles->{$stage});}
    409410}
    410411
     
    463464        my $outputFile = "$prefix/czarplot_hosts_space.png";
    464465    my $limit = 97.0;
    465     my $inputFile = $self->{_czarDb}->createHostsData($limit);
     466    my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_hosts_space.XXXXX", DIR => '/tmp', SUFFIX => '.dat');
     467    $self->{_czarDb}->createHostsData($limit, $tmpFile);
    466468
    467469    my $totalUsed = $self->{_czarDb}->getTotalClusterStorageAsPercentage();
     
    482484        "set ylabel \"Space (TB)\";" .
    483485        "set xtic rotate by -90 scale 0;" .
    484         "plot '$inputFile' " .
     486        "plot '".$tmpFile->filename."' " .
    485487        "using 2:xtic(1) t \"Used\" lt 7," .
    486488        "'' using 3 t \"Over $limit% used\" lt 1," .
Note: See TracChangeset for help on using the changeset viewer.