Astro-SpaceTrack

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    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.

  Add ISS data to celestrak_supplemental.

  Support the various Space Track data formats. This involves providing
    a -format option, with values corresponding to the Space Track
    formats, plus 'legacy' (the default) to provide what is essentially
    the Version 1 data format. The old -json option is equivalent to
    -format json.

0.086		2014-04-26	T. R. Wyant

Changes  view on Meta::CPAN


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.

  Document the desupport of the Space Track version 1 interface as of
    this release.

  No longer test version 1 of the Space Track interface, since it is

Changes  view on Meta::CPAN

  When the space_track_version attribute is 2, implement the -exclude
    search option in terms of the OBJECT_TYPE field rather than by
    simulating the version 1 exclusion rules in the client. This can
    mean different search results depending on the interface used (e.g.
    Westford needles are debris under v1, but payload under v2), but
    since the change seems to be deliberate on the part of Space Track,
    I am following it.

0.060_12	2012-08-07	T. R. Wyant
  Turn on autoflush in t/query.t to try to prevent overwriting of
    prompt.

  Have the REST version of retrieve() issue multiple queries if the
    number of OIDs is over 50.

  Add the ability to handle OID ranges to the REST versions of
    retrieve() and search_oid().

  Have the output of names( 'spacetrack' ) depend on the value of the
    space_track_version attribute.

Changes  view on Meta::CPAN

  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
    time.

  Add attribute 'pretty' to reqest that JSON text (and potentially
    others) be pretty-formatted.

Changes  view on Meta::CPAN

0.031		2007-12-21	T. R. Wyant
    Fix embedded modifier bug, exposed by the fixing of the
	corresponding Perl bug (id=22354) in 5.10.0 -- or 5.9.0
	actually. Thanks to Andy Lester's article:
	http://perlbuzz.com/mechanix/2007/12/code-broken-by-regex-fixes-in.html
	which tipped me off before I had to discover the problem
	for myself.

    Fixed dependencies in Makefile.PL and Build.PL.

    Went back to prompting for executables in Makefile.PL and
	Build.PL, as a way to handle apparant ActiveState build
	failure because both they and I were running pl2bat.bat.

    Enhance ExtUtils::MakeMaker version detection in Makefile.PL,
	since ActiveState is apparantly deploying a Perl 5.10
	with a development version of that module.

0.030		2007-10-24	T. R. Wyant
    Add Celestrak 'sts' data set name to catalog.

Changes  view on Meta::CPAN


  Changed Content-Type header of spacetrack () response
    to text/plain. Used to be text/text.

  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.

Makefile.PL  view on Meta::CPAN


use strict;
use warnings;

use lib qw{ inc };

use My::Module::Meta;
use My::Module::Recommend;

use Config;
use ExtUtils::MakeMaker qw{WriteMakefile prompt};
use FileHandle;
use Getopt::Std;

my $meta = My::Module::Meta->new();

my %opt;
getopts ('ny', \%opt) or die <<'EOD';
The only legal options are
  -n = answer all questions 'no'.
  -y = answer all questions 'yes'.

README  view on Meta::CPAN

You should substitute the appropriate program name for 'make', eg nmake
(typically) under MSWin32, or mms or mmk under VMS. See
ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe for a copy of
nmake for MSWin32 if you need it.

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
to do this before installing, you need to invoke them as (e.g.)
    $ perl -Mblib script/SpaceTrack
Under VMS, you'll need to quote the -M thus:
    $ perl "-Mblib" script/SpaceTrack

inc/My/Module/Test.pm  view on Meta::CPAN

    is_error
    is_error_or_skip
    is_not_success
    is_success
    is_success_or_skip
    last_modified
    most_recent_http_response
    not_defined
    site_check
    spacetrack_user
    spacetrack_skip_no_prompt
    skip_site
    throws_exception
    VERIFY_HOSTNAME
};

use constant HASH_REF	=> ref {};
use constant REGEXP_REF	=> ref qr{};

use constant NO_SPACE_TRACK_ACCOUNT => 'No Space-Track account provided';

inc/My/Module/Test.pm  view on Meta::CPAN

	    1;
	} or $set_read_mode = sub {};

	local $@ = undef;
	eval {		## no critic (RequireCheckingReturnValueOfEval)
	    require IO::Handle;
	    STDERR->autoflush( 1 );
	};
    }

    sub prompt {
	my @args = @_;
	my $opt = HASH_REF eq ref $args[0] ? shift @args : {};
	$readkey_loaded
	    or not $opt->{password}
	    or push @args, '(ECHOED)';
	print STDERR "@args: ";
	# We're a test, and we're trying to be lightweight.
	$opt->{password}
	    and $set_read_mode->( 2 );
	my $input = <STDIN>;	## no critic (ProhibitExplicitStdin)

inc/My/Module/Test.pm  view on Meta::CPAN

	$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 );
    return;
}

inc/My/Module/Test.pm  view on Meta::CPAN

 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
throws the expected exception. The arguments are:

lib/Astro/SpaceTrack.pm  view on Meta::CPAN

    cookie_name => \&_mutate_spacetrack_interface,
    domain_space_track => \&_mutate_spacetrack_interface,
    dump_headers => \&_mutate_dump_headers,	# Dump all HTTP headers. Undocumented and unsupported.
    fallback => \&_mutate_attrib,
    filter => \&_mutate_attrib,
    identity	=> \&_mutate_identity,
    iridium_status_format => \&_mutate_iridium_status_format,
    max_range => \&_mutate_number,
    password => \&_mutate_authen,
    pretty => \&_mutate_attrib,
    prompt	=> \&_mutate_attrib,
    scheme_space_track => \&_mutate_attrib,
    session_cookie => \&_mutate_spacetrack_interface,
    space_track_version => \&_mutate_space_track_version,
    url_iridium_status_kelso => \&_mutate_attrib,
    url_iridium_status_mccants => \&_mutate_attrib,
    url_iridium_status_sladen => \&_mutate_attrib,
    username => \&_mutate_authen,
    verbose => \&_mutate_attrib,
    verify_hostname => \&_mutate_verify_hostname,
    webcmd => \&_mutate_attrib,

lib/Astro/SpaceTrack.pm  view on Meta::CPAN


    my $self = {
	banner => 1,	# shell () displays banner if true.
	dump_headers => DUMP_NONE,	# No dumping.
	fallback => 0,	# Do not fall back if primary source offline
	filter => 0,	# Filter mode.
	iridium_status_format => 'kelso',
	max_range => 500,	# Sanity limit on range size.
	password => undef,	# Login password.
	pretty => 0,		# Pretty-format content
	prompt => 'SpaceTrack> ',
	scheme_space_track => 'https',
	_space_track_interface	=> [
	    undef,	# No such thing as version 0
	    undef,	# Interface version 1 retured.
	    {	# Interface version 2
		# This interface does not seem to put an expiration time
		# on the cookie. But the docs say it's only good for a
		# couple hours, so we need this so we can fudge
		# something in when the time comes.
		cookie_expires		=> 0,

lib/Astro/SpaceTrack.pm  view on Meta::CPAN

'help' gets you a list of valid commands.
EOD

    my $stdout = \*STDOUT;
    my $read;

    unshift @args, 'banner' if $self->{banner} && !$self->{filter};
    # Perl::Critic wants IO::Interactive::is_interactive() here. But
    # that assumes we're using the *ARGV input mechanism, which we're
    # not (command arguments are SpaceTrack commands.) Also, we would
    # like to be prompted even if output is to a pipe, but the
    # recommended module calls that non-interactive even if input is
    # from a terminal. So:
    my $interactive = -t STDIN;
    while (1) {
	my $buffer;
	if (@args) {
	    $buffer = shift @args;
	} else {
	    $read ||= $interactive ? ( eval {
		    $self->_get_readline( $stdout )
		} || sub { print { $stdout } $self->getv( 'prompt' ); return <STDIN> } ) :
		sub { return<STDIN> };
	    $buffer = $read->();
	}
	last unless defined $buffer;

	$buffer =~ s/ \A \s+ //smx;
	$buffer =~ s/ \s+ \z //smx;
	next unless $buffer;
	next if $buffer =~ m/ \A [#] /smx;

lib/Astro/SpaceTrack.pm  view on Meta::CPAN

	    [\Q$readline::rl_completer_word_break_characters\E]+
	>smx;

	no warnings qw{ once };
	$readline::rl_completion_function = sub {
	    my ( $text, $line, $start ) = @_;
	    return $self->__readline_completer(
		$text, $line, $start );
	};
    }
    return sub { $rdln->readline ( $self->getv( 'prompt' ) ) };
}


=for html <a name="source"></a>

=item $st->source ($filename);

This convenience method reads the given file, and passes the individual
lines to the shell method. It croaks if the file is not provided or
cannot be read.

lib/Astro/SpaceTrack.pm  view on Meta::CPAN

=item pretty (Boolean)

This attribute specifies whether the content of the returned
L<HTTP::Response|HTTP::Response> is to be pretty-formatted. Currently
this only applies to Space Track data returned in C<JSON> format.
Pretty-formatting the C<JSON> is extra overhead, so unless you intend to
read the C<JSON> yourself this should probably be false.

The default is C<0> (i.e. false).

=item prompt (string)

This attribute specifies the prompt issued by the C<shell()> method. The
default is C<< 'SpaceTrack> ' >>.

=item scheme_space_track (string)

This attribute specifies the URL scheme used to access the Space Track
web site. The user will not normally need to modify this, but if the web
site changes schemes for some reason, this attribute may provide a way
to get queries going again.

The default is C<'https'>.

script/SpaceTrack  view on Meta::CPAN

#	Title:	SpaceTrack
#	Author:	T. R. Wyant
#	Date:	07-Mar-2005
#	Remarks:
#		This Perl script is just a really simple encapsulation
#		of the Astro::SpaceTrack shell subroutine. Note that the
#		command line arguments are passed, so you can do things
#		like
#		$ perl SpaceTrack 'set username me password secret'
#		followed by whatever commands you like at the SpaceTrack
#		prompt.


use strict;
use warnings;

our $VERSION = '0.182';

use Astro::SpaceTrack qw{shell};
use Getopt::Long 2.39;

script/SpaceTrack  view on Meta::CPAN


This application provides a command-line interface to the
Astro::SpaceTrack module, based on the Astro::SpaceTrack::shell
subroutine.

This gives you interactive access to all Astro::SpaceTrack methods,
plus pseudo output redirection (with tilde expansion) if you want your
output to go to a file.

Commands can be passed in on the command line. After all command-line
commands have been processed, you get an interactive prompt unless one
of the command-line commands was 'exit'. Beginning with 0.014, commands
can also be piped in, or redirected in from a file.

The one and only option is -filter, which sets the 'filter' attribute
of the C<Astro::SpaceTrack> object. This prevents informational output
(such as the banner and 'OK' messages) to STDOUT. The idea is that
with -filter asserted, you can pipe the output to another program,
and only have orbital elements written to the pipe.

Please see L<Astro::SpaceTrack|Astro::SpaceTrack> for the details.

t/basic.t  view on Meta::CPAN

    cookie_name
    domain_space_track
    dump_headers
    fallback
    filter
    identity
    iridium_status_format
    max_range
    password
    pretty
    prompt
    scheme_space_track
    session_cookie
    space_track_version
    username
    verbose
    verify_hostname
    webcmd
    with_name
    } ], 'Attribute list is correct';

t/complete.t  view on Meta::CPAN


complete( 'celestrak_supplemental -', [ qw{ --file --format --match --no-match
	--no-rms --query --rms } ] );

complete( 'celestrak_supplemental o', [ qw{ oneweb orbcomm } ] );

complete( 'favorite -', [ qw{ --format --json --no-json } ] );

complete( 'file -', [ retrieve_options() ] );

complete( 'get p', [ qw{ password pretty prompt } ] );

complete( 'iridium_status -', [ qw{ --no-raw --raw } ] );

complete( 'iridium_status s', [ qw{ sladen spacetrack } ] );

complete( 'launch_sites -', [ qw{ --format --json --no-json } ] );

complete( 'mccants -', [ qw{ --file } ] );

complete( 'mccants c', [ qw{ classified } ] );

complete( 'retrieve -', [ retrieve_options() ] );

complete( 'set p', [ qw{ password pretty prompt } ] );

complete( 'set password ', [] );

complete( 'show p', [ qw{ password pretty prompt } ] );

complete( 'spacetrack -', [ qw{ --format --json --no-json } ] );

complete( 'spacetrack i', [ qw{ inmarsat intelsat iridium } ] );

complete( 'update -', [ retrieve_options() ] );

done_testing;

sub complete {

tools/capture  view on Meta::CPAN

    retrieval_size	=> $Astro::SpaceTrack::RETRIEVAL_SIZE,
);

GetOptions( \%opt,
    qw{ file=s list! retrieval_size|retrieval-size=i verbose! },
    help => sub { pod2usage( { -verbose => 2 } ) },
) or pod2usage( { -verbose => 0 } );

my $st = Astro::SpaceTrack::Dumper->new(
    canned_response_file	=> $opt{file},
    prompt => 'SpaceTrack capture> ',
);

$opt{list}
    and list_captures( $st );

{
    local $Astro::SpaceTrack::RETRIEVAL_SIZE = $opt{retrieval_size};
    $opt{verbose}
	and $st->set( dump_headers => Astro::SpaceTrack->DUMP_RESPONSE() );
    $st->shell( @ARGV );

xt/author/spacetrack_catalogs.t  view on Meta::CPAN

use 5.006002;

use strict;
use warnings;

use Astro::SpaceTrack;
use Test::More 0.88;	# Because of done_testing();
use HTML::TreeBuilder;

use lib qw{ inc };
use My::Module::Test qw{ spacetrack_skip_no_prompt };

spacetrack_skip_no_prompt();

{
    my $st = Astro::SpaceTrack->new();
    my $resp = $st->login();
    $resp->is_success()
	or do {
	fail 'Space Track login failed: ' . $resp->status_line();
	last;
    };

xt/author/spacetrack_modeldef_v2.t  view on Meta::CPAN

use 5.006002;

use strict;
use warnings;

use Astro::SpaceTrack;
use JSON;
use Test::More 0.88;	# Because of done_testing();

use lib qw{ inc };
use My::Module::Test qw{ spacetrack_skip_no_prompt };

spacetrack_skip_no_prompt();

my $st = Astro::SpaceTrack->new();
my $rslt = $st->spacetrack_query_v2();
$rslt->is_success()
    or plan skip_all => 'Space Track inaccessable: ' . $rslt->status_line();

my $json = JSON->new()->pretty()->canonical()->utf8();

$rslt = $st->spacetrack_query_v2( qw{
    basicspacedata modeldef class satcat



( run in 0.848 second using v1.01-cache-2.11-cpan-0b5f733616e )