Changeset 25027 for branches/pap/ippScripts/scripts/dist_advancerun.pl
- Timestamp:
- Aug 7, 2009, 4:08:25 PM (17 years ago)
- Location:
- branches/pap
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/dist_advancerun.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pap
- Property svn:mergeinfo changed
-
branches/pap/ippScripts/scripts/dist_advancerun.pl
r23874 r25027 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use File::Temp qw( tempfile ); 18 use File::Basename qw( basename);18 use File::Basename qw( dirname); 19 19 use PS::IPP::Metadata::Config; 20 20 use PS::IPP::Metadata::List qw( parse_md_list ); … … 72 72 73 73 my $tool_cmd; 74 my $list_mode; 75 my $component_key; 74 76 if ($stage eq "raw") { 75 77 $tool_cmd = "$regtool -exp_id"; 78 $list_mode = "-processedimfile"; 79 $component_key = "class_id"; 76 80 } elsif ($stage eq "chip") { 77 81 $tool_cmd = "$chiptool -chip_id"; 82 $list_mode = "-processedimfile"; 83 $component_key = "class_id"; 78 84 } elsif ($stage eq "camera") { 79 85 $tool_cmd = "$camtool -cam_id"; 86 $list_mode = "-processedexp"; 87 $component_key = ""; 80 88 } elsif ($stage eq "fake") { 81 89 $tool_cmd = "$faketool -fake_id"; 90 $list_mode = "-processedimfile"; 91 $component_key = "class_id"; 82 92 } elsif ($stage eq "warp") { 83 93 $tool_cmd = "$warptool -warp_id"; 94 $list_mode = "-warped"; 95 $component_key = "skycell_id"; 84 96 } elsif ($stage eq "stack") { 85 97 $tool_cmd = "$stacktool -stack_id"; 98 $list_mode = "-sumskyfile"; 99 $component_key = "skycell_id"; 86 100 } elsif ($stage eq "diff") { 87 101 $tool_cmd = "$difftool -diff_id"; 102 $list_mode = "-diffskyfile"; 103 $component_key = "skycell_id"; 88 104 } else { 89 105 &my_die("Unexpected stage: $stage", $dist_id, $PS_EXIT_CONFIG_ERROR); 90 106 } 91 107 108 $tool_cmd .= " $stage_id"; 109 92 110 # XXX should we create a file rule for this? 93 my $ outfile = "$outdir/dbinfo.$stage.$stage_id.mdc";94 95 { 96 my $command = "$tool_cmd $stage_id -exportrun -outfile $outfile";97 $command .= " -clean" if defined $clean;111 my $dbinfo_file = "$outdir/dbinfo.$stage.$stage_id.mdc"; 112 113 { 114 my $command = "$tool_cmd -exportrun -outfile $dbinfo_file"; 115 $command .= " -clean" if ((defined $clean) and ($stage ne "raw")); 98 116 $command .= " -dbname $dbname" if defined $dbname; 99 117 … … 105 123 } 106 124 } 107 108 # set distRun.stage = 'full' 109 { 110 my $command = "$disttool -updaterun -dist_id $dist_id -set_state full"; 125 my $dirinfo = "$outdir/dirinfo.$stage.$stage_id.mdc"; 126 { 127 my $command = "$tool_cmd $list_mode"; 111 128 $command .= " -dbname $dbname" if defined $dbname; 112 129 … … 117 134 &my_die("Unable to perform $command: $error_code", $dist_id, $error_code); 118 135 } 136 if (@$stdout_buf == 0) { 137 &my_die("Unable to perform $command: $error_code", $dist_id, $error_code); 138 } 139 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 140 &my_die("Unable to parse metadata config doc", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 141 my $components = parse_md_list($metadata) or 142 &my_die("Unable to parse metadata list", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 143 144 open MANIFEST, ">$dirinfo" or 145 &my_die("Unable to open dirinfo file $dirinfo", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 146 147 my $destdir; 148 foreach my $c (@$components) { 149 # take the workdir from the first component 150 if (!$destdir) { 151 my $workdir = $c->{workdir}; 152 if ($workdir) { 153 $destdir = stripvolume($workdir, $stage); 154 } elsif ($stage eq 'raw') { 155 $destdir = 'none'; 156 } else { 157 &my_die("workdir not found for open dirinfo file $dirinfo", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 158 } 159 print MANIFEST "destdir METADATA\n"; 160 print MANIFEST "\t" , "destdir", "\tSTR\t", $destdir, "\n"; 161 print MANIFEST "END\n\n"; 162 print MANIFEST "components METADATA\n"; 163 } 164 my $component = $c->{$component_key} ? $c->{$component_key} : "exposure"; 165 my $path; 166 if ($stage eq 'raw') { 167 $path = $c->{uri}; 168 } else { 169 $path = $c->{path_base}; 170 } 171 &my_die("unable to find path", $dist_id, $PS_EXIT_UNKNOWN_ERROR) if !$path; 172 my $component_dir = find_componentdir($destdir, $path); 173 # print MANIFEST "$component METADATA\n"; 174 print MANIFEST "\t" , "$component", "\tSTR\t", $component_dir, "\n"; 175 } 176 print MANIFEST "END\n\n"; 177 close MANIFEST or 178 &my_die("Unable to close dirinfo file $dirinfo", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 179 } 180 181 { 182 my $command = "$disttool -updaterun -dist_id $dist_id -set_state full"; 183 $command .= " -dbname $dbname" if defined $dbname; 184 185 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 186 run(command => $command, verbose => $verbose); 187 unless ($success) { 188 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 189 &my_die("Unable to perform $command: $error_code", $dist_id, $error_code); 190 } 119 191 } 120 192 … … 124 196 ### Pau. 125 197 198 sub stripvolume 199 { 200 my $path = shift; 201 my $stage = shift; 202 my @segments; 203 204 # workdir isn't what we want for raw stage 205 return "none" if ($stage and ($stage eq 'raw')); 206 207 my $scheme = file_scheme($path); 208 my $tail; 209 if ($scheme) { 210 # strip off scheme:// 211 $tail = substr($path, length($scheme) + 3); 212 } elsif (substr($path, 0, 1) eq '/') { 213 $tail = substr($path, 1); 214 $scheme = ""; 215 } 216 # remove any leading / that are left 217 while ((substr($tail, 0, 1) eq '/')) { 218 $tail = substr($tail, 1); 219 } 220 221 if (($scheme eq 'neb') or ($scheme eq 'path')) { 222 my $volume; 223 ($volume, @segments) = split '/', $tail; 224 225 } elsif (!$scheme or ($scheme eq 'file')) { 226 227 # XXX Here we're assuming the /data/ipp??? structure. This won't be true when data is forwarded 228 # by remote sites. We need a way to configure this 229 my $volume; 230 231 # data/ippxxx/dirs 232 (undef, $volume, @segments) = split '/', $tail; 233 } else { 234 die( "unexpected workdir value: $path\n"); 235 } 236 237 return caturi(@segments); 238 } 239 240 sub find_componentdir 241 { 242 my $destdir = shift; 243 my $path = shift; 244 245 my $result; 246 if ($destdir eq 'none') { 247 $result = stripvolume($path); 248 } else { 249 # find location of destdir in the path 250 my $i = index($path, $destdir); 251 252 $result = substr($path, $i + length($destdir) + 1); 253 254 while (substr($result, 0, 1) eq '/') { 255 $result = substr($result, 1); 256 } 257 } 258 return dirname($result); 259 } 126 260 127 261 sub my_die
Note:
See TracChangeset
for help on using the changeset viewer.
