Changeset 28377
- Timestamp:
- Jun 16, 2010, 6:00:09 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/minidvodb_createdb.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/minidvodb_createdb.pl
r28295 r28377 41 41 my ( $outroot, $dbname, $dvodb, $minidvodb,$minidvodb_interval, $minidvodb_group, $camera, $verbose, $no_update, 42 42 $no_op, $redirect, $save_temps); 43 GetOptions( 43 GetOptions( 44 44 'camera|c=s' => \$camera, # Camera 45 45 'dbname|d=s' => \$dbname, # Database name … … 62 62 ) unless 63 63 defined $minidvodb_group and 64 defined $camera and 64 defined $camera and 65 65 defined $outroot and 66 66 defined $dvodb; … … 114 114 115 115 unless ($no_op) { 116 117 116 117 118 118 119 119 #see if there is already one in new state … … 123 123 $fpaCommand1 .= " -dbname $dbname" if defined $dbname; 124 124 125 125 126 126 unless ($no_update) { 127 127 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 128 128 run(command => $fpaCommand1, verbose => $verbose); 129 129 130 130 131 131 … … 135 135 exit($error_code); 136 136 } 137 137 138 138 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"); 141 141 exit($error_code); 142 142 } … … 145 145 my $addRun_count; 146 146 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 149 149 my $fpaCommand2 = "$addtool -listminidvodbrun"; 150 150 $fpaCommand2 .= " -minidvodb_group '$minidvodb_group'"; … … 155 155 #print $fpaCommand2; 156 156 157 157 158 158 my ( $success2, $error_code2, $full_buf2, $stdout_buf2, $stderr_buf2 ) = 159 run(command => $fpaCommand2, verbose => $verbose);159 run(command => $fpaCommand2, verbose => $verbose); 160 160 &my_die( "Unable to get listminidvodbrun",$minidvodb_group, $PS_EXIT_SYS_ERROR) unless $success2; 161 161 # if it didn't list something in active state (what?) then we definitely need to create a new one 162 162 if (defined(@$stdout_buf2)) { 163 163 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 166 166 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); 168 168 my $comp2 = $$components2[0]; 169 169 $minidvodb_name = $comp2->{minidvodb_name}; 170 170 $creation_date = $comp2->{creation_date}; 171 171 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 } 174 174 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 one179 }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 } 180 180 181 181 #find the number of add_ids that have been proccessed … … 187 187 $fpaCommand3 .= " -dbname $dbname" if defined $dbname; 188 188 189 189 190 190 my ( $success3, $error_code3, $full_buf3, $stdout_buf3, $stderr_buf3 ) = 191 run(command => $fpaCommand3, verbose => $verbose);191 run(command => $fpaCommand3, verbose => $verbose); 192 192 &my_die( "Unable to get checkminidvodbunaddrun", $minidvodb_group, $PS_EXIT_SYS_ERROR) unless $success3; 193 193 194 194 if (defined(@$stdout_buf3)) { #checkminidvodb returns nothing IF there have been no addruns added to the db yet 195 195 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 198 198 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); 200 200 my $comp = $$components3[0]; 201 201 $addRun_count = $comp->{addRun_count}; 202 } 202 } 203 203 if (!defined($addRun_count)) { 204 ## there's nothing to parse if there's nothing204 ## there's nothing to parse if there's nothing 205 205 $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 211 211 $create_new = 1; 212 212 } 213 213 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 223 223 } 224 224 #create the minidvodb entry (well, the command for it) … … 228 228 $fpaCommand .= " -set_mergedvodb_path $dvodbReal"; 229 229 $fpaCommand .= " -dbname $dbname" if defined $dbname; 230 230 231 231 unless ($no_update or !$create_new) { 232 232 233 233 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 } 241 241 } else { 242 print "skipping command: $fpaCommand\n";242 print "skipping command: $fpaCommand\n"; 243 243 } 244 244 } … … 249 249 my $minidvodb_group = shift; # Camtool identifier 250 250 my $exit_code = shift; # Exit code to add 251 251 252 252 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 253 253 254 254 carp($msg); 255 255 256 256 exit $exit_code; 257 257 }
Note:
See TracChangeset
for help on using the changeset viewer.
