IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30396


Ignore:
Timestamp:
Jan 27, 2011, 3:56:26 PM (15 years ago)
Author:
rhenders
Message:

Added function to retrieve the current dates for a provided server; improved how current lables are obtained

File:
1 edited

Legend:

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

    r30370 r30396  
    123123        # sometimes a label can be on the same line as the panstasks prompt
    124124        if ($line =~ m/pantasks: (.*)/) {
    125             if (length($1) > 0) {push(@labels, $1);}
    126             $passedHeader=1; next;
    127         }
    128         if ($passedHeader) {push(@labels, $line);}
     125            $line = $1;
     126            $passedHeader=1;
     127        }
     128
     129        if ($passedHeader && length($line) > 0){push(@labels, $line);}
    129130    }
    130131
     
    196197    }
    197198}
     199
     200###########################################################################
     201#
     202# Gets current dates for this server
     203#
     204###########################################################################
     205sub getDates {
     206    my ($self, $server) = @_;
     207
     208    my @dates;
     209
     210    my $prefix;
     211
     212    if ($server eq "stdscience") {$prefix = "ns";}
     213    elsif ($server eq "registration") {$prefix = "register";}
     214
     215    my @cmdOut = `echo "$prefix.show.dates;quit" | pantasks_client -c ~ipp/$server/ptolemy.rc 2>&1`;
     216    my $line;
     217    my $passedHeader=0;
     218    foreach $line (@cmdOut) {
     219
     220        chomp($line);
     221        if (!$self->outputOk($line)) {return \@dates;}
     222
     223        # sometimes content is on same line as pantasks prompt
     224        if ($line =~ m/pantasks: (.*)/) {
     225            $line =~ s/pantasks: //;
     226                $passedHeader=1;
     227        }
     228
     229        if ($passedHeader && length($line) > 0){
     230
     231            # strip out only the date part
     232            if ($line =~ m/([0-9]{4}-[0-9]{2}-[0-9]{2}).*/) {
     233
     234                push(@dates, $1);
     235            }
     236        }
     237    }
     238
     239    return \@dates;
     240}
     241
     242
    1982431;
Note: See TracChangeset for help on using the changeset viewer.