IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28888


Ignore:
Timestamp:
Aug 10, 2010, 4:26:38 PM (16 years ago)
Author:
rhenders
Message:

Now using Datastore class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/perl/ippToPsps_run.pl

    r28852 r28888  
    1414use ippToPsps::Gpc1Db;
    1515use ippToPsps::IppToPspsDb;
     16use ippToPsps::Datastore;
    1617
    1718# globals
     
    103104my $gpc1Db = new ippToPsps::Gpc1Db("gpc1", "ippdb01", "ippuser", "ippuser", $verbose, $save_temps);
    104105my $ippToPspsDb = new ippToPsps::IppToPspsDb("ippToPsps", "ippdb01", "ipp", "ipp", $verbose, $save_temps);
     106my $datastore = undef;
     107if ($datastoreProduct) {$datastore = new ippToPsps::Datastore($datastoreProduct, $verbose, $save_temps);}
    105108
    106109# check we can run programs and get camera config
    107110my $ippToPsps = can_run('ippToPsps') or (warn "Can't find 'ippToPsps' program" and exit($PS_EXIT_CONFIG_ERROR));
    108 my $dsreg = can_run('dsreg') or (warn "Can't find 'dsreg' program" and exit($PS_EXIT_CONFIG_ERROR));
    109111my $ipprc = PS::IPP::Config->new($camera) or (warn "Can't get camera configuration" and exit($PS_EXIT_CONFIG_ERROR));
    110112
     
    179181        if (!$surveyType) {next;}
    180182
    181         $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastoreProduct) ? $datastoreProduct : "NONE");
     183        $batchId = $ippToPspsDb->createNewBatch($expId, $distGroup, $pspsBatchType, $dvoDb, (defined $datastore) ? $datastoreProduct : "NONE");
    182184
    183185        # TODO quit here if no sensible batch ID
     
    202204                if (!$dontTarNZip) {
    203205                    my $tarball = tarAndZipBatch($output, $batch);
    204                     if ($tarball && $datastoreProduct && publishToDatastore($batch, $output, $tarball)) {$published = 1;}
     206                    if ($tarball && defined $datastore ) {
     207                       
     208                        $published = $datastore->register($batch, $output, $tarball, "IPP_PSPS", "tgz");
     209                    }
    205210                }
    206211            }
     
    421426
    422427    if (!$foundFits) { print "* Could not find any FITS files for this batch\n"; return 0;}
    423     return 1;
    424 }
    425 
    426 #######################################################################################
    427 #
    428 # register new job with the datastore
    429 #
    430 ########################################################################################
    431 sub publishToDatastore {
    432     my ($batch, $path, $tarball) = @_;
    433 
    434     my ($tempFile, $tempName) = tempfile( "/tmp/ippToPsps_dsregList.XXXX", UNLINK => !$save_temps);
    435 
    436     print $tempFile $tarball . '|||tgz' . "\n";
    437 
    438     # build dsreg command command
    439     my $command  = "$dsreg";
    440     $command .= " --add $batch";
    441     $command .= " --copy";
    442     $command .= " --datapath $path";
    443     $command .= " --type IPP_PSPS";
    444     $command .= " --product $datastoreProduct";
    445     $command .= " --list $tempName";
    446 
    447     # run command
    448     my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    449         run(command => $command, verbose => $verbose);
    450 
    451     if (!$success) { print "* Unable to publish $tarball to datastore\n" and return 0 };
    452 
    453     print "* Successfully published $tarball to datastore\n";
    454 
    455     close($tempFile);
    456 
    457428    return 1;
    458429}
Note: See TracChangeset for help on using the changeset viewer.