IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 28106 for trunk/pstamp/scripts


Ignore:
Timestamp:
May 26, 2010, 9:12:02 AM (16 years ago)
Author:
bills
Message:

Get the 'webrequest number' frm the database

Location:
trunk/pstamp/scripts
Files:
2 edited

Legend:

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

    r27211 r28106  
    114114
    115115exit 0;
    116 
    117 # Temporary hack
    118 # webrequest number is stored in a file in the current directory
    119 #
    120 # get this number from the database
     116# Ask the database for the next web request number
    121117sub get_webreq_num
    122118{
    123     my $filename = "$workdir/webreq_num.txt";
    124     if (! open IN, "+< $filename" ) {
    125         my $initial_num = 1;
    126         open IN, "> $filename" or die "can't open $filename";
    127         print IN "$initial_num\n" or die "failed to initialize $filename";
    128         close IN;
    129         return $initial_num;
     119    my $command = "$pstamptool -getwebrequestnum";
     120    $command .= " -dbname $dbname" if $dbname;
     121    $command .= " -dbserver $dbserver" if $dbserver;
     122    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     123        run(command => $command, verbose => $verbose);
     124    unless ($success) {
     125        print STDERR @$stderr_buf;
     126        die("Unable to perform pstamptool -getwebrequestnum: $error_code");
     127    }
     128    my $webreq_num = ${$stdout_buf}[0];
     129    chomp $webreq_num;
     130
     131    if (!$webreq_num) {
     132        die("pstamptool -getwebreqnum returned no value");
    130133    }
    131134
    132     my $webreq_num = <IN>;
    133     chomp $webreq_num;
     135    # print STDERR "webreq_num $webreq_num\n";
    134136
    135     print STDERR "$webreq_num\n" if $verbose;
    136 
    137     my $next = $webreq_num + 1;
    138     truncate IN, 0;
    139     seek IN, 0, 0;
    140     print IN "$next\n";
    141 
    142     close IN;
    143137    return $webreq_num;
    144138}
  • trunk/pstamp/scripts/pstamp_webrequest.pl

    r27355 r28106  
    2323
    2424my $host = hostname();
    25 my $verbose = 0;
     25my $verbose = 1;
    2626my $dbname;
    2727my $dbserver;
     
    152152exit 0;
    153153
    154 # Temporary hack
    155 # webrequest number is stored in a file in the current directory
    156 #
     154# Ask the database for the next web request number
    157155sub get_webreq_num
    158156{
    159     my $filename = "webreq_num.txt";
    160     if (! open IN, "+< $filename" ) {
    161         my $initial_num = 1;
    162         open IN, "> $filename" or die "can't open $filename";
    163         print IN "$initial_num\n" or die "failed to initialize $filename";
    164         close IN;
    165         return $initial_num;
     157    my $command = "$pstamptool -getwebrequestnum";
     158    $command .= " -dbname $dbname" if $dbname;
     159    $command .= " -dbserver $dbserver" if $dbserver;
     160    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     161        run(command => $command, verbose => $verbose);
     162    unless ($success) {
     163        print STDERR @$stderr_buf;
     164        die("Unable to perform pstamptool -getwebrequestnum: $error_code");
     165    }
     166    my $webreq_num = ${$stdout_buf}[0];
     167    chomp $webreq_num;
     168
     169    if (!$webreq_num) {
     170        die("pstamptool -getwebreqnum returned no value");
    166171    }
    167172
    168     my $webreq_num = <IN>;
    169     chomp $webreq_num;
     173    # print STDERR "webreq_num $webreq_num\n";
    170174
    171     print STDERR "$webreq_num\n" if $verbose;
    172 
    173     my $next = $webreq_num + 1;
    174     truncate IN, 0;
    175     seek IN, 0, 0;
    176     print IN "$next\n";
    177 
    178     close IN;
    179175    return $webreq_num;
    180176}
Note: See TracChangeset for help on using the changeset viewer.