IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28783


Ignore:
Timestamp:
Jul 29, 2010, 2:46:11 PM (16 years ago)
Author:
rhenders
Message:

Not using temp files anymore

Location:
trunk/tools/czartool
Files:
2 edited

Legend:

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

    r28770 r28783  
    55use warnings;
    66use strict;
    7 
    8 use File::Temp qw(tempfile);
    97
    108my @stages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist"); # TODO put elsewhere
     
    125123###########################################################################
    126124sub insertNewTimeData {
    127     my ($self, $table, $label, $pending, $processed, $faults, $reverting) = @_;
    128 
    129     my $query = $self->{_db}->prepare(<<SQL);
    130     INSERT INTO $table
     125    my ($self, $stage, $label, $pending, $processed, $faults, $reverting) = @_;
     126
     127    my $query = $self->{_db}->prepare(<<SQL);
     128    INSERT INTO $stage
    131129        (label, pending, processed, faults, reverting)
    132130        VALUES
     
    140138###########################################################################
    141139#
    142 # Gets timedifference in seconds for these two times
     140# Gets time difference in seconds for these two times
    143141#
    144142###########################################################################
     
    146144    my ($self, $fromTime, $toTime) = @_;
    147145
    148     my ($tempFile, $tempName) = tempfile( "/tmp/czartool_gnuplot_timeseries.XXXX", UNLINK => !$self->{_save_temps});
    149 
    150146    my $query = $self->{_db}->prepare(<<SQL);
    151147    SELECT
     
    164160###########################################################################
    165161sub createTimeSeriesData {
    166     my ($self, $label, $table, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_;
    167 
    168     my ($tempFile, $tempName) = tempfile( "/tmp/czartool_gnuplot_timeseries.XXXX", UNLINK => !$self->{_save_temps});
     162    my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_;
     163
     164    my $dataFile = "/tmp/czarplot_gnuplot_".$label."_".$stage."_t.dat"; # TODO use stage not table
     165    open (GNUDAT, ">$dataFile");
    169166
    170167    my $query = $self->{_db}->prepare(<<SQL);
     
    175172        DATE_FORMAT(MIN(timestamp),'$self->{_dateFormat}'),
    176173        TIME_TO_SEC(TIMEDIFF(max(timestamp ), min(timestamp)))
    177             FROM $table
     174            FROM $stage
    178175            WHERE label LIKE '$label'
    179176            AND timestamp >= '$fromTime' AND timestamp <= '$toTime';
     
    191188    SELECT
    192189        DATE_FORMAT(timestamp, '$self->{_dateFormat}'), pending, faults, processed-$minProcessed
    193         FROM $table
     190        FROM $stage
    194191        WHERE label LIKE '$label'
    195192        AND timestamp >= '$fromTime' AND timestamp <= '$toTime'
     
    204201        my ($timestamp, $pending, $faults, $processed) = @row;
    205202    #    print  "'$timestamp' '$pending' '$faults' '$processed'\n";
    206         print $tempFile "$timestamp $pending $faults $processed\n";
    207     }
    208     close($tempFile);
    209 
    210     return $tempName;
     203        print GNUDAT "$timestamp $pending $faults $processed\n";
     204    }
     205    close(GNUDAT);
     206
     207    return $dataFile;
    211208}
    212209
     
    217214###########################################################################
    218215sub countFaultsInPast {
    219     my ($self, $label, $table, $interval) = @_; # TODO use time not interval
     216    my ($self, $label, $stage, $interval) = @_; # TODO use time not interval
    220217
    221218    # get earliest time for this label
    222219    my $query = $self->{_db}->prepare(<<SQL);
    223220    SELECT GREATEST(MIN(timestamp), now() - INTERVAL $interval)
    224         FROM $table
     221        FROM $stage
    225222        WHERE label LIKE '$label';
    226223SQL
     
    231228    $query = $self->{_db}->prepare(<<SQL);
    232229    SELECT faults
    233         FROM $table
     230        FROM $stage
    234231        WHERE label LIKE '$label'
    235232        AND timestamp <= '$timestamp' LIMIT 1;
     
    246243###########################################################################
    247244sub countPendingNow {
    248     my ($self, $label, $table) = @_;
     245    my ($self, $label, $stage) = @_;
    249246
    250247    my $query = $self->{_db}->prepare(<<SQL);
    251248    SELECT pending - faults
    252         FROM $table
     249        FROM $stage
    253250        WHERE label LIKE '$label'
    254251        ORDER BY timestamp DESC LIMIT 1;
     
    265262###########################################################################
    266263sub countProcessedPendingAndFaults {
    267     my ($self, $label, $table, $fromTime, $toTime, $processed, $pending, $faults) = @_;
     264    my ($self, $label, $stage, $fromTime, $toTime, $processed, $pending, $faults) = @_;
    268265
    269266
     
    271268    SELECT
    272269        pending, faults
    273         FROM $table
     270        FROM $stage
    274271        WHERE label LIKE '$label'
    275272        AND timestamp >= '$fromTime' AND timestamp <= '$toTime'
     
    283280    SELECT
    284281        MAX(processed) - MIN(processed)
    285         FROM $table
     282        FROM $stage
    286283        WHERE label LIKE '$label'
    287284        AND timestamp >= '$fromTime' AND timestamp <= '$toTime';
     
    298295###########################################################################
    299296sub countProcessed { # TODO use time not interval
    300     my ($self, $label, $table, $interval) = @_;
     297    my ($self, $label, $stage, $interval) = @_;
    301298
    302299    my $query = $self->{_db}->prepare(<<SQL);
    303300    SELECT
    304301        MAX(processed) - MIN(processed)
    305         FROM $table
     302        FROM $stage
    306303        WHERE label LIKE '$label'
    307304        AND timestamp > (now() - INTERVAL $interval);
  • trunk/tools/czartool/Czarplot.pm

    r28776 r28783  
    44use warnings;
    55use strict;
    6 
    7 use File::Temp qw(tempfile);
    86
    97my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
     
    10098    my $outputFile = createImageFileName($self, $label, undef, "h");
    10199
    102     my ($tempFile, $inputFile) = tempfile( "/tmp/czartool_gnuplot_histogram.XXXX", UNLINK => !$self->{_save_temps});
     100    my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table
     101    open (GNUDAT, ">$inputFile");
     102
    103103    my ($processed, $pending, $faults);
    104104    my $stage = undef;
     
    106106
    107107        $self->{_czarDb}->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults);
    108         print $tempFile "$stage $processed, $pending, $faults\n";
    109     }
    110 
    111     close($tempFile);
     108        print GNUDAT "$stage $processed, $pending, $faults\n";
     109    }
     110
     111    close(GNUDAT);
    112112
    113113    plotHistogram($self, $inputFile, $outputFile, $label, $beginTime, $endTime);
Note: See TracChangeset for help on using the changeset viewer.