IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 4, 2010, 6:07:38 PM (16 years ago)
Author:
watersc1
Message:

Updates to automation code to trigger cleanups.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/automate_stacks.pl

    r27712 r27860  
    5656# Grab options
    5757my ( $date, $camera, $dbname, $logfile, $verbose, $manual);
    58 my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only);
     58my ( $help, $isburning, $force_stack_count, $test_mode, $this_target_only, $this_filter_only, $check_mode);
    5959my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips);
    6060my ( $check_stacks, $queue_stacks, $check_diffs, $queue_diffs, $clean_old);
     
    7070    'isburning'            => \$isburning,
    7171    'force_stack_count'    => \$force_stack_count,
     72    'check'                => \$check_mode,
    7273    'test_mode'            => \$test_mode,
    7374    'this_target_only=s'   => \$this_target_only,
     
    116117    defined $queue_chips or defined $queue_stacks or
    117118    defined $check_chips or defined $check_stacks or
    118     defined $test_mode or defined $clean_old;
     119    defined $test_mode or defined $clean_old or defined $check_mode;
    119120
    120121# Configurable parameters from our config file.
     
    127128my %stackable_list = ();
    128129my %reduction_class = ();
    129 my $retention_time = 9000;
    130 
     130my %clean_commands = ();
     131my %clean_retention = ();
     132my %noclean_list = ();
    131133# Grab the configuration data.
    132134my $conf_cmd = "$ppConfigDump -dump-recipe NIGHTLY_SCIENCE -";
     
    141143my $metadata = $mdcParser->parse(join "", @$stdout_buf);
    142144foreach my $entry (@{ $metadata }) {
    143     if (${ $entry }{name} eq 'RETENTION_TIME') {
    144         $retention_time = ${ $entry }{value};
    145     }
     145    if (@{ $entry }{name} eq 'CLEAN_MODES') {
     146        my @mode_data = @{ ${ $entry }{value} };
     147        my $this_mode = '';
     148        foreach my $mentry (@mode_data) {
     149            if (${ $mentry }{name} eq 'MODE') {
     150                $this_mode = ${ $mentry }{value};
     151            }
     152            elsif (${ $mentry }{name} eq 'COMMAND') {
     153                $clean_commands{$this_mode} = ${ $mentry }{value};
     154            }
     155            elsif (${ $mentry }{name} eq 'RETENTION_TIME') {
     156                $clean_retention{$this_mode} = ${ $mentry }{value};
     157            }
     158        }
     159    }
     160#    if (${ $entry }{name} eq 'RETENTION_TIME') {
     161#        $retention_time = ${ $entry }{value};
     162#    }
    146163    elsif (${ $entry }{name} eq 'FILTERS') {
    147164        push @filter_list, ${ $entry }{value};
     
    173190                $reduction_class{$this_target} = ${ $tentry }{value};
    174191            }
     192            elsif (${ $tentry }{name} eq 'NOCLEAN') {
     193                $noclean_list{$this_target} = ${ $tentry }{value};
     194            }
    175195        }
    176196    }
     
    218238if (defined($test_mode)) {
    219239    $debug = 1;
    220 }
    221 
    222 if (defined($check_registration) || defined($test_mode)) {
     240    my $z;
     241    foreach $z (@target_list) {
     242        print "TARGET: $z $tessID_list{$z} $obsmode_list{$z} $object_list{$z} $comment_list{$z} $stackable_list{$z} $reduction_class{$z}\n";
     243    }
     244    foreach $z (@filter_list) {
     245        print "FILTER: $z\n";
     246    }
     247    foreach $z (keys (%clean_commands)) {
     248        print "CLEAN: $z $clean_commands{$z} $clean_retention{$z}\n";
     249    }
     250   
     251}
     252
     253if (defined($check_registration) || defined($test_mode) || defined($check_mode)) {
    223254    $metadata_out{nsState} = 'NEW';
    224255    my ($Nsummit_exp,$Nfaults) = check_summit_copy($date);
    225256    return_metadata($date);
    226     unless (defined($test_mode)) { exit(0); }
     257    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    227258}
    228259if (defined($define_burntool) || defined($test_mode)) {
     
    237268    unless (defined($test_mode)) { exit(0); }
    238269}
    239 if (defined($check_chips) || defined($test_mode)) {
     270if (defined($check_chips) || defined($test_mode) || defined($check_mode)) {
    240271    $metadata_out{nsState} = 'QUEUECHIPS';
    241272    &execute_chips($date,"pretend");
     
    244275    }
    245276    return_metadata($date);
    246     unless (defined($test_mode)) { exit(0); }
     277    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    247278}
    248279if (defined($queue_chips)) {
     
    252283    exit(0);
    253284}
    254 if (defined($check_stacks) || defined($test_mode)) {
     285if (defined($check_stacks) || defined($test_mode) || defined($check_mode)) {
    255286    $metadata_out{nsState} = 'TOWARP';
    256287    &execute_stacks($date,"pretend");
     
    259290    }
    260291    return_metadata($date);
    261     unless (defined($test_mode)) { exit(0); }
     292    unless (defined($test_mode) || defined($check_mode)) { exit(0); }
    262293}
    263294if (defined($queue_stacks)) {
    264295    $metadata_out{nsState} = 'STACKING';
    265296    &execute_stacks($date);
    266     if ($metadata_out{nsState} == 'QUEUESTACKING') {
     297    if ($metadata_out{nsState} eq 'QUEUESTACKING') {
    267298        $metadata_out{nsState} = 'STACKING_POSSIBLE_ERROR';
    268299    }
     
    731762    my $date = shift;
    732763    my $target = shift;
     764    my $mode = shift;
     765
     766    my $command = $clean_commands{$mode};
     767    my $retention_time = $clean_retention{$mode};
    733768
    734769    my ($year,$month,$day) = split /-/,$date;
     
    740775
    741776    my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($cleaning_date,$target);
    742 
    743     my $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -data_group $data_group ";
     777    my $args = $command;
     778    $args .= " -dbname gpc1 -updaterun -set_state goto_cleaned -state full -set_label goto_cleaned -label $label -data_group $data_group ";
    744779    if ($debug == 1) {
    745780        $args .= ' -pretend ';
     
    752787    my $pretend = shift;
    753788
    754     foreach my $target (@target_list) {
    755         my ($cleaning_date,$args) = construct_cleantool_args($date,$target);
    756 
    757         my $command = $chiptool . $args;
    758         print STDERR "$command\n";
    759         if (!(defined($pretend) || $debug == 1)) {
     789    foreach my $mode (keys (%clean_commands)) {
     790        foreach my $target (@target_list) {
     791            if (exists($noclean_list{$target})) {
     792                next;
     793            }
     794            my ($cleaning_date,$command) = construct_cleantool_args($date,$target,$mode);
     795
     796            print STDERR "$command\n";
     797            if (!(defined($pretend) || $debug == 1)) {
    760798#           print STDERR "BEAR IS DRIVING!?\n";
    761             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    762                 run ( command => $command, verbose => $verbose );
    763             unless ($success) {
    764                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    765                 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    766             }
    767         }
    768         $command = $warptool . $args;
    769         print STDERR "$command\n";
    770         if (!(defined($pretend) || $debug == 1)) {
    771 #           print STDERR "BEAR IS DRIVING $pretend $debug!?\n";
    772             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    773                 run ( command => $command, verbose => $verbose );
    774             unless ($success) {
    775                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    776                 &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
    777             }
    778         }
     799                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     800                    run ( command => $command, verbose => $verbose );
     801                unless ($success) {
     802                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     803                    &my_die("Unable to perform stacktool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR);
     804                }
     805            }
     806        }
    779807    }
    780808    return(0);
Note: See TracChangeset for help on using the changeset viewer.