Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
django-sshkey
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
487f9410
authored
Jul 03, 2014
by
Scott Duckworth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make lookup_main() handle all lookup cases
This brings it back on parity with django-sshkey-lookup
parent
23ff9700
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
9 deletions
+44
-9
django_sshkey/util.py
+44
-9
No files found.
django_sshkey/util.py
View file @
487f9410
...
...
@@ -265,15 +265,50 @@ def lookup_by_fingerprint_main():
def
lookup_main
():
import
sys
import
getopt
from
os
import
environ
if
len
(
sys
.
argv
)
<
2
:
sys
.
stderr
.
write
(
'Usage:
%
s URL [USERNAME]
\n
'
%
sys
.
argv
[
0
])
usage
=
(
"Usage: {prog} -a URL
\n
"
" {prog} -u URL USERNAME
\n
"
" {prog} -f URL FINGERPRINT
\n
"
" {prog} URL [USERNAME]
\n
"
)
.
format
(
prog
=
sys
.
argv
[
0
])
try
:
opts
,
args
=
getopt
.
getopt
(
sys
.
argv
[
1
:],
'hafu'
)
except
getopt
.
GetoptError
as
e
:
sys
.
stderr
.
write
(
"Error:
%
s
\n
"
%
str
(
e
))
sys
.
stderr
.
write
(
usage
)
sys
.
exit
(
1
)
mode
=
'x'
for
o
,
a
in
opts
:
if
o
==
'-h'
:
sys
.
stdout
.
write
(
usage
)
sys
.
exit
(
0
)
else
:
mode
=
o
[
1
]
if
len
(
args
)
==
0
:
sys
.
stderr
.
write
(
usage
)
sys
.
exit
(
1
)
url
=
sys
.
argv
[
1
]
if
len
(
sys
.
argv
)
==
2
:
environ
[
'SSHKEY_LOOKUP_URL'
]
=
url
lookup_by_fingerprint_main
()
url
=
args
[
0
]
if
mode
==
'a'
:
response
=
lookup_all
(
url
)
elif
mode
==
'f'
:
if
len
(
args
)
<
2
:
sys
.
stderr
.
write
(
usage
)
sys
.
exit
(
1
)
response
=
lookup_by_fingerprint
(
url
,
args
[
1
])
elif
mode
==
'u'
:
if
len
(
args
)
<
2
:
sys
.
stderr
.
write
(
usage
)
sys
.
exit
(
1
)
response
=
lookup_by_username
(
url
,
args
[
1
])
else
:
username
=
sys
.
argv
[
2
]
for
key
in
lookup_by_username
(
url
,
username
):
sys
.
stdout
.
write
(
key
)
if
len
(
args
)
==
1
:
environ
[
'SSHKEY_LOOKUP_URL'
]
=
url
return
lookup_by_fingerprint_main
()
else
:
response
=
lookup_by_username
(
url
,
args
[
1
])
for
key
in
response
:
sys
.
stdout
.
write
(
key
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment