Changeset 32785 for trunk/pstamp/scripts/pstamp_get_image_job.pl
- Timestamp:
- Nov 23, 2011, 1:46:37 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_get_image_job.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_get_image_job.pl
r30663 r32785 25 25 26 26 my $output_base; 27 my $bundleroot; 27 28 28 29 my $verbose; 29 my $i pprc;30 my $imagedbname; 30 31 my $dbname; 31 32 my $dbserver; … … 41 42 'rownum=s' => \$rownum, 42 43 'output_base=s' => \$output_base, 44 'bundleroot=s' => \$bundleroot, 45 'imagedbname=s' => \$imagedbname, 43 46 'dbname=s' => \$dbname, 44 47 'dbserver=s' => \$dbserver, … … 52 55 53 56 my_die( $err, $PS_EXIT_PROG_ERROR) if $err; 57 58 my $ipprc = PS::IPP::Config->new(); 54 59 55 60 my $params_file = $output_base . ".mdc"; … … 91 96 my $missing_tools; 92 97 my $dist_bundle = can_run('dist_bundle.pl') or (warn "Can't find dist_bundle.pl" and $missing_tools = 1); 98 my $pstamptool = can_run('pstamptool') or (warn "Can't find pstamptool" and $missing_tools = 1); 93 99 if ($missing_tools) { 94 100 warn("Can't find required tools."); … … 96 102 } 97 103 104 $pstamptool .= " -dbname $dbname" if $dbname; 105 $pstamptool .= " -dbserver $dbserver" if $dbserver; 106 98 107 my $outdir = dirname($output_base); 99 108 my $basename = basename($path_base); 100 my $outroot = $output_base ."_" . $basename;101 109 my $results_file = $output_base . ".bundle_results"; 110 my $outroot; 111 if ($bundleroot) { 112 my (undef, undef, undef, $mday, $month, $year) = gmtime(time()); 113 $month += 1; 114 $year += 1900; 115 116 # This will generate an outroot like: 117 # neb://any/pstamp/bundles/2011/11/22/14026916_1_1_o5739g0358o.353654.wrp.215092.skycell.2083.025 118 119 $outroot = $bundleroot . sprintf("/%4d/%02d/%02d/${job_id}_", $year, $month, $mday) . basename($output_base) . "_". $basename; 120 } else { 121 $outroot = $output_base ."_" . $basename; 122 } 102 123 103 124 { … … 105 126 $command .= " --results_file $results_file"; 106 127 $command .= " --component $component --path_base $path_base --outroot $outroot"; 107 # XXX: we need to do some work if we want to support muggle bundles108 # $command .= " --no_magic if $no_magic";128 # XXX: we need to do some work if we want to support muggle bundles 129 # $command .= " --no_magic if $no_magic"; 109 130 $command .= " --magicked" if $magicked; 110 $command .= " --dbname $ dbname" if $dbname;131 $command .= " --dbname $imagedbname" if $imagedbname; 111 132 $command .= " --verbose" if $verbose; 112 133 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 147 168 } 148 169 170 if ($bundleroot) { 171 { 172 # delete any existing pstampFile in case this job has faulted and 173 # been reverted 174 my $command = "$pstamptool -deletefile -job_id $job_id"; 175 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 176 run(command => $command, verbose => $verbose); 177 unless ($success) { 178 my_die("Unable to perform $command: $error_code", $error_code >> 8); 179 } 180 } 181 my $linkname = "$outdir/$file_name"; 182 if (-l $linkname or -e $linkname) { 183 unlink $linkname or my_die("Failed to unlink existing symlink: $linkname", $PS_EXIT_UNKNOWN_ERROR); 184 } 185 my $bundle_name = dirname($outroot) . "/$file_name"; 186 my $resolved = $ipprc->file_resolve($bundle_name); 187 if (!$resolved) { 188 my_die("failed to resolve $bundle_name", $PS_EXIT_UNKNOWN_ERROR); 189 } 190 symlink $resolved, $linkname or my_die("failed to create symlink to $resolved in $outdir", 191 $PS_EXIT_UNKNOWN_ERROR); 192 193 my $command = "$pstamptool -addfile -job_id $job_id -path $bundle_name"; 194 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 195 run(command => $command, verbose => $verbose); 196 unless ($success) { 197 my_die("Unable to perform $command: $error_code", $error_code >> 8); 198 } 199 } 200 201 149 202 print REGLIST "$file_name|$bytes|$md5sum|tgz|\n"; 150 203
Note:
See TracChangeset
for help on using the changeset viewer.
