Changeset 9501 for trunk/ippScripts/scripts/phase0_imfile.pl
- Timestamp:
- Oct 11, 2006, 4:41:30 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/phase0_imfile.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/phase0_imfile.pl
r9492 r9501 7 7 $VERSION = '0.01'; 8 8 9 use Cache::File; 10 use Storable qw(freeze thaw); 11 use File::Basename qw( basename); 9 12 use IPC::Cmd qw( can_run run ); 10 13 use PS::IPP::Metadata::Config; 11 14 use PS::IPP::Metadata::Stats; 12 use Storabe qw( freeze thaw );13 use Data::Dumper;14 15 15 16 use PS::IPP::Config; … … 20 21 use Pod::Usage qw( pod2usage ); 21 22 22 my ($ exp_tag, $class_id, $uri, $no_update);23 my ($cache, $exp_tag, $class_id, $uri, $no_update); 23 24 24 25 GetOptions( 25 'exp_tag|e=s' => \$exp_tag, 26 'caches' => \$cache, 27 'exp_tag|e=s' => \$exp_tag, 26 28 'class_id|i=s' => \$class_id, 27 29 'uri|u=s' => \$uri, … … 75 77 die "Can't find required tools.\n" if $missing_tools; 76 78 79 # setup cache interface 80 81 my $c = Cache::File->new( 82 cache_root => File::Spec->catdir($ENV{'HOME'}, '.pxtools', basename($0)), 83 default_expires => '7200 sec', 84 ); 85 77 86 # Resolve the input URI 78 87 $uri = File::Spec->rel2abs( $uri, $ipprc->workdir() ); … … 83 92 my $command = "$ppStats $uri -recipe PPSTATS " . RECIPE; # Command to run ppStats 84 93 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 85 run(command => $command, verbose => 1); 86 die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n" if not $success; 94 cache_run(command => $command, verbose => 1); 95 die "Unable to perform ppStats on exposure id $exp_tag: $error_code\n" 96 if not $success; 87 97 88 98 # Parse the output … … 123 133 } 124 134 135 sub cache_run 136 { 137 my %p = @_; 138 139 my $cmd_output = $c->get($p{command}) if $cache; 140 if (defined $cmd_output) { 141 return @{thaw $cmd_output}; 142 } else { 143 my @output = run(%p); 144 $c->set($p{command}, freeze \@output) if $cache; 145 return @output; 146 } 147 } 148 125 149 # Pau. 126 150
Note:
See TracChangeset
for help on using the changeset viewer.
