Changeset 30373 for trunk/ippScripts/scripts/magic_cleanup.pl
- Timestamp:
- Jan 26, 2011, 10:07:14 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/magic_cleanup.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_cleanup.pl
r30347 r30373 37 37 38 38 # Parse the command-line arguments 39 my ($magic_id, $exp_id, $ workdir, $camera);39 my ($magic_id, $exp_id, $outroot, $camera); 40 40 my ($dbname, $verbose, $no_update, $no_op, $logfile); 41 41 42 42 GetOptions( 43 43 'magic_id=s' => \$magic_id, # Magic run identifier 44 ' workdir=s' => \$workdir, # directory to clean up44 'outroot=s' => \$outroot, # directory to clean up 45 45 'camera=s' => \$camera, # directory to clean up 46 46 'logfile=s' => \$logfile, … … 54 54 55 55 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 56 pod2usage( -msg => "Required options: --magic_id -- workdir--camera",56 pod2usage( -msg => "Required options: --magic_id --exp_id --outroot --camera", 57 57 -exitval => 3) unless 58 58 defined $magic_id and 59 defined $workdir and 59 defined $exp_id and 60 defined $outroot and 60 61 defined $camera; 61 62 62 63 my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 64 $ipprc->outroot_prepare($outroot); 63 65 $ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $PS_EXIT_SYS_ERROR ) if $logfile; 64 66 65 if (-e $workdir) { 67 my $parentdir = dirname($outroot); 68 if (-e $parentdir ) { 66 69 my @extensions = ('.list', '.streakMap', '.streaks', '.clusters', '_hough.fits'); 67 70 foreach my $ext (@extensions) { 68 71 my $n = 0; 69 my $path = $ workdir . '/*' . $ext;72 my $path = $outroot . '*' . $ext; 70 73 my @files = glob($path); 71 74 foreach my $file (@files) { … … 74 77 unless ($no_op) { 75 78 # remove this print 76 print "unlinking $file\n";79 # print "unlinking $file\n"; 77 80 unlink $file or my_die ("unable to delete $file", $magic_id, $PS_EXIT_SYS_ERROR); 78 81 } else { … … 84 87 } 85 88 # remove the verify directory 86 my $verify_dir = $ workdir . "/$exp_id.mgc.$magic_id.verify";89 my $verify_dir = $parentdir . "/$exp_id.mgc.$magic_id.verify"; 87 90 if (-e $verify_dir ) { 88 91 my $rc = system "rm -r $verify_dir"; … … 91 94 } 92 95 } else { 93 # workdir doesn't exist. 94 # If it's parent directory does exist, then assume workdir is gone so it is "cleaned' 95 my $parentdir = dirname($workdir); 96 if (! -e $parentdir ) { 97 # parent directory doesn't exist either, check that mountpoint exists 98 # we expect at least /data/volume 99 my @dirs = split "/", $parentdir; 100 # so the following should be true 101 # $dirs[0] eq "" 102 # $dirs[1] eq 'data' 103 # $dirs[2] eq the volume: for example ipp053.0 104 if ((scalar(@dirs) < 3) or ($dirs[0] ne "") or ($dirs[1] ne 'data')) { 105 my_die("unexpected parent of workdir found: '$parentdir'", $magic_id, $PS_EXIT_UNKNOWN_ERROR); 106 } else { 107 # re-form mountpoint 108 my $mountpoint = "/$dirs[1]/$dirs[2]"; 109 # check if it is readable 110 if (! -e $mountpoint or ! -r $mountpoint ) { 111 my_die("mount point for workdir not found or not readable: '$mountpoint'", $magic_id, $PS_EXIT_SYS_ERROR); 112 } 96 # parent directory doesn't "exist" either, check that mountpoint exists 97 # if it doesn't assume nfs error and fault 98 # we expect at least /data/volume 99 my @dirs = split "/", $parentdir; 100 # so the following should be true 101 # $dirs[0] eq "" 102 # $dirs[1] eq 'data' 103 # $dirs[2] eq the volume: for example ipp053.0 104 if ((scalar(@dirs) < 3) or ($dirs[0] ne "") or ($dirs[1] ne 'data')) { 105 my_die("unexpected parent of outroot found: '$parentdir'", $magic_id, $PS_EXIT_UNKNOWN_ERROR); 106 } else { 107 # re-form mountpoint 108 my $mountpoint = "/$dirs[1]/$dirs[2]"; 109 # check if it is readable 110 if (! -e $mountpoint or ! -r $mountpoint ) { 111 my_die("mount point for outroot not found or not readable: '$mountpoint'", $magic_id, $PS_EXIT_SYS_ERROR); 113 112 } 114 print "Workdir $workdir not found. Setting magicRun.workdir_state to cleaned.\n";115 # fall through to update workdir_state116 113 } 114 print "Workdir $outroot not found. Setting magicRun.workdir_state to cleaned.\n"; 115 # fall through to update workdir_state 117 116 } 118 117 119 my $command = "$magictool - updaterun-magic_id $magic_id -set_workdir_state cleaned";118 my $command = "$magictool -setworkdirstate -magic_id $magic_id -set_workdir_state cleaned"; 120 119 $command .= " -dbname $dbname" if defined $dbname; 121 120 unless ($no_update) { … … 138 137 $exit_code = $PS_EXIT_PROG_ERROR unless $exit_code; 139 138 140 my $command = "$magictool - updaterun-set_workdir_state error_cleaned";139 my $command = "$magictool -setworkdirstate -set_workdir_state error_cleaned"; 141 140 $command .= " -magic_id $magic_id"; 142 141 $command .= " -dbname $dbname" if defined $dbname;
Note:
See TracChangeset
for help on using the changeset viewer.
