Changeset 32374
- Timestamp:
- Sep 8, 2011, 2:12:04 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
-
PS-IPP-Config/lib/PS/IPP/Config.pm (modified) (3 diffs)
-
ippScripts/scripts/chip_imfile.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-Config/lib/PS/IPP/Config.pm
r31907 r32374 20 20 use Getopt::Long 2.33 qw( GetOptions :config gnu_getopt pass_through ); # Set pass_through so we don't kill @ARGV 21 21 use IPC::Cmd 0.36 qw( can_run run ); 22 use POSIX qw( strftime ); 22 23 23 24 use base qw( Exporter Class::Accessor::Fast ); … … 692 693 } 693 694 695 696 694 697 # redirect stderr and stdout streams to a file 695 698 sub redirect_output … … 722 725 723 726 return 1; 727 } 728 729 # redirect stderr and stdout streams to log file. If file already exists rename it and record 730 # the name in the new log file. 731 sub redirect_to_logfile { 732 my $self = shift; 733 my $name = shift; 734 735 my $tstring = strftime "%Y%m%dT%H%M", gmtime; 736 737 my $old_name; 738 my $scheme = file_scheme($name); 739 if ($scheme eq 'neb') { 740 my $neb = $self->nebulous; 741 if ($neb->storage_object_exists($name)) { 742 eval { 743 $old_name = "$name.$tstring"; 744 $neb->move($name, $old_name); 745 }; 746 if ($@) { 747 carp "nebulous move failed for $name"; 748 return undef; 749 } 750 } 751 } else { 752 if ($self->file_exists($name)) { 753 my $resolved = $self->file_resolve($name); 754 $old_name = "$resolved.$tstring"; 755 if (!rename($resolved, $old_name)) { 756 carp "Failed to rename $resolved $old_name"; 757 return undef; 758 } 759 } 760 } 761 my $result = $self->redirect_output($name); 762 if ($result and $old_name) { 763 print "\nPrevious log file moved to $old_name\n"; 764 } 765 return $result; 724 766 } 725 767 -
trunk/ippScripts/scripts/chip_imfile.pl
r32355 r32374 44 44 my ( $exp_id, $chip_id, $class_id, $chip_imfile_id, $uri, $camera, $outroot, $dbname, $run_state, $reduction, $threads, $verbose, 45 45 $no_update, $save_temps, $no_op, $redirect, $magicked, $deburned ); 46 47 my $zaplog = 0;48 46 49 47 GetOptions( … … 65 63 'no-op' => \$no_op, # Don't do any operations? 66 64 'redirect-output' => \$redirect, 67 'zaplog' => \$zaplog,68 65 'save-temps' => \$save_temps, # Save temporary files? 69 66 ) or pod2usage( 2 ); … … 92 89 } 93 90 94 my ($log Dest, $traceDest);91 my ($logRule, $traceDest); 95 92 if ($run_state eq 'new') { 96 $log Dest = prepare_output("LOG.IMFILE", $outroot, $class_id, $zaplog);93 $logRule = "LOG.IMFILE"; 97 94 $traceDest = prepare_output("TRACE.IMFILE", $outroot, $class_id, 1); 98 95 } else { 99 $log Dest = prepare_output("LOG.IMFILE.UPDATE", $outroot, $class_id, 1);96 $logRule = "LOG.IMFILE.UPDATE"; 100 97 $traceDest = prepare_output("TRACE.IMFILE.UPDATE", $outroot, $class_id, 1); 101 98 } 102 99 103 100 if ($redirect) { 104 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR ); 101 my $logDest = $ipprc->filename($logRule, $outroot, $class_id); 102 103 $ipprc->redirect_to_logfile($logDest) or my_die( "Unable to redirect output", $exp_id, $chip_id, $class_id, $PS_EXIT_SYS_ERROR ); 104 105 105 print STDOUT "\n\n"; 106 106 print STDOUT "Starting script $0 on $host\n\n"; … … 451 451 $command .= " -image_id $chip_imfile_id" if defined $chip_imfile_id; 452 452 $command .= " -source_id $source_id" if defined $source_id; 453 $command .= " -tracedest $traceDest -log $logDest";453 $command .= " -tracedest $traceDest"; 454 454 $command .= " -dbname $dbname" if defined $dbname; 455 455
Note:
See TracChangeset
for help on using the changeset viewer.
