Changeset 24125 for trunk/ippScripts/scripts/dist_advancerun.pl
- Timestamp:
- May 9, 2009, 2:19:48 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/dist_advancerun.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/dist_advancerun.pl
r23874 r24125 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";111 my $dbinfo_file = "$outdir/dbinfo.$stage.$stage_id.mdc"; 112 113 { 114 my $command = "$tool_cmd -exportrun -outfile $dbinfo_file"; 97 115 $command .= " -clean" if defined $clean; 98 116 $command .= " -dbname $dbname" if defined $dbname; … … 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 if (!$destdir) { 150 my $workdir = $c->{workdir}; 151 if ($workdir) { 152 $destdir = stripvolume($workdir, $stage); 153 } elsif ($stage eq 'raw') { 154 $destdir = 'none'; 155 } else { 156 &my_die("workdir not found for open dirinfo file $dirinfo", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 157 } 158 print MANIFEST "destdir METADATA\n"; 159 print MANIFEST "\t" , "destdir", "\tSTR\t", $destdir, "\n"; 160 print MANIFEST "END\n\n"; 161 print MANIFEST "components METADATA\n"; 162 } 163 my $component = $c->{$component_key} ? $c->{$component_key} : "exposure"; 164 my $path; 165 if ($stage eq 'raw') { 166 $path = $c->{uri}; 167 } else { 168 $path = $c->{path_base}; 169 } 170 &my_die("unable to find path", $dist_id, $PS_EXIT_UNKNOWN_ERROR) if !$path; 171 my $component_dir = find_componentdir($destdir, $path); 172 # print MANIFEST "$component METADATA\n"; 173 print MANIFEST "\t" , "$component", "\tSTR\t", $component_dir, "\n"; 174 } 175 print MANIFEST "END\n\n"; 176 close MANIFEST or 177 &my_die("Unable to close dirinfo file $dirinfo", $dist_id, $PS_EXIT_UNKNOWN_ERROR); 178 } 179 180 { 181 my $command = "$disttool -updaterun -dist_id $dist_id -set_state full"; 182 $command .= " -dbname $dbname" if defined $dbname; 183 184 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 185 run(command => $command, verbose => $verbose); 186 unless ($success) { 187 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 188 &my_die("Unable to perform $command: $error_code", $dist_id, $error_code); 189 } 119 190 } 120 191 … … 124 195 ### Pau. 125 196 197 sub stripvolume 198 { 199 my $path = shift; 200 my $stage = shift; 201 my @segments; 202 203 # workdir isn't what we want for raw stage 204 return "none" if ($stage and ($stage eq 'raw')); 205 206 my $scheme = file_scheme($path); 207 my $tail; 208 if ($scheme) { 209 # strip off scheme:// 210 $tail = substr($path, length($scheme) + 3); 211 } elsif (substr($path, 0, 1) eq '/') { 212 $tail = substr($path, 1); 213 $scheme = ""; 214 } 215 # remove any leading / that are left 216 while ((substr($tail, 0, 1) eq '/')) { 217 $tail = substr($tail, 1); 218 } 219 220 if (($scheme eq 'neb') or ($scheme eq 'path')) { 221 my $volume; 222 ($volume, @segments) = split '/', $tail; 223 224 } elsif (!$scheme or ($scheme eq 'file')) { 225 226 # XXX Here we're assuming the /data/ipp??? structure. This won't be true when data is forwarded 227 # by remote sites. We need a way to configure this 228 my $volume; 229 230 # data/ippxxx/dirs 231 (undef, $volume, @segments) = split '/', $tail; 232 } else { 233 die( "unexpected workdir value: $path\n"); 234 } 235 236 return caturi(@segments); 237 } 238 239 sub find_componentdir 240 { 241 my $destdir = shift; 242 my $path = shift; 243 244 my $result; 245 if ($destdir eq 'none') { 246 $result = stripvolume($path); 247 } else { 248 # find location of destdir in the path 249 my $i = index($path, $destdir); 250 251 $result = substr($path, $i + length($destdir) + 1); 252 253 while (substr($result, 0, 1) eq '/') { 254 $result = substr($result, 1); 255 } 256 } 257 return dirname($result); 258 } 126 259 127 260 sub my_die
Note:
See TracChangeset
for help on using the changeset viewer.
