IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18233


Ignore:
Timestamp:
Jun 20, 2008, 9:36:26 AM (18 years ago)
Author:
bills
Message:

mods to prototype web interface to support updated request file format

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/pstamp/scripts/pstamp_webrequest.pl

    r16974 r18233  
    1111# the selected "input" uris are listed on stdout.
    1212#
    13 # Note: Despite the name there nothing really web specific about this program.
     13# Note: Despite the name there nothing particularly web specific about this program.
    1414#
    1515###
     
    1818use strict;
    1919
    20 my $verbosity = 0;
     20use Getopt::Long qw( GetOptions );
     21use Sys::Hostname;
    2122
    22 use Sys::Hostname;
    2323my $host = hostname();
     24my $verbose = 0;
     25my $dbname;
    2426
    25 if ($verbosity) {
     27GetOptions(
     28    'verbose'   =>  \$verbose,
     29    'dbname=s'  =>  \$dbname,
     30);
     31
     32
     33
     34if ($verbose) {
    2635    print "\n\n";
    2736    print "Starting script $0 on $host\n\n";
    2837}
     38
    2939
    3040use IPC::Cmd 0.36 qw( can_run run );
     
    6575
    6676my $cur_dir = getcwd();
    67 my $request_file = "$cur_dir/request_file.$$.fits";
     77my $request_name = "web" . get_webreq_num();
     78my $request_file = "$cur_dir/$request_name.fits";
    6879{
    69     my $command = "$pstamprequest $request_file @ARGV";
     80    my $command = "$pstamprequest -request_name $request_name $request_file @ARGV";
    7081    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    71         run(command => $command, verbose => $verbosity);
     82        run(command => $command, verbose => $verbose);
    7283    unless ($success) {
    7384        print STDERR @$stderr_buf;
     
    8293    ###
    8394    my $command = "$pstampparse $request_file";
     95    $command .= " -dbname $dbname" if $dbname;
    8496    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    85         run(command => $command, verbose => $verbosity);
     97        run(command => $command, verbose => $verbose);
    8698
    8799    if ($success) {
     
    98110{
    99111
    100     my $command = "$pstamptool -addreq -uri $request_file -out_fileset \'pstampresults/web\$REQ_ID\'";
     112    my $command = "$pstamptool -addreq -uri $request_file -out_fileset \'pstampresults/$request_name'";
     113    $command .= " -dbname $dbname" if $dbname;
    101114    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    102         run(command => $command, verbose => $verbosity);
     115        run(command => $command, verbose => $verbose);
    103116    unless ($success) {
    104117        print STDERR @$stderr_buf;
     
    111124
    112125exit 0;
     126
     127# Temporary hack
     128# webrequest number is stored in a file in the current directory
     129#
     130sub get_webreq_num
     131{
     132    my $filename = "./webreq_num.txt";
     133    if (! open IN, "+< $filename" ) {
     134        my $initial_num = 1;
     135        open IN, "> $filename" or die "can't open request $filename";
     136        print IN "$initial_num\n" or die "failed to initialize $filename";
     137        close IN;
     138        return $initial_num;
     139    }
     140
     141    my $webreq_num = <IN>;
     142    chomp $webreq_num;
     143
     144    print STDERR "$webreq_num\n";
     145
     146    my $next = $webreq_num + 1;
     147    truncate IN, 0;
     148    seek IN, 0, 0;
     149    print IN "$next\n";
     150
     151    close IN;
     152    return $webreq_num;
     153}
Note: See TracChangeset for help on using the changeset viewer.