Changeset 9502
- Timestamp:
- Oct 11, 2006, 5:01:10 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/phase0_exp.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/phase0_exp.pl
r9446 r9502 4 4 use strict; 5 5 6 use Cache::File; 7 use Storable qw( freeze thaw ); 8 use File::Basename qw( basename ); 6 9 use IPC::Cmd qw( can_run run ); 7 10 use PS::IPP::Metadata::Config; 8 11 use PS::IPP::Metadata::List qw( parse_md_list ); 9 12 use Statistics::Descriptive; 10 use Data::Dumper;11 13 12 14 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); 13 15 use Pod::Usage qw( pod2usage ); 14 16 15 my ($ exptag, $no_update);17 my ($cache, $exptag, $no_update); 16 18 17 19 GetOptions( 18 'exp_tag|e=s' => \$exptag, 20 'caches' => \$cache, 21 'exp_tag|e=s' => \$exptag, 19 22 'no-update' => \$no_update 20 23 ) or pod2usage( 2 ); … … 70 73 die "Can't find required tools.\n" if $missing_tools; 71 74 75 # setup cache interface 76 77 my $c = Cache::File->new( 78 cache_root => File::Spec->catdir($ENV{'HOME'}, '.', basename($0)), 79 default_expires => '7200 sec', 80 ); 81 72 82 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 73 83 … … 77 87 my $command = "$p0tool -rawimfile -exp_tag $exptag"; 78 88 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 79 run(command => $command, verbose => 1);89 cache_run(command => $command, verbose => 1); 80 90 die "Unable to perform p0tool on exposure id $exptag: $error_code\n" if not $success; 81 91 my $metadata = $mdcParser->parse(join "", @$stdout_buf) … … 159 169 160 170 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 161 run(command => \@command, verbose => 1);171 cache_run(command => \@command, verbose => 1); 162 172 die "Unable to run phase0 update for $exptag: $error_code\n" if not $success; 163 173 } … … 176 186 } 177 187 178 END { system("sync") == 0 or die "failed to execute sync: $!" } 188 sub cache_run 189 { 190 my %p = @_; 191 192 my $cmd_output = $c->get($p{command}) if $cache; 193 if (defined $cmd_output) { 194 return @{thaw $cmd_output}; 195 } else { 196 my @output = run(%p); 197 $c->set($p{command}, freeze \@output) if $cache; 198 return @output; 199 } 200 } 201 202 END { 203 my $exit = $?; 204 system("sync") == 0 or die "failed to execute sync: $!"; 205 $? = $exit; 206 } 207
Note:
See TracChangeset
for help on using the changeset viewer.
