view release on metacpan or search on metacpan
0.128 2019-04-14 T. R. Wyant
Update canned status table for decay of
- Iridium 55
- Iridium 58
- Iridium 64
- Iridium 95
Do Space Track tests with dummy data by default. You can test live
by setting environment variable SPACETRACK_TEST_LIVE to a true
value.
0.127 2019-03-21 T. R. Wyant
Update canned status table for decay of
- Iridium 14
- Iridium 32
- Iridium 59
- Iridium 60
- Iridium 91
Change verify_hostname default back to true, since it appears that
Perl is accepting Mike McCants' Cert again.
0.088 2014-08-31 T. R. Wyant
Properly apply Space Track default fetch options when the options were
passed to a Space Track search method in a hash reference, rather
than command-line style.
0.087 2014-08-29 T. R. Wyant
Use global variable $SPACETRACK_DELAY_SECONDS to control the delay
between Space Track queries. This is initialized from environment
variable SPACETRACK_DELAY_SECONDS if it is true; otherwise it is
initialized to 3.
Throttle Space Track queries to 1 every 3 seconds. Space Track
announced August 19 2014 that they intend to throttle queries to
less than 20 per minute per user as of September 22 2014. They seem
to have jumped the gun though, since throttling seems necessary now.
Remove all RCS-specific functionality. This includes making -rcs do
nothing. On August 18 2014 Space Track started returning 0 for RCS,
instead going for "small," "medium," and "large" in a new JSON
field. The -rcs option is now deprecated, and being put through the
usual deprecation cycle.
Set default value of verify_hostname attribute to false. This is
because Perl does not accept Mike McCants' GoDaddy certificate. The
default can be overridden using environment variable
SPACETRACK_VERIFY_HOSTNAME if it is defined.
Remove all references to obsolete spacetrack() canned queries
full_fast and geosynchronous_fast in the documentation. The queries
themselves are long gone.
Prepare for removal of the RCSVALUE datum in Space Track's satcat
data, which is announced for August 18 2014.
Add 'prompt' attribute.
0.084 2014-01-01 T, R, Wyant
Have celestrak() and celestrak_supplemental() return error status if
the argument is undefined.
Drop deprecated spacetrack() catalogs full_fast and
geosynchronous_fast.
Add celestrak_supplemental() catalog 'ses'.
Remove support for environment variables SPACETRACK_REST_RANGE_OPERATOR
and SPACETRACK_REST_FRACTIONAL_DATE.
0.083 2013-11-23 T. R. Wyant
Add Space Track search option -comment. This adds the Comment field to
the satcat results returned by the search_* methods.
0.082 2013-11-08 T. R. Wyant
Use O-O version of Getopt::Long to parse command-style options, to
prevent configuration leaking in (or out). This requires
Getopt::Long 2.39.
Validate options passed as a hash reference, at least for unexpected
keys. The previous version simply ignored these, but I decided I
wanted feedback to the caller. It is a warning for now, but will
eventually become fatal.
Environment variable SPACETRACK_SKIP_OPTION_HASH_VALIDATION can be set
to suppress the warning.
0.081 2013-10-21 T. R. Wyant
Add object status 'TBA' (added by Space Track October 1 2013). This
_should_ only affect the -exclude option.
Delete commented-out code that goes back to the v1 interface.
Build queries using standard names and data represenations, rather
than Space-Track-specific ones. This change _should_ not affect the
0.077 2013-07-15 T. R. Wyant
Make it an error to set space_track_version to 1. Eliminate all
documentation of the version 1 API, and make version 2 documentaion
not refer to API version. Code for the version 1 API will be removed
in subsequent releases.
0.076 2013-07-01 T. R. Wyant
Deprecated spacetrack() queries (the *_fast ones) become fatal.
Document intent to remove support for environment variables
SPACETRACK_REST_RANGE_OPERATOR and SPACETRACK_REST_FRACTIONAL_DATE
in the first release after January 1 2014.
Install the SpaceTrack script by default.
Eliminate prompting for whether to install SpaceTrack. The -y and -n
options are still available.
Move the SpaceTrackTk script to the eg/ directory.
Eliminate Win32 and VMS specific code in the installers.
Add 'YUN' (Yunsong, DPRK) to hard-coded list of launch sites returned
by the Space Track REST interface.
Re-instate the use of hour, minute, and second spacifications in
-start_epoch and -end_epoch for the Space Track REST interface.
Go back to using OID ranges in the retrieve() method if the Space
Track REST interface is being used.
Document environment varoables SPACETRACK_REST_RANGE_OPERATOR and
SPACETRACK_REST_FRACTIONAL_DATE, so users can get themselves going
again if there are further glitches in the related functionality.
Add method celestrak_supplemental() to retrieve the supplemental TLEs
not derived from SpaceTrack.
Correct bug in celestrak() method, in which the Space Track REST
options were being parsed when they should not have been. This was
really two bugs: use of get() rather than getv() to check the Space
Track version, and failure to check the 'direct' attribute.
before un-quoting and un-escaping the data, so that we have a way to
force something that looks like a redirection to be taken as an
argument.
Add ':' to the list of 'safe' characters when URI-escaping arguments
to the Space Track REST interface. Percent-encoded colons seemed to
stop working some time between 13:15 and 19:15 GMT on July 27 2012.
Un-encoded colons go through fine.
Accept ':' as well as '/' as punctuation between username and password
in environment variable SPACETRACK_USER.
Have t/query.t try to load Term::ReadKey. If successful, it uses it to
turn off password echoing. If not successful, it adds '(ECHOED)' to
the prompt.
Fix problem associating RCS data with TLEs when using version 1 of the
Space Track interface and the OID in the search results is less than
five digits.
Change default value of verify_hostname attribute to false. And about
Manufactured pristine HTTP::Response for successsful
login call.
Added source method, for passing the contents of a file
to the shell method
Skip username and password prompts, and login and
retrieval tests if environment variable
AUTOMATED_TESTING is true and environment variable
SPACETRACK_USER is undefined.
0.003 2005-03-26 T. R. Wyant
Initial release to CPAN.
If your tar supports it, you can use the -z qualifier (i.e. 'tar -xzf')
and skip the 'gunzip' step. You can also skip 'make' if you do 'make
test', since 'make test' implies 'make'.
The 'make test' step of the installation will ask you for your Space
Track username and password. This prompt can be supressed in a number
of ways:
* Set environment variable AUTOMATED_TESTING to a true value. This
will cause all tests that access the Space Track web site to be
skipped.
* Set environment variable SPACETRACK_USER to your username, a slash,
and your password. If you do this incorrectly, the tests that access
the Space Track website will fail.
If you do not have a Space Track account, a return when prompted for
your username will also cause the tests that access the Space Track
database to be skipped.
Note that once you have done the "make" step you can play with either of
the two specimen applications provided (SpaceTrack for a command-line
version, or SpaceTrackTk for the Perl/Tk windowed version). If you want
celestrak
This script retrieves data from Celestrak.com. By default, it
retrieves the list of 100 (or so) brightest. You can also
specify one or more lists to retrieve on the command line. If
you specify a non-existent list you will get an error stating
what lists are available.
spacetrack-identity
This script prints the username and password in a format appropriate
to create environment variable SPACETRACK_USER via a shell eval.
sh_script
This shell script illustrates the retrieval of data for the
International Space Station directly from the Space Track web site
using the SpaceTrack application. Output can be redirected to a
file. This script requires environment variable SPACETRACK_USER to
be set to a valid Space Track username/password (separated by "/"),
and will complain if this is not done. It also requires file
sh_data to be in the default directory.
sh_data
This text file contains the SpaceTrack commands used by sh_script.
SpaceTrackTk
This Perl script is a Perl/Tk client for the Space Track
functionality.
eg/sh_script view on Meta::CPAN
#!/bin/sh
identity=
if [ -r "$HOME/.spacetrack-identity" ]
then
identity=-identity
fi
if [ "$identity" = "" -a "$SPACETRACK_USER" = "" ]
then
echo "
You must either set environment variable SPACETRACK_USER to your
Spacetrack username/password or install Config::Identity and create
~/.spacetrack-identity for this script to work. E.g.:
$ export SPACETRACK_USER=username/password
"
else
if [ -d blib ]
then
perl -Mblib script/SpaceTrack -filter $identity <eg/sh_data
else
SpaceTrack -filter $identity <sh_data
fi
fi
eg/spacetrack-identity view on Meta::CPAN
) or pod2usage( { -verbose => 0 } );
if ( defined $opt{hide} ) {
hide( $opt{hide} );
exit;
}
my $st;
eval {
# Default identity to true
local $ENV{SPACETRACK_IDENTITY} = 1;
$st = Astro::SpaceTrack->new();
} or die "Unable to instantiate Astro::SpaceTrack\n";
my %info;
foreach my $key ( qw{ username password } ) {
defined( $info{$key} = $st->getv( $key ) )
or die "Unable to determine $key\n";
}
my $delim = $opt{basic} ? ':' : '/';
print "SPACETRACK_USER=$info{username}$delim$info{password}\n";
sub hide {
my ( $hide ) = @_;
my $id_file = Astro::SpaceTrack->__identity_file_name();
my $hidden_file = "$id_file-hidden";
my ( $from, $to, $name ) = $hide ? ( $id_file, $hidden_file, 'ID' ) : (
$hidden_file, $id_file, 'Hidden' );
-f $from
or die "$name file $from not found\n";
rename $from, $to
eg/spacetrack-identity view on Meta::CPAN
=head2 -version
This option displays the version of this script. The script then exits.
=head1 DETAILS
This Perl script reports the user's Space Track identity. On success,
the output is
SPACETRACK_USER=username/password
unless C<-basic> is specified, in which case you get a colon (C<':'>)
rather than a slash (C<'/'>).
On failure, the script dies.
=head1 AUTHOR
Tom Wyant (wyant at cpan dot org)
inc/Mock/LWP/UserAgent.pm view on Meta::CPAN
use JSON;
our $VERSION = '0.168';
our $CANNED_RESPONSE_FILE;
use constant REF_HASH => ref {};
sub install_mock {
$Astro::SpaceTrack::SPACETRACK_DELAY_SECONDS = 0;
no warnings qw{ redefine };
*LWP::UserAgent::new = sub {
my ( $class, @arg ) = @_;
### my $self = $class->SUPER::new( @arg );
my $self = bless {}, $class;
$self->{ +__PACKAGE__ } = __load_data();
return $self;
};
inc/Mock/LWP/UserAgent.pm view on Meta::CPAN
will be satisfied by an L<HTTP::Response|HTTP::Response> object
generated from the data in the file. If the URL and method do not appear
in the file, a 404 response is generated.
=head1 METHODS
This class supports the following public method:
=head2 install_mock
This static method sets C<$Astro::SpaceTrack::SPACETRACK_DELAY_SECONDS>
to zero. It also hot-patches the following
L<LWP::UserAgent|LWP::UserAgent> methods:
=head3 new
my $ua = LWP::UserAgent->new();
This static method instantiates the object.
It calls subroutine (B<not> method) L<__load_data()|/__load_data> to
inc/My/Module/Test.pm view on Meta::CPAN
our @ISA = qw{ Exporter };
use HTTP::Date;
use HTTP::Status qw{ :constants };
use Test::More 0.96; # For subtest
our $VERSION = '0.168';
# Set the following to zero if Space Track (or any other SSL host)
# starts using a certificate that can not be verified.
use constant VERIFY_HOSTNAME => defined $ENV{SPACETRACK_VERIFY_HOSTNAME}
? $ENV{SPACETRACK_VERIFY_HOSTNAME}
: 0;
our @EXPORT = ## no critic (ProhibitAutomaticExportation)
qw{
is_error
is_error_or_skip
is_not_success
is_success
is_success_or_skip
last_modified
inc/My/Module/Test.pm view on Meta::CPAN
VERIFY_HOSTNAME
};
use constant HASH_REF => ref {};
use constant REGEXP_REF => ref qr{};
use constant NO_SPACE_TRACK_ACCOUNT => 'No Space-Track account provided';
# Deliberately not localized, to prevent unwanted settings from sneaking
# in from the user's identity file.
$Astro::SpaceTrack::SPACETRACK_IDENTITY_KEY = {
map { $_ => 1 } qw{ username password } };
my $rslt;
sub is_error { ## no critic (RequireArgUnpacking)
my ( $obj, $method, @args ) = @_;
my ( $code, $name ) = splice @args, -2, 2;
$rslt = eval { $obj->$method( @args ) };
$rslt or do {
@_ = ( "$name threw exception: $@" );
inc/My/Module/Test.pm view on Meta::CPAN
},
'www.amsat.org' => {
url => 'https://www.amsat.org/',
},
'www.space-track.org' => {
url => 'https://www.space-track.org/',
check => \&__spacetrack_skip,
}
);
if ( defined $ENV{ASTRO_SPACETRACK_SKIP_SITE} ) {
foreach my $site ( split qr{ \s* , \s* }smx,
$ENV{ASTRO_SPACETRACK_SKIP_SITE} ) {
exists $info{$site}{url}
and $skip_site{$site} = "$site skipped by user request";
}
}
}
sub __site_to_check_uri {
my ( $site ) = @_;
return $info{$site}{url};
}
inc/My/Module/Test.pm view on Meta::CPAN
};
return;
}
{
my $spacetrack_auth;
sub __spacetrack_skip {
my ( %arg ) = @_;
defined $spacetrack_auth
or $spacetrack_auth = $ENV{SPACETRACK_USER};
defined $spacetrack_auth
and $spacetrack_auth =~ m< \A [:/] \z >smx
and return NO_SPACE_TRACK_ACCOUNT;
$spacetrack_auth
and return;
$ENV{AUTOMATED_TESTING}
and return 'Automated testing and SPACETRACK_USER not set.';
$spacetrack_auth = __spacetrack_identity()
and do {
$arg{envir}
and $ENV{SPACETRACK_USER} = $spacetrack_auth; ## no critic (RequireLocalizedPunctuationVars)
return;
};
$arg{no_prompt}
and return $arg{no_prompt};
$^O eq 'VMS' and do {
warn <<'EOD';
Several tests will be skipped because you have not provided logical
name SPACETRACK_USER. This should be set to your Space Track username
and password, separated by a slash ("/") character.
EOD
return 'No Space-Track account provided.';
};
warn <<'EOD';
Several tests require the username and password of a registered Space
Track user. Because you have not provided environment variable
SPACETRACK_USER, you will be prompted for this information. The password
will be echoed unless Term::ReadKey is installed and supports ReadMode.
If you leave either username or password blank, the tests will be
skipped.
If you set environment variable SPACETRACK_USER to your Space Track
username and password, separated by a slash ("/") character, that
username and password will be used, and you will not be prompted.
You may also supress prompts by setting the AUTOMATED_TESTING
environment variable to any value Perl takes as true. This is
equivalent to not specifying a username, and tests that require a
username will be skipped.
EOD
my $user = prompt( 'Space-Track username' )
and my $pass = prompt( { password => 1 }, 'Space-Track password' )
or do {
$ENV{SPACETRACK_USER} = '/'; ## no critic (RequireLocalizedPunctuationVars)
return NO_SPACE_TRACK_ACCOUNT;
};
$ENV{SPACETRACK_USER} = $spacetrack_auth = "$user/$pass"; ## no critic (RequireLocalizedPunctuationVars)
return;
}
}
sub spacetrack_skip_no_prompt {
my $skip;
$ENV{SPACETRACK_TEST_LIVE}
or plan skip_all => 'SPACETRACK_TEST_LIVE not set';
defined( $skip = __spacetrack_skip(
envir => 1,
no_prompt => NO_SPACE_TRACK_ACCOUNT,
)
) and plan skip_all => $skip;
return;
}
sub spacetrack_user {
__spacetrack_skip( envir => 1 );
inc/My/Module/Test.pm view on Meta::CPAN
skip indicator appropriately. Allowed site names are:
celestrak.org
mike.mccants
rod.sladen
www.amsat.org
www.space-track.org
=head2 spacetrack_user
If C<$ENV{SPACETRACK_USER}> is not set, this subroutine sets it to
whatever value is obtained from the identity file if available, or by
prompting the user. The environment variable is B<not> localized.
=head2 throws_exception
is_error $st, fubar => 666,
'The exception of the beast',
'Make sure $st->fubar( 666 ) throws the correct exception';
This subroutine executes the given method and succeeds if the method
lib/Astro/SpaceTrack.pm view on Meta::CPAN
use POSIX ();
use Scalar::Util 1.07 ();
use Text::ParseWords ();
use Time::Local ();
use URI qw{};
# use URI::Escape qw{};
# Number of OIDs to retrieve at once. This is a global variable so I can
# play with it, but it is neither documented nor supported, and I
# reserve the right to change it or delete it without notice.
our $RETRIEVAL_SIZE = $ENV{SPACETRACK_RETRIEVAL_SIZE};
defined $RETRIEVAL_SIZE or $RETRIEVAL_SIZE = 200;
use constant COPACETIC => 'OK';
use constant BAD_SPACETRACK_RESPONSE =>
'Unable to parse SpaceTrack response';
use constant INVALID_CATALOG =>
'Catalog name %s invalid. Legal names are %s.';
use constant LAPSED_FUNDING => 'Funding lapsed.';
use constant LOGIN_FAILED => 'Login failed';
use constant NO_CREDENTIALS => 'Username or password not specified.';
use constant NO_CAT_ID => 'No catalog IDs specified.';
use constant NO_OBJ_NAME => 'No object name specified.';
use constant NO_RECORDS => 'No records found.';
lib/Astro/SpaceTrack.pm view on Meta::CPAN
first defined value it finds in the following list:
=over
=item a value explicitly specified as an argument to C<new()>;
=item a value from the L<IDENTITY FILE|/IDENTITY FILE>, if the
C<identity> attribute is explicitly specified as true and
L<Config::Identity|Config::Identity> is installed;
=item a value from environment variable C<SPACETRACK_USER> if that has a
non-empty value;
=item a value from the L<IDENTITY FILE|/IDENTITY FILE>, if the
C<identity> attribute defaulted to true and
L<Config::Identity|Config::Identity> s installed;
=item a value from environment variable C<SPACETRACK_OPT>.
=back
The reason for preferring C<SPACETRACK_USER> over an identity file value
taken by default is that I have found that under Mac OS X an SSH session
does not have access to the system keyring, and
L<Config::Identity|Config::Identity> provides no other way to specify
the passphrase used to decrypt the private key. I concluded that if the
user explicitly requested an identity that it should be preferred to
anything from the environment, but that, for SSH access to be usable, I
needed to provide a source of username and password that would be taken
before the L<IDENTITY FILE|/IDENTITY FILE> was tried by default.
Proxies are taken from the environment if defined. See the ENVIRONMENT
lib/Astro/SpaceTrack.pm view on Meta::CPAN
username => undef, # Login username.
verbose => undef, # Verbose error messages for catalogs.
verify_hostname => 1, # Don't verify host names by default.
webcmd => undef, # Command to get web help.
with_name => undef, # True to retrieve three-line element sets.
};
bless $self, $class;
$self->set( identity => delete $arg{identity} );
$ENV{SPACETRACK_OPT} and
$self->set (grep {defined $_} split '\s+', $ENV{SPACETRACK_OPT});
# TODO this makes no sense - the first branch of the if() can never
# be executed because I already deleted $arg{identity}. But I do not
# want to execute the SPACETRACK_USER code willy-nilly -- maybe warn
# if identity is 1 and I don't have both a username and a password.
if ( defined( my $id = delete $arg{identity} ) ) {
$self->set( identity => $id );
} elsif ( $ENV{SPACETRACK_USER} ) {
my ($user, $pass) = split qr{ [:/] }smx, $ENV{SPACETRACK_USER}, 2;
'' ne $user
and '' ne $pass
or $user = $pass = undef;
$self->set (username => $user, password => $pass);
} else {
$self->set( identity => undef );
}
defined $ENV{SPACETRACK_VERIFY_HOSTNAME}
and $self->set( verify_hostname =>
$ENV{SPACETRACK_VERIFY_HOSTNAME} );
keys %arg
and $self->set( %arg );
return $self;
}
=for html <a name="amsat"></a>
=item $resp = $st->amsat ()
lib/Astro/SpaceTrack.pm view on Meta::CPAN
and return( $self->attribute_names() );
my $re = qr/ \A \Q$text\E /smx;
return( sort grep { $_ =~ $re } $self->attribute_names() );
}
sub get {
my ( $self, $name ) = @_;
delete $self->{_pragmata};
my $code = $self->can( "_get_attr_$name" ) || $self->can( 'getv' );
my $value = $code->( $self, $name );
my $resp = HTTP::Response->new( HTTP_OK, COPACETIC, undef, $value );
$self->_add_pragmata( $resp,
'spacetrack-type' => 'get',
);
$self->__dump_response( $resp );
return wantarray ? ($resp, $value ) : $resp;
}
# Called dynamically
sub _get_attr_dump_headers { ## no critic (Subroutines::ProhibitUnusedPrivateSubroutines)
my ( $self, $name ) = @_;
lib/Astro/SpaceTrack.pm view on Meta::CPAN
( my $data = $accumulator->( $self ) )
or return HTTP::Response->new ( HTTP_NOT_FOUND, NO_RECORDS );
ref $data
and $data = $self->_get_json_object()->encode( $data );
$no_execute
and return HTTP::Response->new(
HTTP_I_AM_A_TEAPOT, undef, undef, $data );
my $resp = HTTP::Response->new( HTTP_OK, COPACETIC, undef,
$data );
$self->_convert_content( $resp );
$self->_add_pragmata( $resp,
'spacetrack-type' => 'orbit',
'spacetrack-source' => 'spacetrack',
'spacetrack-interface' => 2,
);
return $resp;
}
lib/Astro/SpaceTrack.pm view on Meta::CPAN
my $name = shift @args;
Carp::croak "Attribute $name may not be set. Legal attributes are ",
join (', ', sort keys %mutator), ".\n"
unless $mutator{$name};
my $value = $args[0];
$mutator{$name}->( $self, $name, $value, \@args );
shift @args;
}
@args
and Carp::croak __PACKAGE__, "->set() specifies no value for @args";
my $resp = HTTP::Response->new( HTTP_OK, COPACETIC, undef, COPACETIC );
$self->_add_pragmata( $resp,
'spacetrack-type' => 'set',
);
$self->__dump_response( $resp );
return $resp;
}
=for html <a name="shell"></a>
lib/Astro/SpaceTrack.pm view on Meta::CPAN
For C<< basicspacedata => 'query' >> and C<< class => 'tle' >> or
C<'tle_latest'>,
Pragma: spacetrack-type = orbit
Pragma: spacetrack-source = spacetrack
Pragma: spacetrack-interface = 2
=cut
{
our $SPACETRACK_DELAY_SECONDS = $ENV{SPACETRACK_DELAY_SECONDS} || 3;
my $spacetrack_delay_until;
sub _spacetrack_delay {
my ( $self ) = @_;
$SPACETRACK_DELAY_SECONDS
or return;
$self->{dump_headers} & DUMP_DRY_RUN
and return;
if ( defined $spacetrack_delay_until ) {
my $now = _time();
$now < $spacetrack_delay_until
and _sleep( $spacetrack_delay_until - $now );
}
$spacetrack_delay_until = _time() + $SPACETRACK_DELAY_SECONDS;
return;
}
}
{
my %tle_class = map { $_ => 1 } qw{ tle tle_latest };
sub spacetrack_query_v2 {
my ( $self, @args ) = @_;
lib/Astro/SpaceTrack.pm view on Meta::CPAN
This method updates the named TLE file, which must be in JSON format. On
a successful update, the content of the returned HTTP::Response object
is the updated TLE data, in whatever format is desired. If any updates
were in fact found, the file is rewritten. The rewritten JSON will be
pretty if the C<pretty> attribute is true.
The file to be updated can be generated by using the C<-json> option on
any of the methods that accesses Space Track data. For example,
# Assuming $ENV{SPACETRACK_USER} contains
# username/password
my $st = Astro::SpaceTrack->new(
pretty => 1,
);
my $rslt = $st->spacetrack( { json => 1 }, 'iridium' );
$rslt->is_success()
or die $rslt->status_line();
open my $fh, '>', 'iridium.json'
or die "Failed to open file: $!";
print { $fh } $rslt->content();
lib/Astro/SpaceTrack.pm view on Meta::CPAN
or return;
local $/ = undef;
my $content = <$fh>;
close $fh;
return $content =~ m/ \Q----BEGIN PGP MESSAGE----\E /smx;
}
sub _mutate_identity {
my ( $self, $name, $value ) = @_;
defined $value
or $value = $ENV{SPACETRACK_IDENTITY};
if ( $value and my $identity = __spacetrack_identity() ) {
$self->set( %{ $identity } );
}
return ( $self->{$name} = $value );
}
=for html <a name="flush_identity_cache"></a>
=item Astro::SpaceTrack->flush_identity_cache();
lib/Astro/SpaceTrack.pm view on Meta::CPAN
my $pkg = $1;
my $code = $pkg->can( "_${caller}_opts" )
or Carp::confess "Bug - _${caller}_opts not found";
$lgl_opts = $code->();
}
my $opt;
if ( HASH_REF eq ref $args[0] ) {
$opt = { %{ shift @args } }; # Poor man's clone.
# Validation is new, so I insert a hack to turn it off if need
# be.
unless ( $ENV{SPACETRACK_SKIP_OPTION_HASH_VALIDATION} ) {
my %lgl = _extract_keys( $lgl_opts );
my @bad;
foreach my $key ( keys %{ $opt } ) {
$lgl{$key}
or push @bad, $key;
}
@bad
and _parse_args_failure(
carp => 1,
name => \@bad,
legal => { @{ $lgl_opts } },
suffix => <<'EOD',
You cam suppress this warning by setting environment variable
SPACETRACK_SKIP_OPTION_HASH_VALIDATION to a value Perl understands as
true (say, like 1), but this should be considered a stopgap while you
fix the calling code, or have it fixed, since my plan is to make this
fatal.
EOD
);
}
} else {
$opt = {};
my %lgl = @{ $lgl_opts };
$go->getoptionsfromarray(
lib/Astro/SpaceTrack.pm view on Meta::CPAN
identity file.
I have found that C<gpg> does not seem to work nicely, even though
L<Config::Identity|Config::Identity> prefers it to C<gpg2> if both are
present. The L<Config::Identity|Config::Identity> documentation says
that you can override this by setting environment variable C<CI_GPG>
to the executable you want used.
If this attribute is unspecified (to C<new()> or specified as C<undef>
(to C<new()> or C<set()>), the value of environment variable
C<SPACETRACK_IDENTITY> will be used as the new value.
When a new object is instantiated, the identity is processed first; in
this way attribute values that come from the environment or are
specified explicitly override those that come from the identity file. If
you explicitly set this on an already-instantiated object, the attribute
values from the identity file will replace those in the object.
When you instantiate an object, the identity from environment variable
C<SPACETRACK_USER> will be preferred over the value from the identity
file, if any, even if the C<identity> attribute is explicitly set true.
=item iridium_status_format (string)
This attribute specifies the default format of the data returned by the
C<iridium_status()> method. Valid values are 'kelso', 'sladen' or
'spacetrack'. See that method for more information.
As of version 0.100_02, the default is C<'kelso'>. It used to be
C<'mccants'>, but Mike McCants no longer maintains his Iridium status
lib/Astro/SpaceTrack.pm view on Meta::CPAN
certificates set up, so in 0.064_01 the default became false again.
* On August 19 2014 Perl's SSL logic stopped accepting Mike McCants'
GoDaddy certificate, so starting with version 0.086_02 the default is
false once again.
* On December 11 2014 I noticed that Perl was accepting Mike McCants'
certificate again, so starting with version 0.088_01 the default
is restored to true.
If environment variable C<SPACETRACK_VERIFY_HOSTNAME> is defined, its
value will be used as the default of this attribute. Otherwise the
default is false (i.e. 0).
=item webcmd (string)
This attribute specifies a system command that can be used to launch
a URL into a browser. If specified, the 'help' command will append
a space and the metacpan.org URL for the documentation for this
version of Astro::SpaceTrack, and spawn that command to the operating
system. You can use 'open' under Mac OS X, and 'start' under Windows.
lib/Astro/SpaceTrack.pm view on Meta::CPAN
running script to see new identity file information you must call static
method C<flush_identity_cache()>.
=head1 GLOBALS
The following globals modify the behaviour of this class. If you modify
their values, your modifications should be properly localized. For
example:
{
local $SPACETRACK_DELAY_SECONDS = 42;
$rslt = $st->search_name( 'iss' );
}
=head2 $SPACETRACK_DELAY_SECONDS
This global holds the delay in seconds between queries. It defaults to 3
(or the value of environment variable C<SPACETRACK_DELAY_SECONDS> if
that is true), and should probably not be messed with. But if Space
Track is being persnickety about timing you can set it to a larger
number. This variable must be set to a number. If
L<Time::HiRes|Time::HiRes> is not available this number must be an
integer.
This global is not exported. You must refer to it as
C<$Astro::SpaceTrack::SPACETRACK_DELAY_SECONDS>.
=head1 ENVIRONMENT
The following environment variables are recognized by Astro::SpaceTrack.
=head2 SPACETRACK_DELAY_SECONDS
This environment variable should be set to a positive number to change
the default delay between Space Track queries. This is C<not> something
you should normally need to do. If L<Time::HiRes|Time::HiRes> is not
available this number must be an integer.
This environment variable is only used to initialize
C<$SPACETRACK_DELAY_SECONDS>. If you wish to change the delay you must
assign to the global.
=head2 SPACETRACK_IDENTITY
This environment variable specifies the default value for the identity
attribute any time an undefined value for that attribute is specified.
=head2 SPACETRACK_OPT
If environment variable SPACETRACK_OPT is defined at the time an
Astro::SpaceTrack object is instantiated, it is broken on spaces,
and the result passed to the set command.
If you specify username or password in SPACETRACK_OPT and you also
specify SPACETRACK_USER, the latter takes precedence, and arguments
passed explicitly to the new () method take precedence over both.
=head2 SPACETRACK_TEST_LIVE
If environment variable C<SPACETRACK_TEST_LIVE> is defined to a true
value (in the Perl sense), tests that use the Space Track web site will
actually access it. Otherwise they will either use canned data (i.e. a
regression test) or be skipped.
=head2 SPACETRACK_USER
If environment variable SPACETRACK_USER is defined at the time an
Astro::SpaceTrack object is instantiated, the username and password will
be initialized from it. The value of the environment variable should be
the username and password, separated by either a slash (C<'/'>) or a
colon (C<':'>). That is, either C<'yehudi/menuhin'> or
C<'yehudi:menuhin'> are accepted.
An explicit username and/or password passed to the new () method
overrides the environment variable, as does any subsequently-set
username or password.
=head2 SPACETRACK_VERIFY_HOSTNAME
As of version 0.086_02, if environment variable
C<SPACETRACK_VERIFY_HOSTNAME> is defined at the time an
C<Astro::SpaceTrack> object is instantiated, its value will be used for
the default value of the C<verify_hostname> attribute.
=head2 SPACETRACK_SKIP_OPTION_HASH_VALIDATION
As of version 0.081_01, method options passed as a hash reference will
be validated. Before this, only command-line-style options were
validated. If the validation causes problem, set this environment
variable to a value Perl sees as true (i.e. anything but C<0> or C<''>)
to revert to the old behavior.
Support for this environment variable will be put through a deprecation
cycle and removed once the validation code is deemed solid.
t/data/Mock-LWP-UserAgent/resp.json view on Meta::CPAN
"https://www.space-track.org/basicspacedata/query/class/tle_latest/NORAD_CAT_ID/25544" : {
"GET" : [
"200",
"OK",
[
"Content-Type",
"application/json",
"Status",
"200"
],
"[\n {\n \"COMMENT\" : \"GENERATED VIA SPACETRACK.ORG API\",\n \"FILE\" : \"2434103\",\n \"INTLDES\" : \"98067A\",\n \"NORAD_CAT_ID\" : \"25544\",\n \"OBJECT_ID\" : \"1998-067A\",\n \"OBJECT_NAME\" : \"ISS (ZA...
]
},
"https://www.space-track.org/basicspacedata/query/class/tle_latest/format/3le/orderby/OBJECT_NUMBER%20asc/OBJECT_NUMBER/25544/ORDINAL/1" : {
"GET" : [
"200",
"OK",
[
"Content-Type",
"text/plain; charset=UTF-8",
"Set-Cookie",
t/data/Mock-LWP-UserAgent/resp.json view on Meta::CPAN
"200",
"OK",
[
"Content-Type",
"application/json",
"Set-Cookie",
"chocolatechip=This bears no relation to any cookie set by Space Track; path=/; domain=www.space-track.org",
"Status",
"200"
],
"[\n {\n \"COMMENT\" : \"GENERATED VIA SPACETRACK.ORG API\",\n \"FILE\" : \"1681502\",\n \"INTLDES\" : \"98067A\",\n \"NORAD_CAT_ID\" : \"25544\",\n \"OBJECT_ID\" : \"1998-067A\",\n \"OBJECT_NAME\" : \"ISS (ZA...
]
},
"https://www.space-track.org/basicspacedata/query/class/tle_latest/format/tle/orderby/OBJECT_NUMBER%20asc/EPOCH/%3Enow-30/OBJECT_NAME/inmarsat~~/OBJECT_TYPE/payload/ORDINAL/1" : {
"GET" : [
"200",
"OK",
[
"Content-Type",
"text/plain;charset=UTF-8",
"Status",
t/query_mccants.t view on Meta::CPAN
# In order to try to force a cache miss, we set the access and
# modification time of the file to the epoch.
my @opt = eval { utime 0, 0, $temp->filename() } ?
( '-file' => $temp->filename() ) :
();
SKIP: {
my $do_cache_check = $ENV{AUTHOR_TEST} ||
defined $ENV{SPACETRACK_TEST_CACHE} &&
'' ne $ENV{SPACETRACK_TEST_CACHE};
my $count = 2 + ( $do_cache_check ? 3 : 0 );
is_success_or_skip( $st, 'mccants', @opt, 'mcnames',
'Get molczan-style magnitudes', $count );
is $st->content_type(), 'molczan', "Content type is 'molczan'";
is $st->content_source(), 'mccants', "Content source is 'mccants'";
ok ! $st->cache_hit(), 'Content did not come from cache';
if ( $do_cache_check ) {
my $dump = $ENV{SPACETRACK_TEST_CACHE};
defined $dump
or $dump = 0;
if ( $dump =~ m/ \A 0 (?: x [[:xdigit:]]+ | [0-7]+ ) \z /smx ) {
$dump =~ oct $dump;
} elsif ( $dump =~ m/ [^0-7] /smx ) {
$dump = $st->DUMP_NONE();
}
@opt
or BAIL_OUT 'Cache test requires functional uname()';
t/query_mccants.t view on Meta::CPAN
TODO: {
local $TODO = 'Flaky server suooprt';
ok $st->cache_hit(), 'This time content came from cache';
if ( $st->cache_hit() ) {
diag "Cache hit";
} else {
diag <<'EOD';
The above cache test seems to fail much more often than not, with the
trace information (available by setting environment variable
SPACETRACK_TEST_CACHE to 0x22) showing that the If-Modified-After header
is in fact set but the server returns 200 anyway.
EOD
diag 'Response pragmata: ', explain [
most_recent_http_response()->header( 'pragma' ) ];
diag 'Object pragmata: ', explain $obj_pragmata;
1;
}
}
is most_recent_http_response()->content(), $want,
'We got the same result from the cache as from on line';
}
} else {
note 'Cache test skipped. Neither AUTHOR_TEST nor SPACETRACK_TEST_CACHE set.';
}
}
SKIP: {
is_success_or_skip( $st, qw{ mccants quicksat },
'Get quicksat-style magnitudes', 2 );
is $st->content_type(), 'quicksat', "Content type is 'quicksat'";
t/query_spacetrack.t view on Meta::CPAN
# my $rslt;
my $space_track_domain = 'www.space-track.org';
my $st;
# Things to search for.
# NOTE that if these are changed, the corresponding canned data must be
# regenerated with tools/capture.
my $search_date = '2012-06-13';
my $start_epoch = '2012/04/01';
if ( $ENV{SPACETRACK_TEST_LIVE} ) {
diag 'live test against space track. be aware of their usage guidelines';
my $skip;
$skip = site_check( $space_track_domain ) # To make sure we have account
and plan skip_all => $skip;
$st = Astro::SpaceTrack->new(
identity => ! $ENV{SPACETRACK_USER},
verify_hostname => VERIFY_HOSTNAME,
);
} else {
require Mock::LWP::UserAgent;
Mock::LWP::UserAgent->install_mock();
note <<'EOD';
Testing against canned data. Set environment variable
SPACETRACK_TEST_LIVE to test against the actual Space Track web site,
and be aware of their usage guidelines.
EOD
$st = Astro::SpaceTrack->new(
username => 'bogua',
password => 'equally bogus',
verify_hostname => VERIFY_HOSTNAME,
);
}
t/spacetrack_request.t view on Meta::CPAN
1 25544U First line of data
2 25544 Second line of data
1 25544U First line of data
2 25544 Second line of data
EOD
$st->set( dump_headers => DUMP_REQUEST );
{
no warnings qw{ uninitialized };
local $ENV{SPACETRACK_REST_FRACTIONAL_DATE} = undef;
is_resp( qw{retrieve -start_epoch 2009-04-01 25544}, [ {
args => [
basicspacedata => 'query',
class => 'tle',
format => 'tle',
orderby => 'OBJECT_NUMBER asc',
EPOCH => '2009-04-01 00:00:00--2009-04-02 00:00:00',
OBJECT_NUMBER => 25544,
],
t/spacetrack_request.t view on Meta::CPAN
The point of the following test is to ensure that the request is being
properly broken into two pieces, and that the joining of the JSON in the
responses is being handled properly.
EOD
{
local $Astro::SpaceTrack::RETRIEVAL_SIZE = 50;
# Force undocumented hack to be turned off.
no warnings qw{ uninitialized };
local $ENV{SPACETRACK_REST_RANGE_OPERATOR} = undef;
is_resp( retrieve => 1 .. 66, [
{
args => [
basicspacedata => 'query',
class => 'tle_latest',
format => 'tle',
orderby => 'OBJECT_NUMBER asc',
OBJECT_NUMBER => '1--50',
ORDINAL => 1,
t/spacetrack_request.t view on Meta::CPAN
version => 2,
},
],
);
$st->set( dump_headers => DUMP_NONE );
is_resp( qw{ search_oid -format json 25544 },
[
{
'COMMENT' => 'GENERATED VIA SPACETRACK.ORG API',
'FILE' => '1681502',
'INTLDES' => '98067A',
'NORAD_CAT_ID' => '25544',
'OBJECT_ID' => '1998-067A',
'OBJECT_NAME' => 'ISS (ZARYA)',
'OBJECT_NUMBER' => '25544',
'OBJECT_TYPE' => 'PAYLOAD',
'TLE_LINE0' => '0 ISS (ZARYA)',
'TLE_LINE1' => '1 25544U First line of data',
'TLE_LINE2' => '2 25544 Second line of data',
tools/modeldef view on Meta::CPAN
=head1 OPTIONS
=head2 -help
This option displays the documentation for this script. The script then
exits.
=head2 -password string
This option specifies the password used to access Space Track. The
default comes from environment variable C<SPACETRACK_USER>, or from an
identity file.
=head2 -username string
This option specifies the user name used to access Space Track. The
default comes from environment variable C<SPACETRACK_USER>, or from an
identity file.
=head2 -version
This option displays the version of this script. The script then exits.
=head1 DETAILS
This Perl script generates a web page which describes the Space Track
xt/author/iridium_status.t view on Meta::CPAN
use lib qw{ inc };
use My::Module::Test ();
plan skip_all => 'Kelso dropped Iridium status 2024-04-26';
my $space_track_skip = My::Module::Test::__spacetrack_skip(
envir => 1,
no_prompt => My::Module::Test->NO_SPACE_TRACK_ACCOUNT(),
);
defined $ENV{SPACETRACK_TEST_LIVE}
and not $ENV{SPACETRACK_TEST_LIVE}
and $space_track_skip = 'Disabled via $ENV{SPACETRACK_TEST_LIVE}';
# The following hash is used to compute the todo list. The keys are
# the OIDs for the Iridium satellites. The value for each key is a hash
# containing the names of inconsistent data sources and a true value for
# each inconsistent name. If all three sources are mutually inconsistent,
# only two source names need be given.
my %known_inconsistent = (
# 24792 => { sladen => 1 }, # Sladen: Failed 02-Nov-2017
# Kelso: Failed 16-Nov-2017
xt/author/iridium_status.t view on Meta::CPAN
25273 Iridium 57 [-] Plane 3 - Failed on station?
25286 Iridium 63 [-] Plane 1 - Failed on station?
25319 Iridium 69 [-] Plane 2
25320 Iridium 71 [-] Plane 2
25344 Iridium 73 [-] Plane 1
25467 Iridium 82 [-] Plane 6 - Failed on station?
25527 Iridium 2 [-] Plane 5
SLADEN
$space_track_skip ? () :
[ "Space Track Iridium status",
spacetrack => <<'SPACETRACK'],
24792 Iridium 8 [D] Decayed 2017-11-24
24793 Iridium 7 [?] SpaceTrack
24794 Iridium 6 [D] Decayed 2017-12-23
24795 Iridium 5 [?] SpaceTrack
24796 Iridium 4 [?] SpaceTrack
24836 Iridium 914 [?] SpaceTrack
24837 Iridium 12 [D] Decayed 2018-09-02
24838 Iridium 09 [D] Decayed 2003-03-11
24839 Iridium 10 [D] Decayed 2018-10-06
24840 Iridium 13 [D] Decayed 2018-04-29
xt/author/iridium_status.t view on Meta::CPAN
25578 Iridium 11 [D] Decayed 2018-10-22
25777 Iridium 14 [D] Decayed 2019-03-15
25778 Iridium 21 [D] Decayed 2018-05-24
27372 Iridium 91 [D] Decayed 2019-03-13
27373 Iridium 90 [D] Decayed 2019-01-23
27374 Iridium 94 [D] Decayed 2018-04-18
27375 Iridium 95 [D] Decayed 2019-03-25
27376 Iridium 96 [D] Decayed 2020-05-30
27450 Iridium 97 [D] Decayed 2019-12-27
27451 Iridium 98 [D] Decayed 2018-08-24
SPACETRACK
) {
my ( $what, $file, $data ) = @$_;
$data ||= '';
my $got = $skip{$file} ? 'skip' : $text{$file};
1 while $got =~ s/\015\012/\n/gm;
SKIP: {
$skip{$file}
and skip $skip{$file}, 1;
xt/author/spacetrack_rest_range.t view on Meta::CPAN
{
# Iridiums, per T. S. Kelso
my @oids = qw{
24792-24796 24836 24837 24839-24842 24869-24873 24903-24907
24925 24926 24944-24946 24948-24950 24965-24969 25039-25043
25077 25078 25104-25106 25108 25169-25173 25262 25263
25272-25276 25285-25291 25319 25320 25342-25346 25431 25432
25467-25469 25471 25527 25528 25530 25531 25577 25578 25777
25778 27372-27376 27450 27451
};
local $ENV{SPACETRACK_REST_RANGE_OPERATOR} = 1;
$st->set( dump_headers => 6 );
my $rslt = $st->retrieve( @oids );
# Method _get_json_object() is unsupported and undocumented.
my $json = $st->_get_json_object();
{
my $data = $json->decode( $rslt->content() );