IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30373


Ignore:
Timestamp:
Jan 26, 2011, 10:07:14 AM (15 years ago)
Author:
bills
Message:

Add tasks and script to clean up temporary files created by magic processing.
Update magictool to add modes to control this cleanup.

Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/Build.PL

    r30049 r30373  
    5858        scripts/magic_tree.pl
    5959        scripts/magic_process.pl
     60        scripts/magic_cleanup.pl
    6061        scripts/magic_destreak.pl
    6162        scripts/magic_destreak_revert.pl
  • trunk/ippScripts/scripts/magic_cleanup.pl

    r30347 r30373  
    3737
    3838# Parse the command-line arguments
    39 my ($magic_id, $exp_id, $workdir, $camera);
     39my ($magic_id, $exp_id, $outroot, $camera);
    4040my ($dbname, $verbose, $no_update, $no_op, $logfile);
    4141
    4242GetOptions(
    4343           'magic_id=s'     => \$magic_id,   # Magic run identifier
    44            'workdir=s'      => \$workdir,    # directory to clean up
     44           'outroot=s'      => \$outroot,    # directory to clean up
    4545           'camera=s'       => \$camera,    # directory to clean up
    4646           'logfile=s'      => \$logfile,
     
    5454
    5555pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    56 pod2usage( -msg => "Required options: --magic_id --workdir --camera",
     56pod2usage( -msg => "Required options: --magic_id --exp_id --outroot --camera",
    5757           -exitval => 3) unless
    5858    defined $magic_id and
    59     defined $workdir and
     59    defined $exp_id and
     60    defined $outroot and
    6061    defined $camera;
    6162
    6263my $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);
    6365$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_id, $PS_EXIT_SYS_ERROR ) if $logfile;
    6466
    65 if (-e $workdir) {
     67my $parentdir = dirname($outroot);
     68if (-e $parentdir ) {
    6669    my @extensions = ('.list', '.streakMap', '.streaks', '.clusters', '_hough.fits');
    6770    foreach my $ext (@extensions) {
    6871        my $n = 0;
    69         my $path = $workdir . '/*' . $ext;
     72        my $path = $outroot . '*' . $ext;
    7073        my @files = glob($path);
    7174        foreach my $file (@files) {
     
    7477                unless ($no_op) {
    7578                    # remove this print
    76                     print "unlinking $file\n";
     79                    # print "unlinking $file\n";
    7780                    unlink $file or my_die ("unable to delete $file", $magic_id, $PS_EXIT_SYS_ERROR);
    7881                } else {
     
    8487    }
    8588    # 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";
    8790    if (-e $verify_dir ) {
    8891        my $rc = system "rm -r $verify_dir";
     
    9194    }
    9295} 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);
    113112        }
    114         print "Workdir $workdir not found. Setting magicRun.workdir_state to cleaned.\n";
    115         # fall through to update workdir_state
    116113    }
     114    print "Workdir $outroot not found. Setting magicRun.workdir_state to cleaned.\n";
     115    # fall through to update workdir_state
    117116}
    118117           
    119 my $command = "$magictool -updaterun -magic_id $magic_id -set_workdir_state cleaned";
     118my $command = "$magictool -setworkdirstate -magic_id $magic_id -set_workdir_state cleaned";
    120119$command   .= " -dbname $dbname" if defined $dbname;
    121120unless ($no_update) {
     
    138137    $exit_code = $PS_EXIT_PROG_ERROR unless $exit_code;
    139138
    140     my $command = "$magictool -updaterun -set_workdir_state error_cleaned";
     139    my $command = "$magictool -setworkdirstate -set_workdir_state error_cleaned";
    141140    $command   .= " -magic_id $magic_id";
    142141    $command   .= " -dbname $dbname" if defined $dbname;
  • trunk/ippTools/share/Makefile.am

    r30352 r30373  
    246246        magictool_exposure.sql \
    247247        magictool_setfull.sql \
     248        magictool_setgotocleaned.sql \
     249        magictool_tocleanup.sql \
    248250        magicdstool_clearstatefaults.sql \
    249251        magicdstool_change_file_data_state.sql \
Note: See TracChangeset for help on using the changeset viewer.