IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28377


Ignore:
Timestamp:
Jun 16, 2010, 6:00:09 PM (16 years ago)
Author:
eugene
Message:

max of 500 images per minidvo db

File:
1 edited

Legend:

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

    r28295 r28377  
    4141my (  $outroot, $dbname, $dvodb, $minidvodb,$minidvodb_interval, $minidvodb_group, $camera,  $verbose, $no_update,
    4242     $no_op, $redirect, $save_temps);
    43 GetOptions(   
     43GetOptions(
    4444    'camera|c=s'        => \$camera, # Camera
    4545    'dbname|d=s'        => \$dbname, # Database name
     
    6262          ) unless
    6363    defined $minidvodb_group and
    64     defined $camera and 
     64    defined $camera and
    6565    defined $outroot and
    6666    defined $dvodb;
     
    114114
    115115unless ($no_op) {
    116    
    117  
     116
     117
    118118
    119119#see if there is already one in new state
     
    123123    $fpaCommand1 .= " -dbname $dbname" if defined $dbname;
    124124
    125    
     125
    126126unless ($no_update) {
    127127    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    128128        run(command => $fpaCommand1, verbose => $verbose);
    129    
     129
    130130
    131131
     
    135135       exit($error_code);
    136136    }
    137    
     137
    138138    if (scalar(@{$stdout_buf})) {
    139         $error_code = 3;
    140             warn("Unwilling to create minidvodb, one already exists in new state: $error_code\n");
     139        $error_code = 3;
     140            warn("Unwilling to create minidvodb, one already exists in new state: $error_code\n");
    141141        exit($error_code);
    142142    }
     
    145145    my $addRun_count;
    146146    my $minidvodb_name;
    147 #find the active one's date, and find out if it has more than 1 addRun in it   
    148    
     147#find the active one's date, and find out if it has more than 1 addRun in it
     148
    149149    my $fpaCommand2 = "$addtool -listminidvodbrun";
    150150    $fpaCommand2 .= " -minidvodb_group '$minidvodb_group'";
     
    155155#print $fpaCommand2;
    156156
    157    
     157
    158158    my ( $success2, $error_code2, $full_buf2, $stdout_buf2, $stderr_buf2 ) =
    159         run(command => $fpaCommand2, verbose => $verbose);
     159        run(command => $fpaCommand2, verbose => $verbose);
    160160    &my_die( "Unable to get listminidvodbrun",$minidvodb_group, $PS_EXIT_SYS_ERROR) unless $success2;
    161161  # if it didn't list something in active state (what?) then we definitely need to create a new one
    162162    if (defined(@$stdout_buf2)) {
    163163  my  $metadata2 = $mdcParser->parse(join "", @$stdout_buf2) or
    164         &my_die("Unable to parse metadata config", $minidvodb_group, $PS_EXIT_PROG_ERROR);
    165    
     164        &my_die("Unable to parse metadata config", $minidvodb_group, $PS_EXIT_PROG_ERROR);
     165
    166166  my   $components2 = parse_md_list($metadata2) or
    167         &my_die("Unable to parse metadata list", $minidvodb_group, $PS_EXIT_PROG_ERROR);
     167        &my_die("Unable to parse metadata list", $minidvodb_group, $PS_EXIT_PROG_ERROR);
    168168  my   $comp2 = $$components2[0];
    169169    $minidvodb_name = $comp2->{minidvodb_name};
    170170    $creation_date  = $comp2->{creation_date};
    171171    if (!defined($minidvodb_name)) {
    172         &my_die("Unable to parse minidvodb_name", $minidvodb_group, $PS_EXIT_PROG_ERROR);
    173     } 
     172        &my_die("Unable to parse minidvodb_name", $minidvodb_group, $PS_EXIT_PROG_ERROR);
     173    }
    174174    if (!defined($creation_date)) {
    175         &my_die("Unable to parse creation_date", $minidvodb_group, $PS_EXIT_PROG_ERROR);
    176     } 
    177     } else { 
    178         $create_new = 1; #this is to force it to make a new one
    179             }
     175        &my_die("Unable to parse creation_date", $minidvodb_group, $PS_EXIT_PROG_ERROR);
     176    }
     177    } else {
     178        $create_new = 1; #this is to force it to make a new one
     179            }
    180180
    181181    #find the number of add_ids that have been proccessed
     
    187187    $fpaCommand3 .= " -dbname $dbname" if defined $dbname;
    188188
    189    
     189
    190190my ( $success3, $error_code3, $full_buf3, $stdout_buf3, $stderr_buf3 ) =
    191         run(command => $fpaCommand3, verbose => $verbose);
     191        run(command => $fpaCommand3, verbose => $verbose);
    192192    &my_die( "Unable to get checkminidvodbunaddrun", $minidvodb_group, $PS_EXIT_SYS_ERROR) unless $success3;
    193    
     193
    194194    if (defined(@$stdout_buf3)) {  #checkminidvodb returns nothing IF there have been no addruns added to the db yet
    195195    my  $metadata3 = $mdcParser->parse(join "", @$stdout_buf3) or
    196         &my_die("Unable to parse metadata config", $minidvodb_group, $PS_EXIT_PROG_ERROR);
    197    
     196        &my_die("Unable to parse metadata config", $minidvodb_group, $PS_EXIT_PROG_ERROR);
     197
    198198    my  $components3 = parse_md_list($metadata3) or
    199         &my_die("Unable to parse metadata list", $minidvodb_group, $PS_EXIT_PROG_ERROR);
     199        &my_die("Unable to parse metadata list", $minidvodb_group, $PS_EXIT_PROG_ERROR);
    200200   my  $comp = $$components3[0];
    201201    $addRun_count = $comp->{addRun_count};
    202         }
     202        }
    203203    if (!defined($addRun_count)) {
    204         ## there's nothing to parse if there's nothing
     204        ## there's nothing to parse if there's nothing
    205205        $addRun_count = 0;
    206     } 
    207    
    208 
    209     if ($addRun_count > 30000) {
    210         #it's too big, create_new
     206    }
     207
     208
     209    if ($addRun_count > 500) {
     210        #it's too big, create_new
    211211        $create_new = 1;
    212212   }
    213213    if ($create_new == 0) {
    214         my $parser = DateTime::Format::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S', time_zone => "HST" );
    215         my $creation_dt = $parser->parse_datetime( $creation_date )->mjd;
    216         if ($mjd_start- $creation_dt > $minidvodb_interval && $addRun_count > 0 ) {
    217             #db is old and has stuff in it, want to create_new
    218             $create_new = 1;
    219         }
    220     }
    221    
    222    
     214        my $parser = DateTime::Format::Strptime->new( pattern => '%Y-%m-%dT%H:%M:%S', time_zone => "HST" );
     215        my $creation_dt = $parser->parse_datetime( $creation_date )->mjd;
     216        if ($mjd_start- $creation_dt > $minidvodb_interval && $addRun_count > 0 ) {
     217            #db is old and has stuff in it, want to create_new
     218            $create_new = 1;
     219        }
     220    }
     221
     222
    223223}
    224224#create the minidvodb entry (well, the command for it)
     
    228228    $fpaCommand .= " -set_mergedvodb_path $dvodbReal";
    229229    $fpaCommand .= " -dbname $dbname" if defined $dbname;
    230    
     230
    231231    unless ($no_update or !$create_new) {
    232232
    233233
    234         my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    235             run(command => $fpaCommand, verbose => $verbose);
    236         unless ($success) {
    237             $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    238             warn("Unable to add result to database: $error_code\n");
    239             exit($error_code);
    240         }
     234        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     235            run(command => $fpaCommand, verbose => $verbose);
     236        unless ($success) {
     237            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     238            warn("Unable to add result to database: $error_code\n");
     239            exit($error_code);
     240        }
    241241    } else {
    242         print "skipping command: $fpaCommand\n";
     242        print "skipping command: $fpaCommand\n";
    243243    }
    244244}
     
    249249    my $minidvodb_group = shift; # Camtool identifier
    250250    my $exit_code = shift; # Exit code to add
    251    
     251
    252252    $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code;
    253    
     253
    254254    carp($msg);
    255    
     255
    256256    exit $exit_code;
    257257}
Note: See TracChangeset for help on using the changeset viewer.