Changeset 466 for locker/deploy


Ignore:
Timestamp:
Oct 14, 2007, 12:11:40 AM (15 years ago)
Author:
andersk
Message:
Prepare to get rid of curl.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • locker/deploy/bin/onserver.pm

    • Property svn:executable deleted
    r462 r466  
    88use Cwd qw(abs_path);
    99use POSIX qw(strftime);
     10use LWP::UserAgent;
     11use URI;
    1012our @ISA = qw(Exporter);
    11 our @EXPORT = qw(setup totmp print_login_info press_enter $server $tmp $USER $HOME $sname $deploy $addrend $admin_username $requires_sql $addrlast $sqlhost $sqluser $sqlpass $sqldb $sqldbcurl $admin_password $scriptsdev $human);
     13our @EXPORT = qw(setup totmp fetch_uri print_login_info press_enter $server $tmp $USER $HOME $sname $deploy $addrend $admin_username $requires_sql $addrlast $sqlhost $sqluser $sqlpass $sqldb $sqldbcurl $admin_password $scriptsdev $human);
    1214
    1315our $server = "scripts.mit.edu";
     
    2022  print FILE $_[0];
    2123  close(FILE);
     24}
     25
     26my $ua = LWP::UserAgent->new;
     27my $base_uri;
     28
     29sub fetch_uri {
     30    my ($uri, $get, $post) = @_;
     31    my $u = URI->new($uri);
     32    my $req;
     33    if (defined $post) {
     34        $u->query_form($post);
     35        my $content = $u->query;
     36        $u->query_form($get);
     37        $req = HTTP::Request->new(POST => $u->abs($base_uri));
     38        $req->content_type('application/x-www-form-urlencoded');
     39        $req->content($content);
     40    } else {
     41        $u->query_form($get) if (defined $get);
     42        $req = HTTP::Request->new(GET => $u->abs($base_uri));
     43    }
     44    my $res = $ua->request($req);
     45    if ($res->is_success) {
     46        return $res->content;
     47    } else {
     48        print STDERR "Error fetching configuration page: ", $res->status_line, "\n";
     49        return undef;
     50    }
    2251}
    2352
     
    5685  }
    5786  ($addrlast) = ($addrend =~ /([^\/]*)$/);
     87 
     88  $base_uri = "http://$server/~$USER/$addrend/";
    5889 
    5990  if($requires_sql) {
     
    102133  $| = 1; # STDOUT is *hot*!
    103134}
     135
     1361;
Note: See TracChangeset for help on using the changeset viewer.