IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39506


Ignore:
Timestamp:
Mar 31, 2016, 6:36:52 AM (10 years ago)
Author:
eugene
Message:

allow neb-repair to exit with a success status if supplied file is not a nebulous file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Nebulous/bin/neb-repair

    r32554 r39506  
    3232
    3333pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
    34 pod2usage( -msg => "Required options: --server", -exitval => 2 )
    35     unless $server;
    36 pod2usage( -msg => "missing key", exitval => 2 )
    37     unless defined $key;
     34pod2usage( -msg => "Required options: --server", -exitval => 2 ) unless $server;
     35pod2usage( -msg => "missing key", exitval => 2 ) unless defined $key;
     36
     37# this program should exit (with success status) if file is not a neb file
     38
     39my $scheme = file_scheme ($key);
     40if ($scheme eq "file") { print "key is a file, not a nebulous key\n"; exit 0; }
     41if ($scheme eq "path") { print "key is a path, not a nebulous key\n"; exit 0; }
    3842
    3943my $neb = Nebulous::Client->new(
     
    158162# }
    159163
    160 
     164# Return the scheme used for a filename (copied from PS-IPP-Config/lib/PS/IPP/Config.pm
     165sub file_scheme
     166{
     167    my $name = shift;                # Filename for which to get the scheme
     168    my ($scheme) = $name =~ /^(path|neb|file):/; # The scheme, e.g., file://, path://
     169    if undef $scheme { $scheme = "none"; }
     170    # $scheme may be undef if the input doesn't contain one of the above recognised schemes
     171    unless (defined($scheme)) { $scheme = "none"; }
     172    return $scheme;
     173}
    161174
    162175__END__
Note: See TracChangeset for help on using the changeset viewer.