Changeset 18543
- Timestamp:
- Jul 15, 2008, 10:09:05 AM (18 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
r16959 r18543 15 15 use File::Copy; 16 16 use File::Basename; 17 use Digest::MD5::File qw( file_md5_hex ); 17 18 18 19 use PS::IPP::Config qw($PS_EXIT_SUCCESS … … 35 36 my $verbose = 1; 36 37 my $ipprc; 38 my $dbname; 39 my $job_id; 40 my $rownum; 37 41 38 42 # … … 41 45 42 46 GetOptions( 47 'job_id=s' => \$job_id, 48 'rownum=s' => \$rownum, 43 49 'uri=s' => \$uri, 44 50 'out_dir=s' => \$out_dir, 51 'dbname=s' => \$dbname, 45 52 ) or pod2usage(2); 46 53 47 54 my $err = ""; 55 $err .= "--job_id is required\n" if (!$job_id); 56 $err .= "--rownum is required\n" if (!$rownum); 57 $err .= "--uri is required to specify the file list\n" if (!$uri); 58 $err .= "--out_dir is required to specify the output fileset\n" if (!$out_dir); 48 59 49 if (!$uri) { 50 die("--uri is required to specify the file list"); 51 } 52 if (!$out_dir) { 53 die("--out_dir is required to specify the output fileset"); 54 } 60 die $err if $err; 55 61 56 62 # collapse any multiple slashes in output_dir … … 89 95 90 96 my $reglist = "$out_dir/reglist"; 91 if (! open(REGLIST, ">$reglist ") ) {97 if (! open(REGLIST, ">$reglist$job_id") ) { 92 98 die("failed to open registration list: $reglist"); 93 99 } 94 100 95 101 my @files; 102 my $num = 0; 96 103 while (<INPUT>) { 97 104 chomp; 98 105 my @fields = split /\|/; 99 106 my $pathname = shift @fields; 100 101 #my ($volume, $directories, $filename) = File::Spec->splitpath($pathname); 107 my $filetype = shift @fields; 102 108 103 109 ($pathname , my $filename) = resolvepath($pathname); … … 107 113 } 108 114 109 if (! symlink $pathname, "$out_dir/$filename" ) { 110 die("failed trying to create symlink to $pathname in $out_dir"); 115 $num++; 116 $filename = "${rownum}_${num}_$filename"; 117 my $dest_path = "$out_dir/$filename"; 118 if (! copy $pathname, "$dest_path" ) { 119 die("failed trying to copy $pathname to $out_dir"); 111 120 } 112 121 113 print REGLIST "$filename|"; 122 # XXX is pstamp always the right file type, if not where can we get the right one? 123 print REGLIST file_registration_line($filename, $dest_path, $filetype); 124 114 125 foreach my $f (@fields) { 115 126 print REGLIST "$f|"; … … 120 131 close(REGLIST); 121 132 122 #only thing left to do is register the fileset 123 exec "dsreg < $reglist --add --product $product --fileset $fileset --type PSRESULTS"; 124 133 exit 0; 125 134 126 135 sub resolvepath { … … 139 148 return ($pathname, $file); 140 149 } 150 151 # XXX move this to a module so the code can be shared 152 sub file_registration_line { 153 my $filename = shift; 154 my $path = shift; 155 my $filetype = shift; 156 if (-e $path) { 157 my @finfo = stat($path); 158 die "failed to stat $path" unless (@finfo); # XXX clean up 159 my $bytes = $finfo[7]; 160 my $md5sum = file_md5_hex($path); 161 162 return "$filename|$bytes|$md5sum|$filetype|"; 163 } else { 164 die "$filename not found at $path"; 165 } 166 }
Note:
See TracChangeset
for help on using the changeset viewer.
