IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17637


Ignore:
Timestamp:
May 12, 2008, 12:04:53 PM (18 years ago)
Author:
jhoblitt
Message:

add --timeout option to all ds*ls utilties and other minor doc changes
add the ability to all DataStore::* classes that handle HTTP to pass options directly to LWP::UserAgent

Location:
trunk/DataStore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/DataStore/Changes

    r17552 r17637  
    22
    330.07
     4    - add --timeout option to all ds*ls utilties and other minor doc changes
     5    - add the ability to all DataStore::* classes that handle HTTP to pass
     6      options directly to LWP::UserAgent
    47    - add support for checksumming compressed fits files
    58    - Change DateStore::File to handle passing args to LWP::UserAgent
    6     - add dsget --timeout option
    79    - change dsget to return the HTTP status code on failure
    810    - remove use of parse_neb_key() from dsget
  • trunk/DataStore/lib/DataStore/FileSet.pm

    r15022 r17637  
    1 # Copyright (C) 2006  Joshua Hoblitt
     1# Copyright (C) 2006-2008  Joshua Hoblitt
    22#
    3 # $Id: FileSet.pm,v 1.14 2007-09-25 23:52:46 jhoblitt Exp $
     3# $Id: FileSet.pm,v 1.15 2008-05-12 22:04:53 jhoblitt Exp $
    44
    55package DataStore::FileSet;
     
    99
    1010use vars qw($VERSION);
    11 $VERSION = '0.03';
     11$VERSION = '0.04';
    1212
    1313use base qw( DataStore::Record );
     
    186186    my $self = shift;
    187187
    188     # no params
    189     validate(@_, {});
     188    my %p = validate(@_,
     189        {
     190            ua_args     => {
     191                optional    => 1,
     192            },
     193        },
     194    );
    190195
    191196    # make request
    192     my $ua = LWP::UserAgent->new;
     197    my $ua;
     198    if (defined $p{ua_args}) {
     199        $ua = LWP::UserAgent->new(%{$p{ua_args}});
     200    } else {
     201        $ua = LWP::UserAgent->new;
     202    }
    193203    my $request = HTTP::Request->new(GET => $self->uri);
    194204    my $response = $ua->request($request);
  • trunk/DataStore/lib/DataStore/Product.pm

    r15021 r17637  
    1 # Copyright (C) 2006  Joshua Hoblitt
     1# Copyright (C) 2006-2008  Joshua Hoblitt
    22#
    3 # $Id: Product.pm,v 1.10 2007-09-25 23:50:34 jhoblitt Exp $
     3# $Id: Product.pm,v 1.11 2008-05-12 22:04:53 jhoblitt Exp $
    44
    55package DataStore::Product;
     
    99
    1010use vars qw($VERSION);
    11 $VERSION = '0.01';
     11$VERSION = '0.02';
    1212
    1313use base qw( DataStore::Record );
     
    167167    my $self = shift;
    168168
    169     # no params
    170     validate(@_, {});
     169    my %p = validate(@_,
     170        {
     171            ua_args     => {
     172                optional    => 1,
     173            },
     174        },
     175    );
    171176
    172177    # make request
    173     my $ua = LWP::UserAgent->new;
     178    my $ua;
     179    if (defined $p{ua_args}) {
     180        $ua = LWP::UserAgent->new(%{$p{ua_args}});
     181    } else {
     182        $ua = LWP::UserAgent->new;
     183    }
     184
    174185    my $request;
    175186    if ($self->last_fileset) {
  • trunk/DataStore/lib/DataStore/Root.pm

    r15025 r17637  
    11# Adapted from Product.pm
    22#
    3 # Copyright (C) 2006  Joshua Hoblitt
     3# Copyright (C) 2006-2008  Joshua Hoblitt
    44#
    5 # $Id: Root.pm,v 1.4 2007-09-26 00:13:29 jhoblitt Exp $
     5# $Id: Root.pm,v 1.5 2008-05-12 22:04:53 jhoblitt Exp $
    66
    77package DataStore::Root;
     
    1111
    1212use vars qw($VERSION);
    13 $VERSION = '0.01';
     13$VERSION = '0.02';
    1414
    1515use base qw( DataStore::Record );
     
    131131    my $self = shift;
    132132
    133     # no params
    134     validate(@_, {});
     133    my %p = validate(@_,
     134        {
     135            ua_args     => {
     136                optional    => 1,
     137            },
     138        },
     139    );
    135140
    136141    # make request
    137     my $ua = LWP::UserAgent->new;
     142    my $ua;
     143    if (defined $p{ua_args}) {
     144        $ua = LWP::UserAgent->new(%{$p{ua_args}});
     145    } else {
     146        $ua = LWP::UserAgent->new;
     147    }
     148
    138149    my $request = HTTP::Request->new(GET => $self->uri);
    139150    my $response = $ua->request($request);
  • trunk/DataStore/scripts/dsfilesetls

    r17455 r17637  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2006  Joshua Hoblitt
     3# Copyright (C) 2006-2008  Joshua Hoblitt
    44#
    5 # $Id: dsfilesetls,v 1.6 2008-04-18 23:33:13 jhoblitt Exp $
     5# $Id: dsfilesetls,v 1.7 2008-05-12 22:04:53 jhoblitt Exp $
    66
    77use strict;
     
    1616use Pod::Usage qw( pod2usage );
    1717
    18 my ($uri);
     18my ($uri, $timeout);
    1919
    2020GetOptions(
    2121    'uri|u=s'           => \$uri,
     22    'timeout|t'     => \$timeout,
    2223) or pod2usage( 2 );
    2324
     
    2829) unless defined $uri;
    2930
    30 my $response = DataStore::FileSet->new( uri => $uri )->request;
     31# default http request timeout is 30s
     32$timeout ||= 30;
     33
     34my $response = DataStore::FileSet->new( uri => $uri )->request(
     35        ua_args  => { timeout => $timeout },
     36    );
    3137
    3238die "request failed" unless defined $response;
     
    7682The URI of the file to be retrieved.
    7783
     84=item * --timeout|-t
     85
     86The ammount of time (in seconds) to wait for a response from the DataStore
     87after making an HTTP request.  The default is 30s.
     88
     89Optional.
     90
    7891=back
    7992
     
    92105=head1 COPYRIGHT
    93106
    94 Copyright (C) 2006  Joshua Hoblitt.  All rights reserved.
     107Copyright (C) 2006-2008  Joshua Hoblitt.  All rights reserved.
    95108
    96109This program is free software; you can redistribute it and/or modify it under
     
    112125=head1 SEE ALSO
    113126
    114 L<DataStore>, L<DataStore::FileSet>, L<DataStore::File>
     127L<dsget>, L<dsleech>, L<dsrootls>, L<dsproductls>, L<dsfilesetls>, L<DataStore>
    115128
    116129=cut
  • trunk/DataStore/scripts/dsget

    r17552 r17637  
    33# Copyright (C) 2006-2008  Joshua Hoblitt
    44#
    5 # $Id: dsget,v 1.23 2008-05-07 03:05:03 jhoblitt Exp $
     5# $Id: dsget,v 1.24 2008-05-12 22:04:53 jhoblitt Exp $
    66
    77use strict;
     
    126126# request the file from the remote data store server (save in tmpfilename)
    127127my $response = DataStore::File->new(%p)->request(
    128     filename => $tmpfilename,
    129     ua_args  => { timeout => $timeout},
    130 );
     128        filename => $tmpfilename,
     129        ua_args  => { timeout => $timeout },
     130    );
    131131
    132132die "request failed" unless defined $response;
     
    282282=head1 SEE ALSO
    283283
    284 L<DataStore>, L<DataStore::File>
     284L<dsget>, L<dsleech>, L<dsrootls>, L<dsproductls>, L<dsfilesetls>, L<DataStore>
    285285
    286286=cut
  • trunk/DataStore/scripts/dsleech

    r16582 r17637  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2006  Joshua Hoblitt
     3# Copyright (C) 2006-2008  Joshua Hoblitt
    44#
    5 # $Id: dsleech,v 1.9 2008-02-22 01:50:43 jhoblitt Exp $
     5# $Id: dsleech,v 1.10 2008-05-12 22:04:53 jhoblitt Exp $
    66
    77use strict;
     
    1818use Pod::Usage qw( pod2usage );
    1919
    20 my ($dir, $uri, $last_fileset, $overwrite, $recall, $remember, $verbose);
     20my ($dir, $uri, $last_fileset, $overwrite, $recall, $remember, $verbose, $timeout);
    2121
    2222GetOptions(
     
    2828    'remember'          => \$remember,
    2929    'verbose|v'         => \$verbose,
     30    'timeout|t'         => \$timeout,
    3031) or pod2usage( 2 );
    3132
     
    3536    -exitval => 3,
    3637) unless defined $uri;
     38
     39# default http request timeout is 30s
     40$timeout ||= 30;
    3741
    3842my %p = (
     
    5963}
    6064
    61 my $response = DataStore::Product->new(%p)->request;
     65my $response = DataStore::Product->new(%p)->request(
     66    ua_args  => { timeout => $timeout },
     67);
     68
    6269unless (defined $response->is_success) {
    6370    die "request failed: ", $response->status_line;
     
    96103        print "processing fileset: $fileset->fileset $n/@$filesets\n" if $verbose;
    97104
    98         my $response = $fileset->request;
     105        my $response = $fileset->request(
     106                ua_args  => { timeout => $timeout },
     107            );
    99108        unless (defined $response->is_success) {
    100109            warn "request failed: ", $response->status_line;
     
    155164        print "fetching ", $file->fileid, "..." if $verbose;
    156165
    157         my $response = $file->request( filename => $filename );
     166        my $response = $file->request(
     167                filename => $filename,
     168                ua_args  => { timeout => $timeout },
     169            );
    158170        unless (defined $response->is_success) {
    159171            warn "request failed: ", $response->status_line;
     
    261273This flag is optional.
    262274
     275=item * --timeout|-t
     276
     277The ammount of time (in seconds) to wait for a response from the DataStore
     278after making an HTTP request.  The default is 30s.
     279
     280Optional.
     281
    263282=back
    264283
     
    277296=head1 COPYRIGHT
    278297
    279 Copyright (C) 2006  Joshua Hoblitt.  All rights reserved.
     298Copyright (C) 2006-2008  Joshua Hoblitt.  All rights reserved.
    280299
    281300This program is free software; you can redistribute it and/or modify it under
     
    297316=head1 SEE ALSO
    298317
    299 L<dsproductls>, L<dsfilesetls>, L<dsget>, L<DataStore>
     318L<dsget>, L<dsleech>, L<dsrootls>, L<dsproductls>, L<dsfilesetls>, L<DataStore>
    300319
    301320=cut
  • trunk/DataStore/scripts/dsproductls

    r8707 r17637  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2006  Joshua Hoblitt
     3# Copyright (C) 2006-2008  Joshua Hoblitt
    44#
    5 # $Id: dsproductls,v 1.3 2006-08-30 22:45:53 jhoblitt Exp $
     5# $Id: dsproductls,v 1.4 2008-05-12 22:04:53 jhoblitt Exp $
    66
    77use strict;
     
    1616use Pod::Usage qw( pod2usage );
    1717
    18 my ($uri, $last_fileset);
     18my ($uri, $last_fileset, $timeout);
    1919
    2020GetOptions(
    2121    'uri|u=s'           => \$uri,
    2222    'last_fileset|l=s'  => \$last_fileset,
     23    'timeout|t'         => \$timeout,
    2324) or pod2usage( 2 );
    2425
     
    2930) unless defined $uri;
    3031
     32# default http request timeout is 30s
     33$timeout ||= 30;
     34
    3135my %p = (
    3236    uri     => $uri,
     
    3539$p{last_fileset} = $last_fileset if defined $last_fileset;
    3640
    37 my $response = DataStore::Product->new(%p)->request;
     41my $response = DataStore::Product->new(%p)->request(
     42        ua_args  => { timeout => $timeout },
     43    );
    3844
    3945die "request failed" unless defined $response;
     
    8288This flag is optional.
    8389
     90=item * --timeout|-t
     91
     92The ammount of time (in seconds) to wait for a response from the DataStore
     93after making an HTTP request.  The default is 30s.
     94
     95Optional.
     96
    8497=back
    8598
     
    98111=head1 COPYRIGHT
    99112
    100 Copyright (C) 2006  Joshua Hoblitt.  All rights reserved.
     113Copyright (C) 2006-2008  Joshua Hoblitt.  All rights reserved.
    101114
    102115This program is free software; you can redistribute it and/or modify it under
     
    118131=head1 SEE ALSO
    119132
    120 L<DataStore>, L<DataStore::Product>, L<DataStore::FileSet>
     133L<dsget>, L<dsleech>, L<dsrootls>, L<dsproductls>, L<dsfilesetls>, L<DataStore>
    121134
    122135=cut
  • trunk/DataStore/scripts/dsrootls

    r14879 r17637  
    11#!/usr/bin/env perl
    22
    3 # Copyright (C) 2006-2007  Joshua Hoblitt
     3# Copyright (C) 2006-2008  Joshua Hoblitt
    44#
    5 # $Id: dsrootls,v 1.1 2007-09-18 04:15:09 jhoblitt Exp $
     5# $Id: dsrootls,v 1.2 2008-05-12 22:04:53 jhoblitt Exp $
    66
    77use strict;
     
    1616use Pod::Usage qw( pod2usage );
    1717
    18 my ($uri);
     18my ($uri, $timeout);
    1919
    2020GetOptions(
    21     'uri|u=s'           => \$uri,
     21    'uri|u=s'       => \$uri,
     22    'timeout|t'     => \$timeout,
    2223) or pod2usage( 2 );
    2324
     
    2829) unless defined $uri;
    2930
     31# default http request timeout is 30s
     32$timeout ||= 30;
     33
    3034my %p = (
    3135    uri     => $uri,
    3236);
    3337
    34 my $response = DataStore::Root->new(%p)->request;
     38my $response = DataStore::Root->new(%p)->request(
     39        ua_args  => { timeout => $timeout },
     40    );
    3541
    3642die "request failed" unless defined $response;
     
    7884The URI of the file to be retrieved.
    7985
     86=item * --timeout|-t
     87
     88The ammount of time (in seconds) to wait for a response from the DataStore
     89after making an HTTP request.  The default is 30s.
     90
     91Optional.
     92
    8093=back
    8194
     
    94107=head1 COPYRIGHT
    95108
    96 Copyright (C) 2006-2007  Joshua Hoblitt.  All rights reserved.
     109Copyright (C) 2006-2008  Joshua Hoblitt.  All rights reserved.
    97110
    98111This program is free software; you can redistribute it and/or modify it under
     
    114127=head1 SEE ALSO
    115128
    116 L<DataStore>, L<DataStore::Product>, L<DataStore::FileSet>
     129L<dsget>, L<dsleech>, L<dsrootls>, L<dsproductls>, L<dsfilesetls>, L<DataStore>
    117130
    118131=cut
Note: See TracChangeset for help on using the changeset viewer.