Changeset 30586 for branches/czw_branch/20101203/ippScripts
- Timestamp:
- Feb 11, 2011, 4:29:48 PM (15 years ago)
- Location:
- branches/czw_branch/20101203
- Files:
-
- 18 edited
- 1 copied
-
. (modified) (1 prop)
-
ippScripts/Build.PL (modified) (1 diff)
-
ippScripts/scripts/addstar_run.pl (modified) (4 diffs)
-
ippScripts/scripts/dist_advancerun.pl (modified) (8 diffs)
-
ippScripts/scripts/dist_bundle.pl (modified) (8 diffs)
-
ippScripts/scripts/dist_component.pl (modified) (5 diffs)
-
ippScripts/scripts/dist_defineruns.pl (modified) (4 diffs)
-
ippScripts/scripts/dist_make_fileset.pl (modified) (3 diffs)
-
ippScripts/scripts/ipp_apply_burntool_single.pl (modified) (3 diffs)
-
ippScripts/scripts/ipp_cleanup.pl (modified) (4 diffs)
-
ippScripts/scripts/magic_cleanup.pl (copied) (copied from trunk/ippScripts/scripts/magic_cleanup.pl )
-
ippScripts/scripts/magic_destreak.pl (modified) (3 diffs)
-
ippScripts/scripts/magic_destreak_cleanup.pl (modified) (2 diffs)
-
ippScripts/scripts/magic_destreak_defineruns.pl (modified) (3 diffs)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (9 diffs)
-
ippScripts/scripts/nightly_science.pl (modified) (21 diffs)
-
ippScripts/scripts/publish_file.pl (modified) (4 diffs)
-
ippScripts/scripts/register_exp.pl (modified) (1 diff)
-
ippScripts/scripts/register_imfile.pl (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20101203
- Property svn:mergeinfo changed
-
branches/czw_branch/20101203/ippScripts/Build.PL
r30018 r30586 58 58 scripts/magic_tree.pl 59 59 scripts/magic_process.pl 60 scripts/magic_cleanup.pl 60 61 scripts/magic_destreak.pl 61 62 scripts/magic_destreak_revert.pl -
branches/czw_branch/20101203/ippScripts/scripts/addstar_run.pl
r29006 r30586 71 71 defined $camera; 72 72 if ($minidvodb && !defined($minidvodb_group)) { 73 my_die( "missing minidvodb_group", $add_id, 3 );74 }73 my_die( "missing minidvodb_group", $add_id, 3 ); 74 } 75 75 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $add_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 76 76 … … 113 113 114 114 if (defined $dvodbReal) { 115 if ($minidvodb) { 116 117 if (!defined($minidvodb_name)) { 118 #take the active one, if it's not defined on the command line 119 #reverts would have this already set, for example. 120 my $command = "addtool -listminidvodbrun "; 121 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group; 122 $command .= " -state 'active' -limit 1"; 123 $command .= " -dbname $dbname" if defined $dbname; 124 print $command; 125 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 126 run(command => $command, verbose => $verbose); 127 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 128 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 129 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 130 131 my $components = parse_md_list($metadata) or 132 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 133 my $comp = $$components[0]; 134 $minidvodb_path = $comp->{minidvodb_path}; 135 $minidvodb_name = $comp->{minidvodb_name}; 136 137 if (!defined($minidvodb_path)) { 138 &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR); 139 } 140 if (!defined($minidvodb_name)) { 141 &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR); 142 } 143 } 144 # tack on the minidvodb part to the db. 145 # $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/'; 146 #we don't need this now that I fixed the paths 147 148 } 115 if ($minidvodb) { 116 117 #if (!defined($minidvodb_name)) { 118 #take the active one, if it's not defined on the command line 119 #reverts would have this already set, for example. 120 my $command = "addtool -listminidvodbrun "; 121 $command .= " -minidvodb_group $minidvodb_group" if defined $minidvodb_group; 122 $command .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 123 $command .= " -state 'active' -limit 1"; 124 $command .= " -dbname $dbname" if defined $dbname; 125 print $command; 126 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 127 run(command => $command, verbose => $verbose); 128 &my_die( "Unable to get active minidvodb_name", $add_id, $PS_EXIT_SYS_ERROR) unless $success; 129 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 130 &my_die("Unable to parse metadata config", $add_id, $PS_EXIT_PROG_ERROR); 131 132 my $components = parse_md_list($metadata) or 133 &my_die("Unable to parse metadata list", $add_id, $PS_EXIT_PROG_ERROR); 134 my $comp = $$components[0]; 135 $minidvodb_path = $comp->{minidvodb_path}; 136 $minidvodb_name = $comp->{minidvodb_name}; 137 138 if (!defined($minidvodb_path)) { 139 &my_die("Unable to parse minidvodb_path", $add_id, $PS_EXIT_PROG_ERROR); 140 } 141 if (!defined($minidvodb_name)) { 142 &my_die("Unable to parse minidvodb_name", $add_id, $PS_EXIT_PROG_ERROR); 143 } 144 #} 145 # tack on the minidvodb part to the db. 146 # $dvodbReal = $dvodbReal . '/' . $minidvodb_name . '/'; 147 #we don't need this now that I fixed the paths 148 149 } 149 150 else { 150 151 … … 153 154 154 155 unless ($no_op) { 155 print $dvodbReal;156 print $dvodbReal; 156 157 157 158 ## addstar can either save the full set of detections, or just … … 222 223 $command .= " -addprocessedexp"; 223 224 $command .= " -fault $exit_code"; 224 $command .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path;225 $command .= " -dvodb_path $minidvodb_path" if defined $minidvodb_path; 225 226 $command .= " -path_base $outroot" if defined $outroot; 226 227 $command .= (" -dtime_addstar " . ((DateTime->now->mjd - $mjd_start) * 86400)); 227 $fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name;228 $fpaCommand .= " -minidvodb_name $minidvodb_name" if defined $minidvodb_name; 228 229 $command .= " -dbname $dbname" if defined $dbname; 229 230 system ($command); -
branches/czw_branch/20101203/ippScripts/scripts/dist_advancerun.pl
r28963 r30586 23 23 use PS::IPP::Config 1.01 qw( :standard ); 24 24 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration26 25 27 26 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 29 28 30 29 # Parse the command-line arguments 31 my ($dist_id, $stage, $stage_id, $outdir, $clean );30 my ($dist_id, $stage, $stage_id, $outdir, $clean, $camera); 32 31 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); 33 32 34 33 GetOptions( 35 'dist_id=s' => \$dist_id,# Magic destreak run identifier 34 'dist_id=s' => \$dist_id,# Magic destreak run identifier 35 'camera=s' => \$camera, 36 36 'stage=s' => \$stage, # raw, chip, warp, or diff 37 37 'stage_id=s' => \$stage_id, # exp_id, chip_id, warp_id, or diff_id … … 53 53 defined $stage_id and 54 54 defined $outdir; 55 56 my $ipprc = PS::IPP::Config->new($camera); # IPP configuration 55 57 56 58 $ipprc->redirect_output($logfile) if $logfile; … … 134 136 } 135 137 136 # XXX should we create a file rule for this? 137 my $dbinfo_file = "$outdir/dbinfo.$stage.$stage_id.mdc"; 138 139 { 140 my $command = "$tool_cmd $exportarg -outfile $dbinfo_file"; 138 139 # work around the fact that $ipprc->file_create does not actually create a file on disk 140 # unless the scheme is nebulous 141 sub create_file { 142 my $rule = shift; 143 my $path_base = shift; 144 my $ref = shift; 145 146 my $file; 147 148 my $error; 149 $file = $ipprc->prepare_output($rule, $path_base, undef, 1, \$error) 150 or &my_die("Unable to prepare outut for $rule", $dist_id, $PS_EXIT_SYS_ERROR); 151 152 my $scheme = file_scheme($file); 153 $scheme = "" if !$scheme; 154 155 my $resolved; 156 if ($scheme) { 157 $ipprc->file_create($file) 158 or &my_die("Unable to create $file", $dist_id, $PS_EXIT_SYS_ERROR); 159 160 $resolved = $ipprc->file_resolve($file) 161 or &my_die("Unable to resolve $file", $dist_id, $PS_EXIT_SYS_ERROR); 162 163 if ($scheme eq 'neb') { 164 &my_die("$resolved not found", $dist_id, $PS_EXIT_SYS_ERROR) unless ($resolved and -e $resolved); 165 } 166 } else { 167 $resolved = $file; 168 } 169 $$ref = $resolved; 170 171 return $file 172 } 173 174 my $dbinfo_root = "$outdir/dbinfo.$stage.$stage_id"; 175 my $resolved; 176 my $dbinfo_file = create_file("DIST.OUTPUT.DBINFO", $dbinfo_root, \$resolved); 177 178 { 179 my $command = "$tool_cmd $exportarg -outfile $resolved"; 141 180 $command .= " -clean" if ((defined $clean) and ($stage ne "raw")); 142 181 $command .= " -dbname $dbname" if defined $dbname; … … 149 188 } 150 189 } 151 my $dirinfo = "$outdir/dirinfo.$stage.$stage_id.mdc"; 190 191 my $dirinfo_root = "$outdir/dirinfo.$stage.$stage_id"; 192 my $dirinfo = create_file("DIST.OUTPUT.DIRINFO", $dirinfo_root, \$resolved); 193 152 194 { 153 195 my $command = "$tool_cmd $list_mode"; … … 168 210 &my_die("Unable to parse metadata list", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 169 211 170 open MANIFEST, ">$ dirinfo" or171 &my_die("Unable to open dirinfo file $ dirinfo", $dist_id, $PS_EXIT_UNKNOWN_ERROR);212 open MANIFEST, ">$resolved" or 213 &my_die("Unable to open dirinfo file $resolved", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 172 214 173 215 my $destdir; … … 197 239 &my_die("unable to find path", $dist_id, $PS_EXIT_UNKNOWN_ERROR) if !$path; 198 240 my $component_dir = find_componentdir($destdir, $path); 199 # print MANIFEST "$component METADATA\n";200 241 print MANIFEST "\t" , "$component", "\tSTR\t", $component_dir, "\n"; 201 242 } … … 217 258 } 218 259 } 219 220 260 221 261 exit 0; -
branches/czw_branch/20101203/ippScripts/scripts/dist_bundle.pl
r30118 r30586 16 16 17 17 use IPC::Cmd 0.36 qw( can_run run ); 18 use File::Temp qw( tempfile );18 use File::Temp qw( tempfile tempdir ); 19 19 use File::Basename qw( basename ); 20 20 use Digest::MD5::File qw( file_md5_hex ); … … 71 71 # Parse the command-line arguments 72 72 my ($camera, $stage, $stage_id, $component, $path_base, $chip_path_base, $alt_path_base, $clean); 73 my ($out dir, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix);73 my ($outroot, $run_state, $data_state, $magicked, $no_magic, $poor_quality, $results_file, $prefix); 74 74 my ($dbname, $save_temps, $verbose, $no_update, $logfile); 75 75 … … 88 88 'magicked' => \$magicked, # magicked state for this component 89 89 'alt_path_base=s'=> \$alt_path_base, # path to alternate inputs 90 'out dir=s' => \$outdir, # "directory" for outputs90 'outroot=s' => \$outroot, # outroot 91 91 'prefix=s' => \$prefix, # "prefix" to apply to filenames 92 92 'clean' => \$clean, # create clean distribution … … 99 99 100 100 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 101 pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --out dir",101 pod2usage( -msg => "Required options: --camera --stage --stage_id --component --path_base --outroot", 102 102 -exitval => 3) unless 103 103 defined $camera and … … 106 106 defined $component and 107 107 defined $path_base and 108 defined $out dir;108 defined $outroot; 109 109 110 110 $ipprc->redirect_output($logfile) if $logfile; … … 116 116 $ipprc->define_camera($camera); 117 117 118 # create the output directories if it is not a nebulous path and it doesn't exist 119 if (index($outdir, "neb://") != 0) { 120 if (! -e $outdir ) { 121 my $code = system "mkdir -p $outdir"; 122 &my_die("cannot create output directory $outdir", $component, 123 $code >> 8) if $code; 124 } 125 } 118 $ipprc->outroot_prepare($outroot); 126 119 127 120 # Get the list of data products for this component … … 138 131 # set up directory for temporary files 139 132 140 my $tmpdir = "$outdir/tmpdir.$component.$$"; 141 if (-e $tmpdir) { 142 if (-d $tmpdir) { 143 my $rc = system "rm -r $tmpdir"; 144 &my_die("cannot rm $tmpdir return code: $rc", $component, $PS_EXIT_UNKNOWN_ERROR) if $rc; 145 } else { 146 unlink $tmpdir or &my_die("cannot delete $tmpdir", $component, $PS_EXIT_UNKNOWN_ERROR); 147 } 148 } 149 mkdir $tmpdir or &my_die("cannot create temporary directory $tmpdir", $component, 150 $PS_EXIT_UNKNOWN_ERROR); 133 my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR"); 134 $temproot = "/tmp" if !defined $temproot; 135 &my_die("directory for TEMP.DIR $temproot does not exist", $component, $PS_EXIT_CONFIG_ERROR) if ! -e $temproot; 136 137 my $tmpdir = tempdir("$temproot/dist.XXXX", CLEANUP => !$save_temps); 151 138 152 139 # … … 349 336 if ($num_files) { 350 337 # create the tarfile 351 # XXX TODO: create a file rule for the tar file name 352 my $tbase = basename($path_base); 353 $tbase .= ".$component" if $component; 354 $file_name = ($prefix ? $prefix : "") . "$tbase.tgz"; 355 my $tarfile = "$outdir/$file_name"; 338 # my $tbase = basename($path_base); 339 # $tbase .= ".$component" if $component; 340 # $file_name = ($prefix ? $prefix : "") . "$tbase.tgz"; 341 my $error; 342 my $output_tarfile; 343 my $rule; 344 if ($stage eq 'chip' or $stage eq 'chip_bg' or $stage eq 'raw') { 345 $rule = "DIST.OUTPUT.CHIP.BUNDLE"; 346 } else { 347 $rule = "DIST.OUTPUT.BUNDLE"; 348 } 349 $output_tarfile = $ipprc->prepare_output($rule, $outroot, $component, 1, \$error) 350 or &my_die("Failed to prepare output tarfile: $error", $component, $error); 351 $file_name = basename($output_tarfile); 352 353 354 my $scheme = file_scheme($output_tarfile); 355 356 my $tarfile; 357 if ($scheme) { 358 $ipprc->file_create($output_tarfile) 359 or &my_die("Failed to create $output_tarfile: $error", $component, $error); 360 $tarfile = $ipprc->file_resolve($output_tarfile); 361 362 if ($scheme eq 'neb') { 363 &my_die("output file $output_tarfile not found", $component, $PS_EXIT_SYS_ERROR) 364 unless ($tarfile and -e $tarfile); 365 } 366 } else { 367 # no scheme the filename and the resolved filename are the same 368 $tarfile = $output_tarfile; 369 } 356 370 357 371 my $command = "tar -C $tmpdir --owner=ipp --group=users -czhf $tarfile ."; -
branches/czw_branch/20101203/ippScripts/scripts/dist_component.pl
r27718 r30586 21 21 use PS::IPP::Metadata::Config; 22 22 use PS::IPP::Metadata::List qw( parse_md_list ); 23 24 23 use PS::IPP::Config 1.01 qw( :standard ); 25 26 my $ipprc = PS::IPP::Config->new(); # IPP configuration27 24 28 25 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 77 74 defined $outdir; 78 75 76 my $ipprc = PS::IPP::Config->new($camera); # IPP configuration 79 77 $ipprc->redirect_output($logfile) if $logfile; 78 79 my $temproot = metadataLookupStr($ipprc->{_siteConfig}, "TEMP.DIR"); 80 81 $temproot = "/tmp" if !defined $temproot; 80 82 81 83 if (($stage eq 'raw') and !$clean and !defined $chip_path_base) { … … 85 87 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 86 88 87 my ($rf, $rf_name) = tempfile(" /tmp/bundleresults.$dist_id.$component.XXXX", UNLINK => !$save_temps);89 my ($rf, $rf_name) = tempfile("$temproot/bundleresults.$dist_id.$component.XXXX", UNLINK => !$save_temps); 88 90 close $rf; 91 92 my $basename = basename($path_base); 93 my $outroot = "$outdir/$basename"; 89 94 90 95 my ($file_name, $bytes, $md5sum); … … 92 97 my $command = "$dist_make_bundle --camera $camera --stage $stage --stage_id $stage_id"; 93 98 $command .= " --results_file $rf_name"; 94 $command .= " --component $component --path_base $path_base --out dir $outdir";99 $command .= " --component $component --path_base $path_base --outroot $outroot"; 95 100 $command .= " --chip_path_base $chip_path_base" if $chip_path_base; 96 101 $command .= " --state $run_state" if defined $run_state; … … 136 141 &my_die("undefined file md5sum from dist_bundle.pl", $dist_id, $component, $outdir, $PS_EXIT_PROG_ERROR) unless defined $md5sum; 137 142 } 143 138 144 139 145 { -
branches/czw_branch/20101203/ippScripts/scripts/dist_defineruns.pl
r29068 r30586 42 42 43 43 # Parse the command-line arguments 44 my ($stage, $stage_limit, $dist_root, $ no_magic);44 my ($stage, $stage_limit, $dist_root, $workdir, $no_magic); 45 45 my ($dbname, $save_temps, $verbose, $no_update, $logfile); 46 46 my @labels; … … 49 49 'stage=s' => \$stage, # stage to queue 50 50 'label=s' => \@labels, # labels 51 'workdir=s' => \$workdir, # workdir 51 52 'stage_limit=s' => \$stage_limit,# maximum number of runs queued for each stage 52 'dist_root=s' => \$dist_root, # root of distribution work area53 # 'dist_root=s' => \$dist_root, # root of distribution work area 53 54 'no_magic' => \$no_magic, # queue runs without requiring magic (for testing only) 54 55 'dbname=s' => \$dbname, # Database name … … 66 67 $ipprc->redirect_output($logfile) if $logfile; 67 68 68 if (!$dist_root) { 69 $dist_root = metadataLookupStr($ipprc->{_siteConfig}, "DISTRIBUTION_ROOT"); 70 &my_die("failed to find DISTRIBUTION_ROOT in site configuration", $PS_EXIT_CONFIG_ERROR) if !$dist_root; 69 if (!$workdir) { 70 print "workdir not supplied will use DISTRIBUTION_ROOT\n"; 71 # old method where we set workdir based on a config file 72 if (!$dist_root) { 73 $dist_root = metadataLookupStr($ipprc->{_siteConfig}, "DISTRIBUTION_ROOT"); 74 &my_die("failed to find DISTRIBUTION_ROOT in site configuration", $PS_EXIT_CONFIG_ERROR) if !$dist_root; 75 } 76 77 my ($day, $month, $year) = (gmtime)[3,4,5]; 78 my $datestr = sprintf "%04d%02d%02d", $year+1900, $month + 1, $day; 79 80 $workdir = $dist_root . "/$datestr"; 81 82 print "workdir is $workdir\n"; 71 83 } 72 73 my ($day, $month, $year) = (gmtime)[3,4,5];74 my $datestr = sprintf "%04d%02d%02d", $year+1900, $month + 1, $day;75 76 my $workdir = "$dist_root/$datestr";77 78 print "workdir is $workdir\n";79 84 80 85 # if stage is not supplied as an argument, loop over all stages … … 90 95 my $command = "$disttool -definebyquery -stage $stage -workdir $workdir -label $label"; 91 96 $command .= " -no_magic" if $no_magic; 92 $command .= " - dry_run" if $no_update;97 $command .= " -pretend" if $no_update; 93 98 $command .= " -limit $stage_limit" if $stage_limit; 94 99 $command .= " -set_label $label"; -
branches/czw_branch/20101203/ippScripts/scripts/dist_make_fileset.pl
r28963 r30586 96 96 # make sure that the database info file for this run exists 97 97 my $dbinfo_file = "$dist_dir/dbinfo.$stage.$stage_id.mdc"; 98 if (! -e "$dbinfo_file") {98 if (! $ipprc->file_exists($dbinfo_file) ) { 99 99 &my_die("dbinfo file for dist run $dbinfo_file not found", $dist_id, $dest_id, $PS_EXIT_UNKNOWN_ERROR); 100 100 } … … 103 103 # make sure that the dirinfo file for this run exists 104 104 my $dirinfo_file = "$dist_dir/dirinfo.$stage.$stage_id.mdc"; 105 if (! -e "$dirinfo_file") {105 if (!$ipprc->file_exists($dirinfo_file)) { 106 106 &my_die("dirinfo file for dist run $dirinfo_file not found", $dist_id, $dest_id, $PS_EXIT_UNKNOWN_ERROR); 107 107 } … … 277 277 $command .= " -dbname $dbname" if $dbname; 278 278 279 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 280 run(command => $command, verbose => $verbose); 281 unless ($success) { 282 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 283 print STDERR "Unable to perform $command error_code: $error_code\n"; 279 if (!$no_update) { 280 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 281 run(command => $command, verbose => $verbose); 282 unless ($success) { 283 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 284 print STDERR "Unable to perform $command error_code: $error_code\n"; 285 } 286 } else { 287 print STDERR "skipping $command\n"; 284 288 } 285 289 exit $fault; -
branches/czw_branch/20101203/ippScripts/scripts/ipp_apply_burntool_single.pl
r29982 r30586 74 74 unless ($success) { 75 75 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 76 &my_die("Unable to perform ppConfigDump: $error_code", 0, 0, $class_id, $PS_EXIT_SYS_ERROR);76 &my_die("Unable to perform ppConfigDump: $error_code", $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 77 77 } 78 78 79 79 my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or 80 &my_die("Unable to parse metadata config doc", 0, 0, $class_id, $PS_EXIT_SYS_ERROR);80 &my_die("Unable to parse metadata config doc", $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 81 81 82 82 my $burntoolStateGood = 999; … … 87 87 } 88 88 if ($burntoolStateGood == 999) { 89 &my_die("Failed to determine BURNTOOL.STATE.GOOD", $ burntoolStateGood, $class_id, 0, $PS_EXIT_SYS_ERROR);89 &my_die("Failed to determine BURNTOOL.STATE.GOOD", $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 90 90 } 91 91 my $outState = -1 * abs($burntoolStateGood); … … 178 178 my $exp_id = shift; 179 179 my $class_id = shift; 180 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state -3",1);180 vsystem("$regtool -dbname $dbname -updateprocessedimfile -exp_id $exp_id -class_id $class_id -burntool_state 0 -set_state pending_burntool",1); 181 181 } 182 182 printf STDERR "$message\n"; -
branches/czw_branch/20101203/ippScripts/scripts/ipp_cleanup.pl
r29892 r30586 167 167 # addFilename (\@files, "PPIMAGE.OUTPUT.MASK", $path_base, $class_id); 168 168 # addFilename (\@files, "PPIMAGE.OUTPUT.VARIANCE", $path_base, $class_id); 169 addFilename (\@files, "PPIMAGE.CHIP", $path_base, $class_id );170 addFilename (\@files, "PPIMAGE.CHIP.MASK", $path_base, $class_id );171 addFilename (\@files, "PPIMAGE.CHIP.VARIANCE", $path_base, $class_id );169 addFilename (\@files, "PPIMAGE.CHIP", $path_base, $class_id, 1); 170 addFilename (\@files, "PPIMAGE.CHIP.MASK", $path_base, $class_id, 1); 171 addFilename (\@files, "PPIMAGE.CHIP.VARIANCE", $path_base, $class_id, 1); 172 172 if ($mode eq "goto_purged") { 173 173 # additional files to remove for 'purge' mode … … 429 429 430 430 # delete the temporary image datafiles 431 addFilename(\@files, "PSWARP.OUTPUT", $path_base, $skycell_id );432 addFilename(\@files, "PSWARP.OUTPUT.MASK", $path_base, $skycell_id );433 addFilename(\@files, "PSWARP.OUTPUT.VARIANCE", $path_base, $skycell_id );431 addFilename(\@files, "PSWARP.OUTPUT", $path_base, $skycell_id, 1); 432 addFilename(\@files, "PSWARP.OUTPUT.MASK", $path_base, $skycell_id, 1); 433 addFilename(\@files, "PSWARP.OUTPUT.VARIANCE", $path_base, $skycell_id, 1); 434 434 # addFilename(\@files, "PSWARP.OUTPUT.SOURCES", $path_base, $skycell_id); 435 435 if ($mode eq "goto_purged") { … … 706 706 my @files = (); 707 707 # delete the temporary image datafiles 708 addFilename(\@files, "PPSUB.OUTPUT", $path_base, $skycell_id );709 addFilename(\@files, "PPSUB.OUTPUT.MASK", $path_base, $skycell_id );710 addFilename(\@files, "PPSUB.OUTPUT.VARIANCE", $path_base, $skycell_id );711 712 addFilename(\@files, "PPSUB.INVERSE", $path_base, $skycell_id );713 addFilename(\@files, "PPSUB.INVERSE.MASK", $path_base, $skycell_id );714 addFilename(\@files, "PPSUB.INVERSE.VARIANCE", $path_base, $skycell_id );708 addFilename(\@files, "PPSUB.OUTPUT", $path_base, $skycell_id, 1); 709 addFilename(\@files, "PPSUB.OUTPUT.MASK", $path_base, $skycell_id, 1); 710 addFilename(\@files, "PPSUB.OUTPUT.VARIANCE", $path_base, $skycell_id, 1); 711 712 addFilename(\@files, "PPSUB.INVERSE", $path_base, $skycell_id, 1); 713 addFilename(\@files, "PPSUB.INVERSE.MASK", $path_base, $skycell_id, 1); 714 addFilename(\@files, "PPSUB.INVERSE.VARIANCE", $path_base, $skycell_id, 1); 715 715 716 716 addFilename(\@files, "PPSUB.INPUT.CONV", $path_base, $skycell_id); … … 2048 2048 my $path_base = shift; # base filename 2049 2049 my $class_id = shift; # class_id, if needed 2050 my $recovery = shift; # is there is a recovery file to clean? 2050 2051 2051 2052 my $file = $ipprc->filename($filerule, $path_base, $class_id); 2052 2053 2053 2054 push @$files, $file; 2055 2056 if ($recovery) { 2057 # need to clean up the recovery file (the pixels censored by streaksremove) 2058 $file = $ipprc->recovery_filename($file); 2059 push @$files, $file; 2060 } 2054 2061 return 1; 2055 2062 } -
branches/czw_branch/20101203/ippScripts/scripts/magic_destreak.pl
r30118 r30586 65 65 'cam_reduction=s'=> \$cam_reduction, # reduction class from camera stage (for chip and raw) 66 66 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) 67 'recoveryroot=s' => \$recoveryroot,# " directory" for saving the images of excised pixels67 'recoveryroot=s' => \$recoveryroot,# "prefix" for saving the images of excised pixels 68 68 'replace=s' => \$replace, # replace the input images with the results. 69 69 'magicked=s' => \$magicked, # magicked state of the run … … 190 190 my $recovery_path_base; 191 191 if ($recoveryroot) { 192 if (!inNebulous($recoveryroot)) { 193 if (! -e $recoveryroot ) { 194 my $code = system "mkdir -p $recoveryroot"; 195 &my_die("cannot create output directory $recoveryroot", $magic_ds_id, $component, 196 $code >> 8) if $code; 197 } 198 } 199 # note: trailing / is necessary 200 $recovery_path_base = "$recoveryroot/$basename/"; 192 # recoveryroot is a path to prepend to the basenames of the input files 193 if (inNebulous($recoveryroot)) { 194 # if recoveryroot is a nebulous path we ignore the actual path and put the files in the 195 # the same "directory" as the input files 196 $recoveryroot = "$dirname/REC_"; 197 $recovery_path_base = $recoveryroot . $basename; 198 } else { 199 # otherwise we put the files in recoveryroot. 200 # Regardless, we prefix the basename with 'REC_' 201 $ipprc->outroot_prepare($recoveryroot); 202 $recovery_path_base = "$recoveryroot/REC_$basename"; 203 } 201 204 } 202 205 … … 601 604 $command .= " -magic_ds_id $magic_ds_id"; 602 605 $command .= " -component $component"; 606 $command .= " -backup_path_base $backup_path_base" if $backup_path_base; 607 $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base; 603 608 $command .= " -fault $exit_code"; 604 609 $command .= " -dbname $dbname" if defined $dbname; -
branches/czw_branch/20101203/ippScripts/scripts/magic_destreak_cleanup.pl
r29829 r30586 233 233 $bmask = $ipprc->filename("$name.MASK", $backup_path_base); 234 234 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 235 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 235 # bills 2011-01-24 236 # don't clean up the uncensored sources file 237 # $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 236 238 } 237 239 if ($recovery_path_base) { … … 251 253 $bmask = $ipprc->filename("$name.MASK", $backup_path_base); 252 254 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 253 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 255 # bills 2011-01-24 256 # don't clean up the uncensored sources file 257 # $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 254 258 } 255 259 if ($recovery_path_base) { -
branches/czw_branch/20101203/ippScripts/scripts/magic_destreak_defineruns.pl
r30118 r30586 42 42 43 43 # Parse the command-line arguments 44 my ($stage, $stage_limit, $workdir );44 my ($stage, $stage_limit, $workdir, $recoveryroot); 45 45 my ($dbname, $save_temps, $verbose, $no_update, $logfile); 46 46 my @labels; … … 51 51 'stage_limit=s' => \$stage_limit,# maximum number of runs queued for each stage 52 52 'workdir=s' => \$workdir, # output destination 53 'recoveryroot=s' => \$recoveryroot, # recovery pixels destination 53 54 'dbname=s' => \$dbname, # Database name 54 55 'verbose' => \$verbose, # Print stuff? … … 78 79 foreach my $label (@labels) { 79 80 my $command = "$magicdstool -definebyquery -stage $stage -workdir $workdir -label $label"; 81 $command .= " -recoveryroot $recoveryroot" if $recoveryroot; 80 82 $command .= " -pretend" if $no_update; 81 83 $command .= " -limit $stage_limit" if $stage_limit; -
branches/czw_branch/20101203/ippScripts/scripts/magic_destreak_revert.pl
r30118 r30586 39 39 # Parse the command-line arguments 40 40 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked, $run_state); 41 my ($outroot, $recovery root, $replace, $release, $bytes, $md5sum);41 my ($outroot, $recovery_path_base, $replace, $release, $bytes, $md5sum); 42 42 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); 43 43 … … 53 53 'cam_reduction=s'=> \$cam_reduction, # reduction class of the associated camera run 54 54 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) 55 'recovery root=s' => \$recoveryroot,# "directory" for saving the images of excised pixels55 'recovery_path_base=s' => \$recovery_path_base,# "directory" for saving the images of excised pixels 56 56 'replace=s' => \$replace, # replace the input images with the results. 57 57 'bothways=s' => \$bothways, # run has inverse files (bothways diff) … … 130 130 131 131 # default value is "NULL" do not use it 132 if (defined($recovery root) and ($recoveryrooteq "NULL")) {133 $recovery root= undef;132 if (defined($recovery_path_base) and ($recovery_path_base eq "NULL")) { 133 $recovery_path_base = undef; 134 134 } 135 135 … … 149 149 } 150 150 151 my $recovery_path_base;152 if ($recoveryroot) {153 # note: trailing / is necessary154 $recovery_path_base = "$recoveryroot/$basename/";155 }156 157 151 158 152 my ($image, $mask, $ch_mask, $weight, $sources, $astrom); 159 153 my ($bimage, $bmask, $bch_mask, $bweight, $bsources, $bastrom); 154 my ($rimage, $rmask, $rch_mask, $rweight); 160 155 161 156 if ($stage eq "raw") { … … 214 209 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id); 215 210 $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $class_id); 211 212 $rimage = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $class_id); 213 # This is somewhat kludgey but it works whether the mask is camera mask or chip mask 214 $rmask = dirname($recovery_path_base) . "/REC_" . basename($mask); 215 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $class_id); 216 $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $class_id); 216 217 } elsif ($stage eq "camera") { 217 218 $astrom = $ipprc->filename("PSASTRO.OUTPUT", $path_base); … … 226 227 $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base); 227 228 $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base); 229 $rimage = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base); 230 $rmask = $ipprc->filename("PSWARP.OUTPUT.MASK", $recovery_path_base); 231 $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base); 228 232 } elsif ($stage eq "diff") { 229 233 my $name = "PPSUB.OUTPUT"; … … 236 240 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 237 241 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 242 if ($recovery_path_base) { 243 $rimage = $ipprc->filename($name, $recovery_path_base); 244 $rmask = $ipprc->filename("$name.MASK", $recovery_path_base); 245 $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base); 246 } 238 247 } 239 248 240 249 revert_files($replace, $image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom); 250 if ($recovery_path_base) { 251 delete_recovery_files($rimage, $rmask, $rweight, $rch_mask); 252 } 241 253 242 254 if ($stage eq "diff" and $bothways) { … … 251 263 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 252 264 revert_files($replace, $image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef); 265 if ($recovery_path_base) { 266 $rimage = $ipprc->filename($name, $recovery_path_base); 267 $rmask = $ipprc->filename("$name.MASK", $recovery_path_base); 268 $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base); 269 delete_recovery_files($rimage, $rmask, $rweight); 270 } 253 271 } 254 272 … … 426 444 427 445 428 sub file_check 429 { 430 my $file = shift; # Name of file 431 &my_die("Unable to find output file: $file", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR) unless 432 $ipprc->file_exists($file); 446 sub delete_recovery_files 447 { 448 foreach my $file (@_) { 449 if ($ipprc->file_exists($file)) { 450 if (!$ipprc->file_delete($file)) { 451 &my_die("failed to delete recovery file $file", $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR); 452 } 453 } 454 } 433 455 } 434 456 -
branches/czw_branch/20101203/ippScripts/scripts/nightly_science.pl
r30017 r30586 44 44 my ( $date, $datetime, $camera, $dbname, $logfile, $verbose, $manual); 45 45 my ( $help, $isburning, $force_stack_count, $force_diff_count, $test_mode, $this_target_only, $this_filter_only, $this_mode_only, $check_mode); 46 my ( $registration_status, $burntool_status, $observing_status );46 my ( $registration_status, $burntool_status, $observing_status, $old_date); 47 47 my ( $check_registration, $define_burntool, $queue_burntool, $check_chips, $queue_chips); 48 48 my ( $check_stacks, $queue_stacks, $check_sweetspot, $queue_sweetspot, $check_diffs, $queue_diffs, $clean_old); … … 66 66 'registraion_status' => \$registration_status, 67 67 'burntool_status' => \$burntool_status, 68 'old_date=s' => \$old_date, 68 69 'check_stacks' => \$check_stacks, 69 70 'queue_stacks' => \$queue_stacks, … … 134 135 unless ($success) { 135 136 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 136 &my_die("Unable to perform ppConfigDump: $error_code", $date, $PS_EXIT_SYS_ERROR);137 &my_die("Unable to perform ppConfigDump: $error_code", 0, 0, $date, $PS_EXIT_SYS_ERROR); 137 138 } 138 139 … … 278 279 279 280 $metadata_out{nsObservingState} = &get_observing_state($date); 281 $metadata_out{nsRegistrationState} = &get_registration_state($date); 280 282 # 281 283 # Mode selection … … 396 398 exit(0); 397 399 } 398 exit(10); 400 399 401 if (defined($check_confirm_stacks) || defined($test_mode)) { 400 402 $metadata_out{nsStackState} = 'CONFIRM_STACKING'; … … 409 411 exit(0); 410 412 } 411 413 exit(10); 412 414 if (defined($check_sweetspot) || defined($test_mode) || defined($check_mode)) { 413 415 $metadata_out{nsSSState} = 'CHECKSWEETSPOT'; … … 1097 1099 my $pretend = shift; 1098 1100 1101 my $Npotential = 0; 1102 my $Nqueued = 0; 1103 my $is_processing = 0; 1104 my $is_registering; 1105 if ($metadata_out{nsRegistrationState} eq 'REGISTERED') { 1106 $is_registering = 0; 1107 } 1108 else { 1109 $is_registering = 1; 1110 } 1111 1099 1112 foreach my $target (sort (keys %science_config)) { 1100 1113 if ($science_config{$target}{STACKABLE} == 1) { … … 1105 1118 print STDERR "execute_stacks: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 1106 1119 } 1120 $is_processing = 1; 1107 1121 $metadata_out{nsStackState} = 'FORCETOWARP'; 1108 1122 next; … … 1120 1134 next; 1121 1135 } 1136 $Npotential++; 1122 1137 if ($Nalready != 0) { 1138 $Nqueued++; 1123 1139 if ($debug == 1) { 1124 1140 print STDERR "execute_stacks: Not queueing $target in filter $filter on $date due to already existing stacks.\n"; … … 1137 1153 } 1138 1154 stack_queue($date,$target,$filter); 1155 $Nqueued ++; 1139 1156 } 1140 1157 if (defined($pretend)) { … … 1152 1169 } 1153 1170 } 1171 $metadata_out{nsStackPotential} = $Npotential; 1172 $metadata_out{nsStackQueued} = $Nqueued; 1173 if (($Npotential == $Nqueued)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)&&($is_registering == 0)) { 1174 $metadata_out{nsStackState} = 'FINISHED_STACKS'; 1175 } 1154 1176 } 1155 1177 … … 1231 1253 my ($label,$workdir,$obs_mode,$object,$comment,$tess_id,$dist_group,$data_group,$reduction) = get_tool_parameters($date,$target); 1232 1254 1233 my $sth = "SELECT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_1 AND warp2 = $warp_id_2"; 1255 my $count = 0; 1256 1257 my $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_1 AND warp2 = $warp_id_2"; 1234 1258 my $data_ref = $db->selectall_arrayref( $sth ); 1235 1236 return($#{ $data_ref } + 1); 1259 $count += $#{ $data_ref } + 1; 1260 1261 $sth = "SELECT DISTINCT diff_id from diffRun JOIN diffInputSkyfile USING(diff_id) where data_group = '$data_group' AND warp1 = $warp_id_2 AND warp2 = $warp_id_1"; 1262 $data_ref = $db->selectall_arrayref( $sth ); 1263 $count += $#{ $data_ref } + 1; 1264 1265 return($count); 1237 1266 } 1238 1267 … … 1272 1301 my $pretend = shift; 1273 1302 1303 my $Npotential = 0; 1304 my $Nnoexp = 0; 1305 my $is_processing = 0; 1306 my $is_registering; 1307 if ($metadata_out{nsRegistrationState} eq 'REGISTERED') { 1308 $is_registering = 0; 1309 } 1310 else { 1311 $is_registering = 1; 1312 } 1313 1274 1314 foreach my $target (sort (keys %science_config)) { 1275 1315 if ($science_config{$target}{DIFFABLE} == 1) { 1276 1316 foreach my $filter (@filter_list) { 1317 $Npotential ++; 1277 1318 my ($NprocChips,$NprocWarps) = pre_diff_queue($date,$observing_state,$target,$filter); 1278 1319 if ((!defined($force_diff_count))&&($NprocChips != $NprocWarps)) { … … 1280 1321 print STDERR "execute_diffs: Target $target on $date is not fully processed. ($NprocChips $NprocWarps)\n"; 1281 1322 } 1282 $metadata_out{nsDiffState} = 'FORCETOWARP'; 1283 next; 1284 } 1323 $is_processing = 1; 1324 } 1285 1325 if ($NprocChips == 0) { 1326 $Nnoexp ++; 1286 1327 if ($debug == 1) { 1287 1328 print STDERR "execute_diffs: Target $target in filter $filter on $date has no exposures.\n"; … … 1311 1352 } 1312 1353 } 1354 if ($debug == 1) { 1355 print "$metadata_out{nsObservingState} $metadata_out{nsDiffPotential} $metadata_out{nsDiffQueued} $is_processing $is_registering\n"; 1356 } 1357 1358 if ($metadata_out{nsObservingState} eq 'END_OF_NIGHT') { 1359 if ($is_processing == 1) { 1360 $metadata_out{nsDiffState} = 'DIFFING'; 1361 } 1362 elsif ($is_registering == 0) { 1363 if ($Npotential == $Nnoexp) { 1364 $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1365 } 1366 elsif ($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued}) { 1367 $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1368 } 1369 } 1370 else { 1371 $metadata_out{nsDiffState} = 'DIFFING'; 1372 } 1373 } 1374 else { 1375 $metadata_out{nsDiffState} = 'DIFFING'; 1376 } 1377 1378 # if (($Npotential == $Nnoexp)&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')&&($is_processing == 0)) { 1379 # $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1380 # } 1381 1382 # if ($is_processing == 1) { 1383 # $metadata_out{nsDiffState} = 'DIFFING'; 1384 # } 1313 1385 } 1314 1386 … … 1326 1398 1327 1399 my $object_ref = $db->selectall_arrayref( $obj_sth ); 1400 1401 my $Npotential = 0; 1402 my $Nqueued = 0; 1328 1403 1329 1404 foreach my $object_row (@{ $object_ref }) { 1330 1405 my $this_object = shift @{ $object_row }; 1331 my $input_sth = "select exp_id,warp_id,dateobsfrom warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) ";1332 $input_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' ";1333 $input_sth .= " ORDER BY dateobs ";1406 # my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment from warpRun JOIN fakeRun USING(fake_id) JOIN camRun USING(cam_id) JOIN chipRun USING(chip_id) JOIN rawExp USING(exp_id) "; 1407 # $input_sth .= " WHERE warpRun.state = 'full' AND warpRun.label = '$label' AND warpRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1408 # $input_sth .= " ORDER BY dateobs "; 1334 1409 1410 my $input_sth = "select exp_id,warp_id,dateobs,rawExp.comment,warpRun.state AS warp_state FROM "; 1411 $input_sth .= " rawExp LEFT JOIN chipRun USING (exp_id) LEFT JOIN camRun USING (chip_id) LEFT JOIN fakeRun USING (cam_id) LEFT JOIN warpRun USING (fake_id) "; 1412 $input_sth .= " WHERE chipRun.label = '$label' AND chipRun.data_group = '$data_group' AND rawExp.filter = '$filter' AND rawExp.object = '$this_object' "; 1413 $input_sth .= " ORDER BY dateobs "; 1414 1335 1415 my $warps = $db->selectall_arrayref( $input_sth ); 1416 1417 # Each comment should only appear once. Therefore, if we see it more than once, we assume the first is extra. 1418 my %comment_hash = (); 1419 foreach my $this_warp (@{ $warps }) { 1420 my $this_comment = ${ $this_warp }[3]; 1421 my $this_exp_id = ${ $this_warp }[0]; 1422 $comment_hash{$this_comment} = $this_exp_id; 1423 } 1336 1424 1337 1425 if (($#{ $warps } + 1) % 2 != 0) { 1338 print STDERR "diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps }\n"; 1339 next; 1426 print STDERR "diff_queue: Number of input warps to make diffs is not even for target $target and object $this_object! $#{ $warps } "; 1427 if ($#{ $warps} + 1 == 1) { 1428 print STDERR ": I can do no diffs with only one exposure.\n"; 1429 next; 1430 } 1431 else { 1432 print STDERR ": I should declare an exposure to be faulty.\n"; 1433 my @keep_warps = (); 1434 # print "@{ $warps }\n"; 1435 foreach my $this_warp (@{ $warps }) { 1436 my $this_comment = ${ $this_warp }[3]; 1437 my $this_exp_id = ${ $this_warp }[0]; 1438 if ($comment_hash{$this_comment} == $this_exp_id) { 1439 push @keep_warps, $this_warp; 1440 } 1441 else { 1442 print STDERR "diff_queue: excluding $this_exp_id for $this_object\n"; 1443 } 1444 } 1445 @{ $warps } = @keep_warps; 1446 # print "@{ $warps }\n"; 1447 } 1340 1448 } 1341 1449 1342 1450 while ($#{ $warps } > -1) { 1343 1451 my $input_warp = shift @{ $warps }; 1452 my $input_exp_id = ${ $input_warp }[0]; 1453 my $input_comment = ${ $input_warp }[3]; 1454 1455 1344 1456 my $template_warp = shift @{ $warps }; 1345 my $input_exp_id = ${ $input_warp }[0]; 1457 1346 1458 my $template_exp_id = ${ $template_warp }[0]; 1347 1459 1348 1460 my $input_warp_id = ${ $input_warp }[1]; 1349 1461 my $template_warp_id = ${ $template_warp }[1]; 1462 1463 my $input_warp_state = ${ $input_warp }[4]; 1464 my $template_warp_state = ${ $template_warp }[4]; 1350 1465 1466 $Npotential++; 1467 1468 unless (defined($input_warp_id) && defined($template_warp_id) && 1469 ($input_warp_state eq 'full')&&($template_warp_state eq 'full')) { 1470 print STDERR "Diff for this $date $target $input_exp_id $template_exp_id not fully processed\n"; 1471 next; 1472 } 1473 1351 1474 if (verify_uniqueness_diff($input_warp_id,$template_warp_id,$date,$target) != 0) { 1352 print STDERR "Diffs already queued for this $date $target $input_exp_id $template_exp_id\n"; 1475 $Nqueued++; 1476 print STDERR "Diffs already queued for this $date $target $input_exp_id $template_exp_id ($input_warp_id $template_warp_id) $this_object $input_comment\n"; 1353 1477 next; 1354 1478 } … … 1366 1490 $cmd .= ' -pretend '; 1367 1491 print STDERR "diff_queue: $cmd\n"; 1492 print STDERR " $input_warp_id $template_warp_id\n"; 1368 1493 } 1369 1494 … … 1375 1500 &my_die("Unable to perform difftool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1376 1501 } 1377 } 1378 } 1379 } 1502 $Nqueued++; 1503 } 1504 } 1505 } 1506 $metadata_out{nsDiffPotential} += $Npotential; 1507 $metadata_out{nsDiffQueued} += $Nqueued; 1508 # if (($metadata_out{nsDiffPotential} == $metadata_out{nsDiffQueued})&&($metadata_out{nsObservingState} eq 'END_OF_NIGHT')) { 1509 # $metadata_out{nsDiffState} = 'FINISHED_DIFFS'; 1510 # } 1511 1380 1512 } 1381 1513 … … 1493 1625 } 1494 1626 } 1495 1627 # print "$datetime $eon_dt\n"; 1496 1628 if (DateTime->compare($datetime,$eon_dt) < 1) { 1497 1629 return("OBSERVING"); … … 1501 1633 } 1502 1634 } 1635 1636 # This basically does the end of night check, but does it "the hard way," to prevent the time from fooling us. 1637 sub get_registration_state { 1638 my $date = shift; 1639 1640 foreach my $eon (keys %eon_config) { 1641 my $command = "$regtool -processedexp -simple "; 1642 $command .= " -dbname $dbname "; 1643 $command .= " -dateobs_begin ${date}T00:00:00 -dateobs_end ${date}T23:59:59 "; 1644 $command .= " -object $eon_config{$eon}{OBJECT} " if defined($eon_config{$eon}{OBJECT}); 1645 $command .= " -obs_mode $eon_config{$eon}{OBSMODE} " if defined($eon_config{$eon}{OBSMODE}); 1646 $command .= " -exp_type $eon_config{$eon}{EXPTYPE} " if defined($eon_config{$eon}{EXPTYPE}); 1647 $command .= " -comment $eon_config{$eon}{COMMENT} " if defined($eon_config{$eon}{COMMENT}); 1648 1649 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 1650 run ( command => $command, verbose => $verbose ); 1651 unless ($success) { 1652 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 1653 &my_die("Unable to perform regtool: $error_code", 0,0,$date, $PS_EXIT_SYS_ERROR); 1654 } 1655 my @eon_exposures = split /\n/, (join '', @$stdout_buf); 1656 if ($#eon_exposures >= 0) { 1657 return("REGISTERED"); 1658 } 1659 } 1660 return("NOT_REGISTERED"); 1661 } 1662 1663 1503 1664 1504 1665 sub get_tool_parameters { … … 1620 1781 my $stage = shift; # stage name 1621 1782 my $stage_id = shift; # identifier 1783 my $date = shift; 1622 1784 my $exit_code = shift; # Exit code 1623 # outputImage and path_base are globals1624 1785 1625 1786 carp($msg); -
branches/czw_branch/20101203/ippScripts/scripts/publish_file.pl
r30118 r30586 42 42 43 43 # Parse the command-line arguments 44 my ( $pub_id, $camera, $stage, $stage_id, $fileset, $format, $product, $workdir );44 my ( $pub_id, $camera, $stage, $stage_id, $fileset, $format, $product, $workdir, $need_magic ); 45 45 my ( $dbname, $verbose, $no_update, $no_op, $save_temps, $redirect ); 46 46 my ( $output_format ); … … 54 54 'fileset=s' => \$fileset, # Fileset name 55 55 'workdir=s' => \$workdir, # Working directory 56 'need-magic' => \$need_magic, # do we require censored detections? 56 57 'dbname=s' => \$dbname, # Database name 57 58 'verbose' => \$verbose, # Print to stdout … … 166 167 foreach my $comp ( @$components ) { 167 168 my $path_base = $comp->{path_base}; # Base name for file 169 if (!$need_magic and $comp->{magicked}) { 170 # This client is authorized to receive uncensored detections 171 # Get the uri for the "backup" files 172 print "Using uncensored input from $path_base\n"; 173 $path_base = $ipprc->destreaked_filename($path_base); 174 } 168 175 next if defined $comp->{quality} and $comp->{quality} > 0; 169 176 print "Warning: mis-matched comments\n" if defined $comment and $comment ne $comp->{comment}; … … 181 188 $filename = $ipprc->filename( "PSPHOT.OUT.CMF.MEF", "$path_base.pos" ); 182 189 } 183 $filename = $ipprc->file_resolve($filename); 190 &my_die("input file does not exist: $filename", $pub_id, $PS_EXIT_SYS_ERROR) if !$ipprc->file_exists($filename); 191 my $resolved = $ipprc->file_resolve($filename); 192 193 &my_die("unable to resolve input file: $filename", $pub_id, $PS_EXIT_SYS_ERROR) if !$resolved; 194 195 $filename = $resolved; 184 196 185 197 my $data = { zp => $zp, -
branches/czw_branch/20101203/ippScripts/scripts/register_exp.pl
r30047 r30586 348 348 if (defined $exp_id and not $no_update) { 349 349 my $command = "$regtool -addprocessedexp -exp_id $exp_id -fault $exit_code"; 350 $command .= " -exp_tag $exp_tag"; 351 $command .= " -exp_name UNKNOWN"; 352 $command .= " -inst UNKNOWN"; 353 $command .= " -telescope UNKNOWN"; 354 $command .= " -telescope UNKNOWN"; 355 $command .= " -filelevel UNKNOWN"; 350 356 $command .= " -hostname $host" if defined $host; 351 357 $command .= " -dbname $dbname" if defined $dbname; -
branches/czw_branch/20101203/ippScripts/scripts/register_imfile.pl
r30118 r30586 10 10 my $date = `date`; 11 11 print "\n\n"; 12 print "Starting script $0 on $host at $date\n\n"; 12 my $cmd_line = join ' ', @ARGV; 13 print "Starting script $0 $cmd_line on $host at $date\n\n"; 13 14 14 15 use vars qw( $VERSION ); … … 39 40 40 41 my ($cache, $exp_id, $tmp_class_id, $tmp_exp_name, $uri, $bytes, $md5sum, $dbname, $verbose, $no_update, $no_op, $logfile); 42 my ($sunrise, $sunset); 41 43 GetOptions( 42 44 'caches' => \$cache, … … 47 49 'bytes=s' => \$bytes, 48 50 'md5sum=s' => \$md5sum, 51 'sunrise=s' => \$sunrise, 52 'sunset=s' => \$sunset, 49 53 'dbname|d=s' => \$dbname, # Database name 50 54 'verbose' => \$verbose, # Print to stdout … … 54 58 ) or pod2usage( 2 ); 55 59 56 my $ipprc = PS::IPP::Config->new() or my_die ( "Unable to set up", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR ); # IPP configuration57 $ipprc->redirect_output($logfile) or my_die ( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile;60 my $ipprc = PS::IPP::Config->new() or my_die_for_add( "Unable to set up", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 61 $ipprc->redirect_output($logfile) or my_die_for_add( "Unable to redirect output", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_SYS_ERROR ) if $logfile; 58 62 59 63 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; … … 65 69 defined $uri; 66 70 71 unless (defined($sunset)) { 72 $sunset = '03:30:00'; 73 } 74 unless (defined($sunrise)) { 75 $sunrise = '17:30:00'; 76 } 67 77 68 78 my $RECIPE = "REGISTER"; # Recipe to use for ppStats … … 84 94 85 95 my $cmdflags; 86 my $burntoolStateGood; 96 my $burntoolStateTarget; 97 my $burntoolStateCurrent; 87 98 # Run ppStats on the input file 88 99 { … … 101 112 print "STDOUT:\n$out1"; 102 113 print "STDERR:\n$err1"; 103 &my_die ("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h1->result() or $PS_EXIT_PROG_ERROR) ) unless $result1;114 &my_die_for_add("Unable to perform ppStats on exposure id $exp_id: " . $h1->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h1->result() or $PS_EXIT_PROG_ERROR) ) unless $result1; 104 115 105 116 print "[Running " . join(' ', @command2) . "]\n"; … … 110 121 print "STDOUT:\n$out2"; 111 122 print "STDERR:\n$err2"; 112 &my_die ("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h2->result() or $PS_EXIT_PROG_ERROR) ) unless $result2;123 &my_die_for_add("Unable to perform ppStatsFromMetadata on exposure id $exp_id: " . $h2->result(), $exp_id, $tmp_exp_name, $tmp_class_id, $uri, ($h2->result() or $PS_EXIT_PROG_ERROR) ) unless $result2; 113 124 chomp $out2; 114 125 $cmdflags = $out2; 115 126 116 127 # Manually parse the burntool_state entry. 117 my $burntoolState= 0;128 $burntoolStateCurrent = 0; 118 129 my $isGPC1 = 0; 119 $burntoolState Good= 0;130 $burntoolStateTarget = 0; 120 131 foreach my $line (split /\n/, $out1) { 121 132 if ($line =~ /FPA.BURNTOOL.APPLIED/) { 122 133 $line =~ s/^\s+//; 123 $burntoolState = (split /\s+/, $line)[2];134 $burntoolStateCurrent = (split /\s+/, $line)[2]; 124 135 } 125 136 if ($line =~ /FPA.CAMERA/) { … … 131 142 } 132 143 if ($isGPC1 != 1) { 133 $burntoolState = 0; # If it's not GPC1, you shouldn't have run burntool.134 } 135 elsif (($isGPC1 == 1) && ($burntoolState == 1)) {136 # print STDERR "In the good region: >>$burntoolState <<\n";144 $burntoolStateCurrent = 0; # If it's not GPC1, you shouldn't have run burntool. 145 } 146 elsif (($isGPC1 == 1) && ($burntoolStateCurrent == 1)) { 147 # print STDERR "In the good region: >>$burntoolStateCurrent<<\n"; 137 148 my $ppConfigDump_cmd = "$ppConfigDump -camera GPC1 -dump-camera -"; 138 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 148 159 if ($line =~ /BURNTOOL.STATE.GOOD/) { 149 160 $line =~ s/^\s+//; 150 $burntoolState Good= (split /\s+/, $line)[2];161 $burntoolStateTarget = (split /\s+/, $line)[2]; 151 162 last; 152 163 } 153 164 } 154 $burntoolState = $burntoolStateGood; # Positive because this has the header table. 155 156 } 157 $cmdflags .= " -burntool_state $burntoolState "; 165 # XXX why was this being equated?? 166 # $burntoolState = $burntoolStateGood; # Positive because this has the header table. 167 168 } 169 $cmdflags .= " -burntool_state $burntoolStateTarget "; 158 170 } 159 171 160 172 $now_time = localtime(); 161 173 printf STDERR "\ndone with ppStats: %s\n", $now_time if $verbose; 174 printf STDERR "\nburntool state current: %d target: %d\n", $burntoolStateCurrent, $burntoolStateTarget; 162 175 163 176 # we require at a minimum: -telescope, -inst, -filelevel, -class_id, -exp_type 164 if (uc(&value_for_flag ($cmdflags, "NULL", "-telescope")) eq "NULL") { &my_die ("telescope not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 165 if (uc(&value_for_flag ($cmdflags, "NULL", "-inst")) eq "NULL") { &my_die ("inst not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 166 if (uc(&value_for_flag ($cmdflags, "NULL", "-filelevel")) eq "NULL") { &my_die ("filelevel not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 167 if (uc(&value_for_flag ($cmdflags, "NULL", "-class_id")) eq "NULL") { &my_die ("class_id not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 168 if (uc(&value_for_flag ($cmdflags, "NULL", "-exp_type")) eq "NULL") { &my_die ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 177 if (uc(&value_for_flag ($cmdflags, "NULL", "-telescope")) eq "NULL") { &my_die_for_add ("telescope not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 178 if (uc(&value_for_flag ($cmdflags, "NULL", "-inst")) eq "NULL") { &my_die_for_add ("inst not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 179 if (uc(&value_for_flag ($cmdflags, "NULL", "-filelevel")) eq "NULL") { &my_die_for_add ("filelevel not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 180 if (uc(&value_for_flag ($cmdflags, "NULL", "-class_id")) eq "NULL") { &my_die_for_add ("class_id not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 181 if (uc(&value_for_flag ($cmdflags, "NULL", "-exp_type")) eq "NULL") { &my_die_for_add ("exp_type not found", $exp_id, $tmp_exp_name, $tmp_class_id, $uri, $PS_EXIT_CONFIG_ERROR); } 182 my $dateobs = &value_for_flag($cmdflags, 0.0, "-dateobs"); 169 183 170 184 my $command = "$regtool -addprocessedimfile"; … … 177 191 $command .= " -hostname $host" if defined $host; 178 192 $command .= " -dbname $dbname" if defined $dbname; 179 $command .= " -data_state check_burntool"; 193 if (abs($burntoolStateCurrent) == $burntoolStateTarget) { 194 printf STDERR "This has already been burned.\n"; 195 $command .= " -data_state full"; 196 } 197 elsif (is_daytime($dateobs,$sunrise,$sunset)) { 198 printf STDERR "This is a daytime exposure.\n"; 199 $command .= " -data_state full"; 200 } 201 else { 202 printf STDERR "Need to check burntool.\n"; 203 $command .= " -data_state check_burntool"; 204 } 180 205 $command .= " $cmdflags"; 181 206 … … 187 212 my $ra = &value_for_flag($cmdflags, 0.0, "-ra"); 188 213 my $dec = &value_for_flag($cmdflags, 0.0, "-decl"); 189 my $dateobs = &value_for_flag($cmdflags, 0.0, "-dateobs"); 214 190 215 191 216 # if the needed data is available, pass it to sunmoon: … … 216 241 # lock file? 217 242 # if exp_type = DARK and date > MIDNIGHT HST { wait } 218 # system("ipp_apply_burntool.pl --class_id $class_id --dateobs_begin $date_start --dateobs_end $date_end --dbname gpc1 --logfile /data/$host.0/burntool_logs/$class_id.$start_date.log"); 243 # system("ipp_apply_burntool.pl --class_id $class_id --dateobs_begin $date_start --dateobs_end $date_end --dbname gpc1 --logfile /data/$host.0/burntool_logs/$class_id.$start_date.log"); 219 244 220 245 $now_time = localtime(); … … 236 261 # We now have an imfile in the database, check if we can burntool it. If not, continue on. 237 262 238 { 263 if ((abs($burntoolStateCurrent) != $burntoolStateTarget)&& 264 (!is_daytime($dateobs,$sunrise,$sunset))) { 239 265 my $mdcParser = PS::IPP::Metadata::Config->new; 240 266 … … 243 269 $check_date =~ s/T.*$//; 244 270 my $exp_name = $tmp_exp_name; 245 271 246 272 247 273 my $bt_check_command = "$regtool -checkburntoolimfile "; 248 274 $bt_check_command .= " -class_id $class_id "; 249 $bt_check_command .= " -date $check_date "; 250 $bt_check_command .= " -valid_burntool $burntoolStateGood "; 275 $bt_check_command .= " -dateobs_begin ${check_date}T${sunset} "; 276 $bt_check_command .= " -dateobs_end ${check_date}T${sunrise} "; 277 $bt_check_command .= " -valid_burntool $burntoolStateTarget "; 251 278 $bt_check_command .= " -exp_name $exp_name "; 252 279 $bt_check_command .= " -dbname $dbname" if defined $dbname; 253 280 254 281 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 255 run ( command => $bt_check_command, verbose => $verbose);282 run ( command => $bt_check_command, verbose => $verbose); 256 283 unless ($success) { 257 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);258 &my_die("Unable to perform regtool: $error_code", 259 $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR);284 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 285 &my_die_for_update("Unable to perform regtool: $error_code", 286 $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 260 287 } 261 288 … … 264 291 my $exposures; 265 292 while ( scalar @whole > 0 ) { 266 my $value = shift @whole;267 push @single, $value;268 if ($value =~ /^\s*END\s*$/) {269 push @single, "\n";270 271 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) );272 &my_die("Unable to parse output from regtool", 273 $class_id, $exp_name, $date, $PS_EXIT_SYS_ERROR) unless274 defined $list;275 push @{ $exposures }, @$list;276 @single = ();277 }278 } 279 293 my $value = shift @whole; 294 push @single, $value; 295 if ($value =~ /^\s*END\s*$/) { 296 push @single, "\n"; 297 298 my $list = parse_md_list( $mdcParser->parse( join( "\n", @single ) ) ); 299 &my_die_for_update("Unable to parse output from regtool", 300 $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless 301 defined $list; 302 push @{ $exposures }, @$list; 303 @single = (); 304 } 305 } 306 280 307 # We only care about the final entry, as that contains the exposure we are. 281 308 282 309 my $regtool_update = "$regtool -updateprocessedimfile "; 283 310 $regtool_update .= "-dbname $dbname " if defined $dbname; … … 286 313 my $burntool_data = pop(@{ $exposures }); 287 314 if ($burntool_data->{burnable} == 0) { 288 $regtool_update .= " -burntool_state 0 -set_state pending_burntool ";289 unless ($no_update) {290 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =291 IPC::Cmd::run(command => $regtool_update, verbose => $verbose);292 unless ($success) {293 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);294 warn ("Unable to perform regtool -addprocessedimfile: $error_code");295 exit($error_code);296 }297 } else {298 print "skipping command: $command\n";299 }315 $regtool_update .= " -burntool_state 0 -set_state pending_burntool "; 316 unless ($no_update) { 317 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 318 IPC::Cmd::run(command => $regtool_update, verbose => $verbose); 319 unless ($success) { 320 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 321 warn ("Unable to perform regtool -addprocessedimfile: $error_code"); 322 exit($error_code); 323 } 324 } else { 325 print "skipping command: $command\n"; 326 } 300 327 } 301 328 else { 302 my $apply_command = "$ippApplyBurntoolSingle --dbname $dbname ";303 $apply_command .= " --class_id $class_id --exp_id $exp_id ";304 $apply_command .= " --this_uri $burntool_data->{uri} ";305 $apply_command .= " --previous_uri $burntool_data->{previous_uri} " if defined $burntool_data->{previous_uri};306 $apply_command .= " --imfile_state $burntool_data->{imfile_state} ";307 $apply_command .= " --verbose " if $verbose;308 print "$apply_command\n";309 unless ($no_update) {310 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =311 IPC::Cmd::run(command => $apply_command, verbose => $verbose);312 unless ($success) {313 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);314 warn ("Unable to perform ipp_apply_burntool_single.pl: $error_code"); 315 exit($error_code);316 }317 }318 } 329 my $apply_command = "$ippApplyBurntoolSingle --dbname $dbname "; 330 $apply_command .= " --class_id $class_id --exp_id $exp_id "; 331 $apply_command .= " --this_uri $burntool_data->{uri} "; 332 $apply_command .= " --previous_uri $burntool_data->{previous_uri} " if defined $burntool_data->{previous_uri}; 333 $apply_command .= " --imfile_state $burntool_data->{imfile_state} "; 334 $apply_command .= " --verbose " if $verbose; 335 print "$apply_command\n"; 336 unless ($no_update) { 337 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 338 IPC::Cmd::run(command => $apply_command, verbose => $verbose); 339 unless ($success) { 340 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 341 &my_die_for_update("Unable to perform ipp_apply_burntool_single.pl: $error_code", 342 $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 343 } 344 } 345 } 319 346 320 347 … … 353 380 } 354 381 355 sub my_die 382 sub is_daytime 383 { 384 my $dateobs = shift; 385 my $sunset = shift; 386 my $sunrise = shift; 387 388 my ($date,$time); 389 390 if ($dateobs =~ /T/) { 391 ($date,$time) = split /T/, $dateobs; 392 } 393 else { 394 ($date,$time) = split / /, $dateobs; 395 } 396 my ($hour,$minute,$second) = split /\:/, $time; # /; 397 my ($ss_hour,$ss_minute,$ss_second) = split /\:/, $sunset; # /; 398 my ($sr_hour,$sr_minute,$sr_second) = split /\:/, $sunrise; # /; 399 if ($second =~ /Z/) { 400 $second =~ s/Z//; 401 } 402 # print "this exposure: $hour $minute $second\n"; 403 # print "sunset: $ss_hour $ss_minute $ss_second\n"; 404 # print "sunrise: $sr_hour $sr_minute $sr_second\n"; 405 # printf "Hss: %d Mss: %d Sss: %d\n",($hour >= $ss_hour),($minute >= $ss_minute),($second >= $ss_second); 406 # printf "Hsr: %d Msr: %d Ssr: %d\n",($hour <= $sr_hour),($minute <= $sr_minute),($second <= $sr_second); 407 408 if (($hour > $ss_hour)&&($hour <= 24)) { 409 return(1); # After sunset by more than an hour, before midnight 410 } 411 elsif ($hour == $ss_hour) { 412 if ($minute > $ss_minute) { 413 return(1); # After sunset by more than a minute 414 } 415 elsif ($minute == $ss_minute) { 416 if ($second >= $ss_second) { 417 return(1); # After sunset by more than a second 418 } 419 else { 420 return(0); 421 } 422 } 423 else { 424 return(0); 425 } 426 } 427 elsif (($hour < $sr_hour)&&($hour >= 0)) { 428 return(1); # Before sunrise by more than an hour, but after midnight 429 } 430 elsif ($hour == $sr_hour) { 431 if ($minute < $sr_minute) { 432 return(1); # Before sunrise by more than a minute 433 } 434 elsif ($minute == $sr_minute) { 435 if ($second <= $sr_second) { 436 return(1); # Before sunrise by more than a second 437 } 438 else { 439 return(0); 440 } 441 } 442 else { 443 return(0); 444 } 445 } 446 else { 447 return(0); # We should never get here. 448 } 449 } 450 451 sub my_die_for_add 356 452 { 357 453 my $msg = shift; # Warning message on die … … 384 480 exit $exit_code; 385 481 } 482 sub my_die_for_update 483 { 484 my $msg = shift; # Warning message on die 485 my $exp_id = shift; 486 my $class_id = shift; 487 my $exit_code = shift; 488 489 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 490 491 carp($msg); 492 if (defined $exp_id && defined $tmp_class_id and not $no_update) { 493 my $command = "$regtool -updateprocessedimfile"; 494 $command .= " -exp_id $exp_id"; 495 $command .= " -class_id $class_id"; 496 $command .= " -fault $exit_code"; 497 $command .= " -hostname $host" if defined $host; 498 $command .= " -dbname $dbname" if defined $dbname; 499 print "Running: $command\n"; 500 system($command); 501 } 502 exit $exit_code; 503 } 386 504 387 505 # Pau.
Note:
See TracChangeset
for help on using the changeset viewer.
