Changeset 8722
- Timestamp:
- Aug 31, 2006, 12:58:34 PM (20 years ago)
- Location:
- trunk/DataStore
- Files:
-
- 5 edited
-
lib/DataStore/File.pm (modified) (4 diffs)
-
lib/DataStore/Utils.pm (modified) (3 diffs)
-
t/02_fileset_parse.t (modified) (11 diffs)
-
t/05_product.t (modified) (2 diffs)
-
t/06_fileset.t (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/DataStore/lib/DataStore/File.pm
r7951 r8722 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: File.pm,v 1.1 3 2006-07-22 01:17:33 smalleExp $3 # $Id: File.pm,v 1.14 2006-08-31 22:58:34 jhoblitt Exp $ 4 4 5 5 package DataStore::File; … … 9 9 10 10 use vars qw($VERSION); 11 $VERSION = '0.0 2';11 $VERSION = '0.03'; 12 12 13 13 use base qw( DataStore::Record ); … … 229 229 my $ua = LWP::UserAgent->new; 230 230 my $request = HTTP::Request->new(GET => $self->uri); 231 my $response = $ua->request($request, $p{filename}); 231 my $filename = $p{filename}; 232 my $response = $ua->request($request, $filename); 232 233 233 234 if ($response->is_success) { 234 235 # check size 235 236 if (defined $self->bytes) { 236 my $size = stat($ p{filename})->size;237 my $size = stat($filename)->size; 237 238 if (! $self->bytes == $size) { 238 unlink $ p{filename};239 unlink $filename; 239 240 carp "uri: ", $self->uri, 240 241 " - expected size: ", $self->bytes, 241 242 " got: ", $size; 242 return; 243 # set the filename to undef to indicate an error 244 $filename = undef; 245 last; 243 246 } 244 247 } 245 248 246 249 if (defined $self->md5sum) { 247 my $md5 = file_md5_hex($ p{filename});250 my $md5 = file_md5_hex($filename); 248 251 if (! $self->md5sum eq $md5) { 249 unlink $ p{filename};252 unlink $filename; 250 253 carp "uri: ", $self->uri, 251 254 " - expected md5: ", $self->md5sum, 252 255 " got: ", $md5; 253 return; 256 # set the filename to undef to indicate an error 257 $filename = undef; 258 last; 254 259 } 255 260 } … … 261 266 code => $response->code, 262 267 status_line => $response->status_line, 263 data => $ p{filename},268 data => $filename, 264 269 request => $self, 265 270 ); -
trunk/DataStore/lib/DataStore/Utils.pm
r7951 r8722 1 1 # Copyright (C) 2006 Joshua Hoblitt 2 2 # 3 # $Id: Utils.pm,v 1. 2 2006-07-22 01:17:33 smalleExp $3 # $Id: Utils.pm,v 1.3 2006-08-31 22:58:34 jhoblitt Exp $ 4 4 5 5 package DataStore::Utils; … … 9 9 10 10 use vars qw( $VERSION ); 11 $VERSION = '0.0 1';11 $VERSION = '0.02'; 12 12 13 13 use base qw( Exporter ); … … 38 38 ); 39 39 40 $STD_FIELD = qr/^[ a-z0-9-_.]+$/;40 $STD_FIELD = qr/^[A-z0-9-_.]+$/; 41 41 $TIME_FIELD = qr/^(\d{4})-(\d\d)-(\d\d) T (\d\d):(\d\d):(\d\d) Z$/x; 42 42 $BYTE_FIELD = qr/^\d+$/; 43 43 $MD5_FIELD = qr/^[0-9a-f]{32}$/; 44 44 %KNOWN_FILE_TYPES = map { $_ => 1 } qw( chip ); 45 %KNOWN_FILESET_TYPES = map { $_ => 1 } qw( object domeflat skyflat bias dark);45 %KNOWN_FILESET_TYPES = map { $_ => 1 } qw( OBJECT BIAS DARK SKYFLAT DOMEFLAT ); 46 46 %KNOWN_PRODUCT_TYPES = map { $_ => 1 } qw( image dump ); 47 47 -
trunk/DataStore/t/02_fileset_parse.t
r7951 r8722 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 02_fileset_parse.t,v 1. 7 2006-07-22 01:17:34 smalleExp $5 # $Id: 02_fileset_parse.t,v 1.8 2006-08-31 22:58:34 jhoblitt Exp $ 6 6 7 7 use strict; … … 68 68 my $parser = DataStore::FileSet::Parser->new; 69 69 70 is($parser->parse('|2006-01-01T00:03:04Z| object'), undef,70 is($parser->parse('|2006-01-01T00:03:04Z|OBJECT'), undef, 71 71 '->parse() returns undef on failure'); 72 72 } qr/does not conform /, … … 76 76 my $parser = DataStore::FileSet::Parser->new; 77 77 78 is($parser->parse('foobar|2006-01-0100:03:04Z| object'), undef,78 is($parser->parse('foobar|2006-01-0100:03:04Z|OBJECT'), undef, 79 79 '->parse() returns undef on failure'); 80 80 } qr/does not conform /, … … 109 109 my $example1 =<<END; 110 110 # filesetID|time registered |type |telescope pointing |etime|f|airmass| 111 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |112 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |113 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |114 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |111 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 112 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 113 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 114 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 115 115 END 116 116 my $parser = DataStore::FileSet::Parser->new( … … 126 126 my $example1 =<<END; 127 127 # filesetID|time registered |type |telescope pointing |etime|f|airmass| 128 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |129 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |130 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |131 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |128 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 129 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 130 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 131 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 132 132 END 133 133 my $parser = DataStore::FileSet::Parser->new( … … 142 142 is(@$results[0]->fileset, 'otis0123456', 'correct fileset'); 143 143 is(@$results[0]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 144 is(@$results[0]->type, ' object', 'correct type');144 is(@$results[0]->type, 'OBJECT', 'correct type'); 145 145 is(@$results[0]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 146 146 … … 148 148 is(@$results[1]->fileset, 'otis0123456', 'correct fileset'); 149 149 is(@$results[1]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 150 is(@$results[1]->type, ' object', 'correct type');150 is(@$results[1]->type, 'OBJECT', 'correct type'); 151 151 is(@$results[1]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 152 152 … … 154 154 is(@$results[2]->fileset, 'otis0123456', 'correct fileset'); 155 155 is(@$results[2]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 156 is(@$results[2]->type, ' object', 'correct type');156 is(@$results[2]->type, 'OBJECT', 'correct type'); 157 157 is(@$results[2]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 158 158 … … 160 160 is(@$results[3]->fileset, 'otis0123456', 'correct fileset'); 161 161 is(@$results[3]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 162 is(@$results[3]->type, ' object', 'correct type');162 is(@$results[3]->type, 'OBJECT', 'correct type'); 163 163 is(@$results[3]->uri, 'http://foo.com/otis0123456/', 'correct uri'); 164 164 } … … 172 172 173 173 # random comment 174 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |174 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 175 175 176 176 # random comment … … 185 185 is(@$results[0]->fileset, 'otis0123456', 'correct fileset'); 186 186 is(@$results[0]->datetime, '2006-01-01T00:03:04Z', 'correct datetime'); 187 is(@$results[0]->type, ' object', 'correct type');187 is(@$results[0]->type, 'OBJECT', 'correct type'); 188 188 } -
trunk/DataStore/t/05_product.t
r6633 r8722 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 05_product.t,v 1. 4 2006-03-17 23:54:35jhoblitt Exp $5 # $Id: 05_product.t,v 1.5 2006-08-31 22:58:34 jhoblitt Exp $ 6 6 7 7 use strict; … … 108 108 my $string = <<END; 109 109 # filesetID|time registered |type |telescope pointing |etime|f|airmass| 110 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |111 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |112 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |113 otis0123456|2006-01-01T00:03:04Z| object|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 |110 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 111 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 112 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 113 otis0123456|2006-01-01T00:03:04Z|OBJECT|11:00:10.33 68:26:59.6 2000|30.0 |r|1.23 | 114 114 END 115 115 -
trunk/DataStore/t/06_fileset.t
r6649 r8722 3 3 # Copyright (C) 2006 Joshua Hoblitt 4 4 # 5 # $Id: 06_fileset.t,v 1. 7 2006-03-20 22:03:29jhoblitt Exp $5 # $Id: 06_fileset.t,v 1.8 2006-08-31 22:58:34 jhoblitt Exp $ 6 6 7 7 use strict; … … 36 36 fileset => '12buckelyourshoe', 37 37 datetime => '2042-01-01T00:00:00Z', 38 type => ' object',38 type => 'OBJECT', 39 39 ); 40 40 … … 47 47 fileset => '12buckelyourshoe', 48 48 datetime => '2042-01-01T00:00:00Z', 49 type => ' object',49 type => 'OBJECT', 50 50 foo => 1, 51 51 ); … … 119 119 fileset => '12buckelyourshoe', 120 120 datetime => '2042-01-01T00:00:00Z', 121 type => ' object',121 type => 'OBJECT', 122 122 ); 123 123 … … 130 130 fileset => '12buckelyourshoe', 131 131 datetime => '2042-01-01T00:00:00Z', 132 type => ' object',132 type => 'OBJECT', 133 133 ); 134 134 … … 157 157 fileset => '12buckelyourshoe', 158 158 datetime => '2042-01-01T00:00:00Z', 159 type => ' object',159 type => 'OBJECT', 160 160 ); 161 161
Note:
See TracChangeset
for help on using the changeset viewer.
