IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29333


Ignore:
Timestamp:
Oct 5, 2010, 3:41:25 PM (16 years ago)
Author:
bills
Message:

various fixes to postage stamp server and publish stage

Location:
tags/ipp-20100823
Files:
1 deleted
23 edited
2 copied

Legend:

Unmodified
Added
Removed
  • tags/ipp-20100823/ippTasks/pstamp.pro

    r29145 r29333  
    1616$pstampRevDep_DB = 0
    1717$pstampCleanup_DB = 0
     18$pstampStopFaulted_DB = 0
    1819
    1920# set PS_DBSERVER if postage stamp database host is not the same as the value for DBSERVER in site.config
     
    9091        active false
    9192    end
    92     task pstamp.job.revert
    93         active false
    94     end
    9593    task pstamp.dependent.load
    9694        active false
     
    108106        active true
    109107    end
     108    task pstamp.stopfaulted
     109        active true
     110    end
    110111end
    111112macro pstamp.revert.off
     
    114115    end
    115116    task pstamp.dependent.revert
     117        active false
     118    end
     119    task pstamp.stopfaulted
    116120        active false
    117121    end
     
    845849    end
    846850end
     851
     852task pstamp.stopfaulted
     853    host        local
     854
     855    periods     -poll $LOADPOLL
     856    periods     -exec 30
     857    periods     -timeout 300
     858    npending    1
     859
     860    task.exec
     861        stderr $LOGSUBDIR/pstamp.stopfaulted.log
     862        stderr $LOGSUBDIR/pstamp.stopfaulted.log
     863        $run = pstampstopfaulted
     864        if ($DB:n == 0)
     865            option DEFAULT
     866        else
     867            $run = $run $PS_DBSERVER -dbname $DB:$pstampStopFaulted_DB
     868            $pstampStopFaulted_DB ++
     869            if ($pstampStopFaulted_DB >= $DB:n) set pstampStopFaulted_DB = 0
     870        end
     871        add_poll_args run
     872        add_poll_labels run
     873        command $run
     874    end
     875
     876    task.exit $EXIT_SUCCESS
     877        # nothing to do
     878    end
     879
     880    task.exit   default
     881        showcommand failure
     882    end
     883
     884    task.exit   crash
     885        showcommand crash
     886    end
     887
     888    task.exit   timeout
     889        showcommand timeout
     890    end
     891end
  • tags/ipp-20100823/ippTools

  • tags/ipp-20100823/ippTools/share/pstamptool_revertdependent.sql

    • Property svn:mergeinfo deleted
  • tags/ipp-20100823/ippTools/share/pstamptool_revertjob.sql

    • Property svn:mergeinfo deleted
  • tags/ipp-20100823/ippTools/share/pstamptool_updatejob.sql

    r27874 r29333  
    1 UPDATE pstampJob LEFT JOIN pstampDependent USING(dep_id)
     1UPDATE pstampJob
     2    JOIN pstampRequest USING(req_id)
     3    LEFT JOIN pstampDependent USING(dep_id)
    24SET
  • tags/ipp-20100823/ippTools/share/pubtool_pending.sql

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • tags/ipp-20100823/ippTools/share/pxadmin_create_tables.sql

    r29322 r29333  
    14411441        imagedb    VARCHAR(64),
    14421442        rlabel     VARCHAR(64),
     1443        need_magic TINYINT,
    14431444        outdir     VARCHAR(255),
    1444         need_magic TINYINT,
     1445        fault      SMALLINT,
     1446        fault_count INT,
    14451447        PRIMARY KEY(dep_id),
    14461448        KEY(state),
    14471449        KEY(stage),
    1448         KEY(stage_id)
     1450        KEY(stage_id),
     1451        KEY(fault)
    14491452) ENGINE=innodb DEFAULT CHARSET=latin1;
    14501453
  • tags/ipp-20100823/ippTools/src/pstamptool.c

    • Property svn:mergeinfo deleted
    r29307 r29333  
    883883    PXOPT_LOOKUP_S64(req_id,    config->args, "-req_id", false, false);
    884884    PXOPT_LOOKUP_S64(dep_id,    config->args, "-dep_id", false, false);
    885 
    886     if (!job_id && !req_id && !dep_id) {
    887         psError(PS_ERR_UNKNOWN, true, "at least one of -job_id -req_id or -dep_id is required");
     885    PXOPT_LOOKUP_S32(fault_count, config->args, "-fault_count",  false, false);
     886
     887    if (!job_id && !req_id && !dep_id && !fault_count) {
     888        psError(PS_ERR_UNKNOWN, true, "at least one of -job_id -req_id -dep_id or -fault_count is required");
    888889        return false;
    889890    }
     
    904905    PXOPT_COPY_S32(config->args, where, "-fault",  "pstampJob.fault", "==");
    905906    PXOPT_COPY_STR(config->args, where, "-state",  "pstampJob.state", "==");
     907    PXOPT_COPY_S32(config->args, where, "-fault_count", "pstampJob.fault_count", ">=");
     908    pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "LIKE");
    906909
    907910    psString query = pxDataGet("pstamptool_updatejob.sql");
     
    948951    PXOPT_COPY_S64(config->args, where, "-dep_id", "dep_id", "==");
    949952    PXOPT_COPY_S32(config->args, where, "-fault",  "pstampDependent.fault", "==");
     953    pxAddLabelSearchArgs(config, where, "-label", "pstampRequest.label", "LIKE");
     954    // if (fault_count) {
     955        PXOPT_COPY_S32(config->args, where, "-fault_count", "pstampDependent.fault_count", ">=");
     956    // }
    950957
    951958    // XXX: How about selecting by pstampRequest.label? No. That is too dangerous by itself.
  • tags/ipp-20100823/ippTools/src/pstamptool.h

    • Property svn:mergeinfo deleted
  • tags/ipp-20100823/ippTools/src/pstamptoolConfig.c

    • Property svn:mergeinfo deleted
    r29307 r29333  
    167167    psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-state", 0,             "current state of jobs to update", 0);
    168168    psMetadataAddS16(updatejobArgs, PS_LIST_TAIL, "-fault", 0,             "current value for job fault", 0);
     169    psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by pstampJob label (LIKE comparision)", NULL);
     170    psMetadataAddS32(updatejobArgs, PS_LIST_TAIL, "-fault_count", 0,       "select by fault_count (>=)", 0);
    169171    psMetadataAddStr(updatejobArgs, PS_LIST_TAIL, "-set_state", 0,            "new state", NULL);
    170172    psMetadataAddS16(updatejobArgs, PS_LIST_TAIL, "-set_fault", 0,            "new result", 0);
     173    psMetadataAddU64(updatejobArgs, PS_LIST_TAIL, "-limit", 0,      "not used", 0);
    171174
    172175    // -stopdependentjob
     
    176179    psMetadataAddS64(stopdependentjobArgs, PS_LIST_TAIL,  "-dep_id", 0,       "dep_id of jobs to update", 0);
    177180    psMetadataAddS16(stopdependentjobArgs, PS_LIST_TAIL,  "-fault", 0,        "current value for dependent fault", 0);
     181    psMetadataAddS32(stopdependentjobArgs, PS_LIST_TAIL,  "-fault_count", 0,   "select by fault_count (>=)", 0);
    178182    psMetadataAddS16(stopdependentjobArgs, PS_LIST_TAIL,  "-set_fault", 0,    "new fault value for job and dependent (required)", 0);
     183    psMetadataAddStr(stopdependentjobArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by pstampJob label (LIKE comparision)", NULL);
     184    psMetadataAddU64(stopdependentjobArgs, PS_LIST_TAIL, "-limit", 0,      "not used", 0);
    179185
    180186    // -revertjob
     
    187193    psMetadataAddBool(revertjobArgs, PS_LIST_TAIL, "-clear_fault_count", 0,       "clear job fault count", false);
    188194    psMetadataAddBool(revertjobArgs, PS_LIST_TAIL, "-all", 0,       "revert all faulted jobs", false);
    189     psMetadataAddU64(revertjobArgs, PS_LIST_TAIL, "-limit", 0,      "limit result set to N items", 0);
     195    psMetadataAddU64(revertjobArgs, PS_LIST_TAIL, "-limit", 0,      "not used", 0);
    190196
    191197    // -getdependent
  • tags/ipp-20100823/ippTools/src/pubtool.c

    • Property svn:mergeinfo changed (with no actual effect on merging)
  • tags/ipp-20100823/ippTools/src/stacktool.c

    • Property svn:mergeinfo deleted
  • tags/ipp-20100823/ippTools/src/stacktoolConfig.c

    • Property svn:mergeinfo deleted
  • tags/ipp-20100823/pstamp

  • tags/ipp-20100823/pstamp/scripts/Makefile.am

    r28038 r29333  
    1919        pstamp_webrequest.pl \
    2020        pstamp_get_image_job.pl \
     21        psmkreq \
     22        pstampstopfaulted \
    2123        pstamp_checkdependent.pl \
    2224        request_finish.pl \
  • tags/ipp-20100823/pstamp/scripts/detectability_respond.pl

    r29131 r29333  
    644644        $columns = [
    645645            # matching rownum from detectability original request
    646             { name => 'ROWNUM',   type => 'V', writetype => TULONG },
     646            { name => 'ROWNUM',   type => '20A', writetype => TULONG },
    647647            # any errors that occurred during processing
    648648            { name => 'ERROR_CODE',   type => 'V', writetype => TULONG },
  • tags/ipp-20100823/pstamp/scripts/pstamp_checkdependent.pl

    • Property svn:mergeinfo deleted
  • tags/ipp-20100823/pstamp/scripts/pstamp_finish.pl

    r28229 r29333  
    191191            my $filter = $job_params->{filter};
    192192            $filter = "0" if !$filter;
    193             $exp_info = "0|0|0|$filter|0|0";
     193            my $mjd_obs = $job_params->{mjd_obs};
     194            $mjd_obs = "0" if !$mjd_obs;
     195            $exp_info = "$mjd_obs|0|0|$filter|0|0";
    194196        }
    195197
     
    477479    my $ticks = timegm($sec, $min, $hr, $day, $mon-1, $year-1900);
    478480
     481    # dateobs is UTC convert to TAI
     482    # XXX: Do this properly
     483    if ($year >= 2009) {
     484        $ticks += 34;
     485    } else {
     486        $ticks += 33;
     487    }
     488
    479489    return 40587.0 + ($ticks/86400.);
    480490}
  • tags/ipp-20100823/pstamp/scripts/pstamp_insert_request.pl

    r28106 r29333  
    4444
    4545my $pstamptool = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
    46 my $pstampdump = can_run('pstampdump')  or (warn "Can't find pstampdump"  and $missing_tools = 1);
     46my $fields = can_run('fields')  or (warn "Can't find fields"  and $missing_tools = 1);
    4747
    4848if ($missing_tools) {
     
    5353my ($extname, $extver, $req_name);
    5454{
    55     my $command = "$pstampdump -headeronly $tmp_req_file";
     55    # get the header keywords of interest.
     56    # Note that if it's a pstamp request then REQ_NAME should be defined.
     57    # if it's a detectability query it will not have a REQ_NAME but will have a QUERY_ID
     58    my $command = "echo $tmp_req_file | $fields -x 0 EXTNAME EXTVER REQ_NAME QUERY_ID";
    5659    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    5760        run(command => $command, verbose => $verbose);
     61if (0) {
     62    # stoopid fields doesn't set exit status to zero when it works
    5863    unless ($success) {
    5964        print STDERR @$stderr_buf;
    6065        exit $error_code >> 8;
    6166    }
     67}
    6268    my $output = join "", @$stdout_buf;
    63     ($extname, $extver, $req_name) = split " ", $output;
    64     if ($extname and ($extname ne "PS1_PS_REQUEST")) {
     69    (undef, $extname, $extver, $req_name) = split " ", $output;
     70    if (!$extname or ! (($extname eq "PS1_PS_REQUEST") or ($extname eq "MOPS_DETECTABILITY_QUERY"))) {
    6571        print STDERR "invalid request file\n";
    6672        exit $PS_EXIT_DATA_ERROR;
    6773    }
    6874    if (!defined $req_name) {
    69         print STDERR "invalid request file no REQ_NAME\n";
     75        print STDERR "invalid request file no REQ_NAME or QUERY_ID\n";
    7076        exit $PS_EXIT_DATA_ERROR;
    7177    }
     
    9197my $req_id = 0;
    9298{
    93 
    94     my $command = "$pstamptool -addreq -name $req_name -uri $req_file -ds_id 0";
     99    my $command = "$pstamptool -addreq -uri $req_file -ds_id 0 -name $req_name";
    95100    $command .= " -dbname $dbname" if $dbname;
    96101    $command .= " -dbserver $dbserver" if $dbserver;
  • tags/ipp-20100823/pstamp/scripts/pstamp_server_status

    r27211 r29333  
    1616
    1717my ($rundir, $verbose, $save_temps);
     18my $br = '<br />';
    1819
    1920GetOptions(
     
    99100    print "Pantasks Scheduler $scheduler_state.\n";
    100101    if ($controller_state) {
    101         print "Pantasks Controller $controller_state.\n";
     102        print $br . "Pantasks Controller $controller_state.\n";
    102103    } else {
    103104        print STDERR "Controller state not found";
    104105        exit 1;
    105106    }
    106     print "\n";
     107    print "$br$br\n";
    107108} else {
    108109    print STDERR "Scheduler state not found";
     
    116117
    117118if ($request_run) {
    118     print "<b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully.&nbsp; $request_run->{nfail} failed to parse.";
     119    print "<br /><b>Parser Status:</b> $request_run->{nrun} running. $request_run->{ngood} parsed successfully.&nbsp; $request_run->{nfail} failed to parse.";
    119120    if ($request_fin) {
    120121        print "  $request_fin->{ngood} Requests finished.";
     
    125126    print "\n";
    126127    if ($job_run) {
    127         print "<b>Job Status:</b> &nbsp;&nbsp; $job_run->{nrun} running. &nbsp; $job_run->{ngood} completed successfully. &nbsp; $job_run->{nfail} failed";
    128         print "\n";
     128        print "<br /><b>Job Status:</b> &nbsp;&nbsp; $job_run->{nrun} running. &nbsp; $job_run->{ngood} completed successfully. &nbsp; $job_run->{nfail} failed";
     129        print "<br />\n";
    129130    } else {
    130         print "Task pstamp.job.run not found.\n";
     131        print "Task pstamp.job.run not found.<br />\n";
    131132    }
     133    print "<br /><b>Unfinished Requests</b><br />\n";
     134    print "<pre>\n";
     135    system "/home/panstarrs/bills/ipp/tools/psstatus -r ";
     136    print "</pre>\n";
     137    print "<br /><b>Requests completed in last 24 hours (most recently completed first)</b><br />\n";
     138    print "<pre>\n";
     139    # finished requests
     140    system "/home/panstarrs/bills/ipp/tools/psstatus -f";
     141    print "</pre>\n";
    132142} else {
    133143    print "Task pstamp.request.run not found.\n";
     
    135145
    136146
     147
     148
    137149exit 0;
  • tags/ipp-20100823/pstamp/scripts/pstamp_webrequest.pl

    r28106 r29333  
    44# pstampwebrequest.pl: take a postage stamp request command line and process it
    55#
    6 # The arguments are the command line parameters for the program pstamprequest
     6# The arguments are the command line parameters for the program psmkreq
    77#
    88# Unless the argument -list is provided the output is the request id for the resulting request
     
    3333    'dbname=s'      =>  \$dbname,
    3434    'dbserver=s'    =>  \$dbserver,
    35     'project=s'     => \$project,
     35#    'project=s'     => \$project,
    3636    'verbose'       => \$verbose,
    3737);
     
    7070my $missing_tools;
    7171
    72 my $pstamprequest = can_run('pstamprequest')  or (warn "Can't find pstamprequest"  and $missing_tools = 1);
     72my $psmkreq = can_run('psmkreq')  or (warn "Can't find psmkreq"  and $missing_tools = 1);
    7373my $pstamptool = can_run('pstamptool')  or (warn "Can't find pstamptool"  and $missing_tools = 1);
    7474my $pstampparse = can_run('pstampparse.pl')  or (warn "Can't find pstampparse.pl"  and $missing_tools = 1);
    75 my $pstampparser_run = can_run('pstamp_parser_run.pl')  or (warn "Can't find pstamp_parser_run.pl"  and $missing_tools = 1);
    7675
    7776if ($missing_tools) {
     
    9695my $request_file = "$datedir/$request_name.fits";
    9796{
    98     my $command = "$pstamprequest -req_name $request_name -project $project $request_file @ARGV";
    99     $command .= " -$job_type" if $job_type;     # default job_type is pstamp
     97    my $command = "$psmkreq --req_name $request_name  --output $request_file @ARGV";
    10098
    10199    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     
    103101    unless ($success) {
    104102        print STDERR @$stderr_buf;
    105         die("Unable to perform pstamprequest: $error_code");
     103        die("Unable to perform psmkreq: $error_code");
    106104    }
    107105}
  • tags/ipp-20100823/pstamp/scripts/pstampparse.pl

    r28878 r29333  
    806806    my ($r_jobState, $r_fault, $r_dep_id, $imagedb, $state, $stage, $stage_id, $component, $need_magic) = @_;
    807807
    808     # XXX: The update process for warp and subsequent stages requires # destreaking to be performed
    809     # because the -pending queries require the inputs to have magicked >= 0
    810     # The case of stack-stack diffs not needing to be destreaked is taken care of in pstamp_checkdependent
    811     $need_magic = 1 if $imagedb eq 'gpc1';
     808    if (($stage ne 'chip') and ($stage ne 'raw')) {
     809        # XXX: The update process for warp and subsequent stages requires that destreaking to be performed
     810        # because the -pending queries require the inputs to have magicked >= 0
     811        # This is too conservative. For example stage is warp and the warp has never been destreaked we don't
     812        # need magic either
     813        # The case of stack-stack diffs not needing to be destreaked is taken care of in pstamp_checkdependent
     814        # maybe we should put all of the smarts there and interpret the need_magic flag in the dependent as
     815        # "The client needs to have magic performed" and let
     816        # XXX: note the very nasty hard coding of gpc1
     817        $need_magic = 1 if $imagedb eq 'gpc1';
     818    }
    812819
    813820    # chipRun's can be in full state if destreaking is necessary
     
    900907                    $$r_newState = 'stop';
    901908                    $$r_fault = $PSTAMP_NOT_AVAILABLE;
    902                 } elsif (!$image->{magicked}) {
     909                } elsif ($need_magic and !$image->{magicked}) {
    903910                    $$r_newState = 'stop';
    904911                    $$r_fault = $PSTAMP_NOT_DESTREAKED;
  • tags/ipp-20100823/pstamp/web/request.php

    r25322 r29333  
    1616// XXX This is just a prototype for testing purposes.
    1717
    18 
    19 // XXX: change to include pstampconfig.php
    20 
    21 // BEGIN Local configuration
    22 
    23 $WORKDIR = "/data/ipp049.0/pstamp/work";
    24 $dsroot = "/data/ipp049.0/datastore/dsroot";
    25 $dbname = "ippRequestServer";
    26 $dbserver = "ipp049";
    27 
    28 $PSCONFDIR = "/data/ipp053.0/home/bills/psconfig";
    29 $PSCONFIG  = "debug";
    30 $PSBINDIR  = "$PSCONFDIR/$PSCONFIG.lin64/bin";
    31 
    32 // END Local configuration
     18require "pstamp.php";
     19require "submitted.php";
    3320
    3421# this script sets up the environment to run IPP commands with current directory
     
    5542$diff_checked = "";
    5643$list_checked = "";
     44$getstatus_checked = "";
    5745$pstamp_checked = "";
    5846$get_checked = "";
     
    10290if ($rvar_project == "gpc1") {
    10391    $gpc1_selected = "selected";
    104     $require_class_id = 1;
     92//    $require_class_id = 1;
    10593} else if ($rvar_project == "megacam-mops") {
    10694    $mops_selected = "selected";
     
    122110    $diff_checked = "CHECKED";
    123111} else {
    124     // nothing checked default to By Exposure
    125     $exp_checked = "CHECKED";
     112    // nothing checked default to By ID
     113    $file_checked = "CHECKED";
    126114}
    127115
     
    140128
    141129// is the center is specified in Pixels or sky coordinates
    142 if ($rvar_center_type == "Sky") {
     130if ($rvar_center_type == "Pixels") {
     131    $sky_checked="";
     132    $pix_checked="checked";
     133} else {
    143134    $sky_checked="checked";
    144135    $pix_checked="";
    145 } else {
    146     $sky_checked="";
    147     $pix_checked="checked";
    148136}
    149137
     
    168156}
    169157
     158$getstatus_checked = "";
     159$pstamp_checked = "";
     160$list_checked = "";
     161$get_checked = "";
    170162if ($rvar_cmd_mode == "Make Stamps") {
    171163    $pstamp_checked = "checked";
    172     $list_checked = "";
    173     $get_checked = "";
    174164} else if ($rvar_cmd_mode == "Get Images") {
    175165    $get_checked = "checked";
    176     $list_checked = "";
    177     $pstamp_checked = "";
     166} else if ($rvar_cmd_mode == "Get Status") {
     167    $getstatus_checked = "checked";
    178168} else {
    179     $list_checked = "checked";
    180     $get_checked = "";
    181     $pstamp_checked = "";
     169    // default
     170    $pstamp_checked = "checked";
    182171}
    183172
     
    188177
    189178// How do we know whether or not this is the intial page load or not?
    190 // Well, in that case rvar_img_type is not set so key off of that
     179// Well, the first time rvar_img_type is not set. So we key off of that.
    191180// TODO: find a better way to decide whether or not to run commands
    192181
    193182if ($rvar_img_type) {
    194 
    195183    $jobFinished = 0;
    196     if ($request_id == 0) {
     184    if (! $getstatus_checked) {
    197185        try {
    198186            $command_line = build_request_cmd();
     
    201189            if (! $list_checked) {
    202190                // The only output from a successful run is the request_id
     191                $request_name = trim(Array_pop($output_array));
    203192                $request_id = Array_pop($output_array);
    204193                $last_request_id = $request_id;
    205                 setcookie("our_request_id", $request_id);
    206                 // echo "The request id is $request_id\n";
    207                 if (count($output_array) != 0) {
    208                     throw new Exception("unexpected output returned by pstampwebrequest.");
     194                if ($request_id && $request_name) {
     195                    addRequest($request_id, $request_name);
     196                    // setcookie("our_request_id", $request_id);
     197                    // echo "The request id is $request_id\n";
     198                    $getstatus_checked = "checked";
     199                    $pstamp_checked = "";
     200                } else {
     201                    // XXX: TODO print out the error
     202                    if (count($output_array) != 0) {
     203                        throw new Exception("unexpected output returned by pstampwebrequest.");
     204                    }
    209205                }
    210 
    211                 $jobRunning = getRequestStatus();
    212                 if (!$jobRunning) {
    213                   //   echo "1  getRequestStatus reuturned 0\n";
    214                     $jobFinished = 1;
    215                     $request_id = 0;
    216                 }
    217 
    218206            } else {
    219207                $last_request_id = 0;
     
    222210            $error_line = $e->getMessage();
    223211        }
    224     } else {
    225         try {
    226             // get the list of jobs for the request
    227             // echo "calling getRequestStatus\n";
    228             $jobRunning = getRequestStatus();
    229 
    230             if (!$jobRunning) {
    231                //  echo "2  getRequestStatus reuturned 0\n";
    232                 $jobFinished = 1;
    233                 $request_id = 0;
    234             }
    235 
    236         } catch (Exception $e) {
    237             echo "Got Exception $request_id $e\n";
    238             $error_line = $e->getMessage();
    239         }
    240     }
    241     if ($last_request_id) {
    242         // This doesn't work for get_image
    243         listJobs($last_request_id, $jobFinished);
    244     }
    245 }
     212    }
     213}
     214
     215// This is the end of the Logic
    246216
    247217function build_request_cmd()
     
    296266                throw new Exception('RA and DEC must be specified.');
    297267            }
    298             $cmd .= " -skycenter $rvar_RA $rvar_DEC";
     268            $cmd .= " --ra $rvar_RA --dec $rvar_DEC";
    299269        } else {
    300270            if (! $rvar_X || ! $rvar_Y) {
    301271                throw new Exception('X and Y must be specified.');
    302272            }
    303             $cmd .= " -pixcenter $rvar_X $rvar_Y";
     273            $cmd .= " -pixcenter --x $rvar_X --y $rvar_Y";
    304274        }
    305275
     
    308278                throw new Exception('dRA and dDEC must be specified.');
    309279            }
    310             $cmd .= " -arcrange $rvar_dRA $rvar_dDEC";
     280            $cmd .= " --arcseconds --width $rvar_dRA --height $rvar_dDEC";
    311281        } else {
    312282            if (! $rvar_W || ! $rvar_H) {
    313283                throw new Exception('width and height must be specified.');
    314284            }
    315             $cmd .= " -pixrange $rvar_W $rvar_H";
     285            $cmd .= " --width $rvar_W --height $rvar_H";
    316286        }
    317287    }
     
    324294
    325295    if ($exp_checked) {
     296        if ($rvar_img_type == "stack") {
     297            throw new Exception('Lookup by exposure name not supported for stack images.');
     298        }
    326299        if (! $rvar_id ) {
    327300            throw new Exception('Must set ID to the Exposure ID.');
    328301        }
    329         $cmd .= " -byexp $rvar_img_type $rvar_id";
     302        $cmd .= " --req_type byexp --stage $rvar_img_type --id $rvar_id";
    330303    } else if ($file_checked) {
    331304        if (! $rvar_id ) {
    332305            throw new Exception('Must set ID to the exposure name.');
    333306        }
    334         $cmd .= " -byid $rvar_img_type $rvar_id";
     307        $cmd .= " --req_type byid --stage $rvar_img_type --id $rvar_id";
    335308    } else if ($coord_checked) {
    336         // $cmd .= " -bycoord $rvar_img_type";
    337         $coord_checked = "";
    338         $exp_checked = "checked";
    339         throw new Exception("Image selection by coordinate not implemented yet.");
     309        $cmd .= " --req_type bycoord --stage $rvar_img_type";
     310        $coord_checked = "checked";
     311//        throw new Exception("Image selection by coordinate not implemented yet.");
    340312    } else if ($diff_checked) {
    341313        if (! $rvar_id ) {
    342314            throw new Exception('Must set ID to Diff Image ID.');
    343315        }
    344         $cmd .= " -bydiff $rvar_img_type $rvar_id";
    345     }
    346 
    347     if (($rvar_img_type == "raw") || ($rvar_img_type == "chip")) {
    348         if ($require_class_id && ! $rvar_class_id ) {
    349             throw new Exception("must specify Class ID with Image Type $rvar_img_type.");
    350         }
    351         if ((!$rvar_class_id) || ($rvar_class_id == "all")) {
    352             $cmd .= " null";
    353         } else {
    354             $cmd .= " $rvar_class_id";
    355         }
    356     }
     316        $cmd .= " --req_type bydiff --stage $rvar_img_type --id $rvar_id";
     317    }
     318
     319// XXX: don't need to require class_id anymore
     320//    if (($rvar_img_type == "raw") || ($rvar_img_type == "chip")) {
     321//        if (!$sky_checked && ($require_class_id && ! $rvar_class_id )) {
     322//            throw new Exception("must specify Class ID with Image Type $rvar_img_type.");
     323//        }
     324        // leave off compoennt if we're looking up by coordinates. It breaks it
     325        if (!$coord_checked && (($rvar_class_id) && ($rvar_class_id != "all"))) {
     326            $cmd .= " --component $rvar_class_id";
     327        }
     328//    }
    357329
    358330    return escapeshellcmd($cmd);
     
    390362}
    391363
     364// This is no longer used
    392365function printURL($line)
    393366{
     
    442415    echo "</td></tr>";
    443416}
    444 
    445 function countRunningJobs()
    446 {
    447     global $output_array;
    448 
    449     $runningJobs = 0;
    450     $size = sizeof($output_array);
    451     for ($i = 0; $i < $size; $i++) {
    452         $elements = explode(" ", $output_array[$i]);
    453         if (count($elements) == 3) {
    454             $state    = $elements[1];
    455             if ($state != "stop") {
    456                 $runningJobs++;
    457             }
    458         } else {
    459             throw new Exception ("incorrect data in job status: $output_array[$i]");
    460         }
    461     }
    462     return $runningJobs;
    463 }
    464 
    465 function listJobs($request_id, $jobFinished)
    466 {
    467     global $WORKDIR;
    468     global $SCRIPT;
    469 
    470     $command_line = "$SCRIPT pstamp_listjobs.pl $request_id";
    471     global $dbname;
    472     global $dbserver;
    473     if ($dbname) {
    474         $command_line .= " --dbname $dbname --dbserver $dbserver";
    475     }
    476 
    477     run_command($command_line);
    478     if ($jobFinished) {
    479         global $outFileset;
    480         global $dsroot;
    481         $parse_error = "$WORKDIR/$request_id/parse_error.txt";
    482         #echo "reading $parse_error\n";
    483         // readfile( $parse_error );
    484         if (file_exists($parse_error)) {
    485             $fhandle = fopen($parse_error, "r");
    486             if ($fhandle) {
    487                 $contents = fread($fhandle, 1024);
    488                 if ($contents) {
    489                     global $last_request_id;
    490                     global $error_line;
    491                     $error_line = "Request $last_request_id: $contents\n";
    492                 }
    493             }
    494         }
    495     }
    496 }
    497 
    498 function getRequestStatus()
    499 {
    500     global $request_id;
    501     global $command_status;
    502     global $output_array;
    503     global $outFileset;
    504     global $dbname;
    505     global $dbserver;
    506     global $SCRIPT;
    507 
    508     $command_line = "$SCRIPT pstamptool -listreq -req_id $request_id -simple";
    509     if ($dbname) {
    510         $command_line .= " -dbname $dbname -dbserver $dbserver";
    511     }
    512     // echo "Running $command_line\n";
    513 
    514     run_command($command_line);
    515     if ($command_status == 0) {
    516         $size = sizeof($output_array);
    517         $runningReq = 0;
    518         for ($i = 0; $i < $size; $i++) {
    519             $elements = explode(" ", $output_array[$i]);
    520             if (count($elements) >= 4) {
    521                 $state = $elements[2];
    522                 $outFileset = $elements[4];
    523                 if ($state != "stop") {
    524                     $runningReq++;
    525                 }
    526             } else {
    527                 throw new Exception ("incorrect data in job status: $output_array[$i]");
    528             }
    529         }
    530         return $runningReq;
    531     } else {
    532         return 0;
    533     }
    534 }
    535 
    536417?>
    537418
    538 <!-- Beginning of the HTML --------------------------------------------- -->
     419<!----------------------Beginning of the HTML --------------------------------------------- -->
     420
    539421<html>
    540  <head>
    541   <title>Postage Stamp Request Form</title>
    542     <?php
    543         if ($request_id != 0) {
    544             // This doesn't do what I want. It does a get not a post
    545 
    546             // echo '<META HTTP-EQUIV="refresh" CONTENT="5">';
    547 
    548         }
    549     ?>
    550  </head>
     422<head>
     423  <title>
     424    Postage Stamp Request Form (prototype)
     425  </title>
     426</head>
     427<body>
     428
     429<H1 align=center>
     430Postage Stamp Request Form
     431</h1>
     432
     433<?php
     434    welcomeHeader($auth_user, "pstamp_links.php", "Postage Stamp Home");
     435?>
     436
    551437<form method="post">
    552 
    553 <body>
    554 
    555 <H1 align=center>
    556 Postage Stamp Request
    557 </h1>
    558 
    559438<!-- Whole page is a single column table -->
    560439
     
    586465<td>
    587466&nbsp;<b>Select Images By:</b>&nbsp;&nbsp;&nbsp;
     467<input type=radio name="select_by" value="db_id" <?php echo $file_checked; ?> >Database ID
     468&nbsp;
    588469<input type=radio name="select_by" value="exposure_id" <?php echo $exp_checked; ?> >Exposure Name
    589470&nbsp;
    590 <input type=radio name="select_by" value="db_id" <?php echo $file_checked; ?> >Database ID
    591 &nbsp;
     471
    592472<input type=radio name="select_by" value="coord" <?php echo $coord_checked; ?> >Coordinates
    593473&nbsp;
     
    625505        echo "Chip ID:";
    626506      } else {
    627         echo "Class ID:";
     507        echo "Component:";
    628508      }
    629509?>
     
    685565            &nbsp;
    686566            <input type="text" name="dRA" size=10  value= <?php echo $rvar_dRA; ?> >
     567            &nbsp; "
    687568        </td>
    688569        <td>
     
    691572            &nbsp;
    692573            <input type="text" name="dDEC" size=10 value="<?php echo $rvar_dDEC;?>" >
     574            &nbsp; "
    693575        </td>
    694576    </tr>
     
    742624  <tr>
    743625
    744 <?php
    745   if ($request_id == 0): ?>
    746626    <td><input type=submit value="Submit"></td>
    747627    <td><b>Mode:</b>&nbsp;&nbsp;
     628    <input type=radio name="cmd_mode" value="Get Status"<?php echo $getstatus_checked; ?> >Get Status
    748629    <input type=radio name="cmd_mode" value="Make Stamps"<?php echo $pstamp_checked; ?> >Make Stamps
    749     <input type=radio name="cmd_mode" value="Get Images" <?php echo $get_checked; ?> >Get Images
     630    <input type=radio name="cmd_mode" value="Get Images" <?php echo $get_checked; ?> >Get Bundles
     631<!--
    750632    <input type=radio name="cmd_mode" value="List Images" <?php echo $list_checked; ?> >List Images
     633-->
    751634    </td>
    752 <?php
    753   else: ?>
    754     <td><input type=submit value="Check Status"></td>
    755 <!---    <td><input type=submit value="Cancel"></td> --->
    756635<?php
    757   echo "<td><b>Request Id: $request_id";
    758   endif; ?>
     636  // echo "<td><b>Request Id: $request_id";
     637?>
    759638
    760639  </tr>
     
    766645
    767646<tr>
     647<!--- Don't show the command
    768648    <td>
    769649    <b>Command:</b>&nbsp;&nbsp; <?php echo "$command_line\n";?>
     650    </td>
     651--->
     652
     653</tr>
     654<tr>
     655    <td>
     656    <b>Last Command</b>
    770657    </td>
    771658</tr>
     
    794681<td>
    795682<table align=center width=100% rules=none>
    796 <caption height=10 valign=center><b>Results</b></caption>
    797 
     683<caption height=10 valign=center><b>Request Results</b></caption>
    798684
    799685<?php
     686if (0) {
     687    // This is the old way of listing the status of the current request.
     688    // now we save the submitted requests in the session see listRequests() below
     689
    800690    $size = sizeof($output_array);
    801691    // echo "<pre>size of output array is $size\n</pre>";
     
    818708        }
    819709    }
     710} // end if if(0)
    820711?>
    821712</table>
     
    845736</table>
    846737
     738<?php
     739    listRequests("http://datastore.ipp.ifa.hawaii.edu/pstampresults", "pstamp_results_fileset");
     740?>
     741
    847742<!-- The end -->
    848743
     
    861756?>
    862757
     758</form>
    863759</body>
    864 </form>
    865 
    866760</html>
Note: See TracChangeset for help on using the changeset viewer.