Changeset 18544
- Timestamp:
- Jul 15, 2008, 10:11:04 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_job_run.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_job_run.pl
r18235 r18544 11 11 use Sys::Hostname; 12 12 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 13 use File::Basename; 14 use Digest::MD5::File qw( file_md5_hex ); 15 16 # values for OPTION_MASK 17 # XXX put these in a module 18 use constant PSTAMP_SELECT_IMAGE => 1; 19 use constant PSTAMP_SELECT_MASK => 2; 20 use constant PSTAMP_SELECT_WEIGHT => 4; 21 13 22 14 23 my $verbose; … … 92 101 } 93 102 103 my $rownum = $psjob->{rownum}; 94 104 my $uri = $psjob->{uri}; 95 105 my $outputBase = $psjob->{outputBase}; … … 105 115 106 116 if ($success) { 117 # XXX shouldn't need to do this, review schema` 118 my $dir = dirname($outputBase); 119 120 my $reglist = "$dir/reglist$job_id"; 121 122 open F, ">$reglist" or die "can't open $reglist for output"; 123 124 # we are assuming an interface with ppstamp here. 125 my @extensions = ( "fits", "mk.fits", "wt.fits"); 126 127 # XXX TODO: add mask of expected file types to pstampJob so we know what to expect 128 129 my $output_mask = PSTAMP_SELECT_IMAGE; 130 my $m = 1; # XXX we're getting a bit intimate with the bit field definitions here. do better use a hash 131 foreach my $extension (@extensions) { 132 my $do_this_one = $m & $output_mask; 133 $m = $m << 1; 134 next if (! $do_this_one); 135 136 my $basename = basename($outputBase); 137 138 my $filename = "${basename}.${extension}"; 139 my $path = "${outputBase}.${extension}"; 140 141 # XXX is pstamp always the right file type, if not where can we get the right one? 142 print F file_registration_line($filename, $path, "pstamp") . "\n"; 143 } 144 145 close F; 107 146 $jobStatus = $PS_EXIT_SUCCESS; 108 147 } else { … … 111 150 } 112 151 } elsif ($jobType eq "get_image") { 113 my $command = "$pstamp_get_image_job -- uri $uri --out_dir $outputBase";114 $command .= " - dbname $dbname" if $dbname;152 my $command = "$pstamp_get_image_job --job_id $job_id --uri $uri --out_dir $outputBase --rownum $rownum"; 153 $command .= " --dbname $dbname" if $dbname; 115 154 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 116 155 run(command => $command, verbose => $verbose); … … 126 165 } 127 166 128 129 167 # stop the job and set the result value 130 168 { 131 my $command = "$pstamptool -processedjob -job_id $job_id -state stop - result $jobStatus";169 my $command = "$pstamptool -processedjob -job_id $job_id -state stop -fault $jobStatus"; 132 170 $command .= " -dbname $dbname" if $dbname; 133 171 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 139 177 140 178 exit $jobStatus; 179 180 # XXX move this to a module so it can be shared 181 sub file_registration_line { 182 my $filename = shift; 183 my $path = shift; 184 my $filetype = shift; 185 if (-e $path) { 186 my @finfo = stat($path); 187 die "failed to stat $path" unless (@finfo); # XXX clean up 188 my $bytes = $finfo[7]; 189 my $md5sum = file_md5_hex($path); 190 191 return "$filename|$bytes|$md5sum|$filetype|"; 192 } else { 193 die "$filename not found at $path"; 194 } 195 }
Note:
See TracChangeset
for help on using the changeset viewer.
