-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdocker__credentials.py
executable file
·54 lines (39 loc) · 1.07 KB
/
docker__credentials.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python
import sys
from os.path import expanduser
from netrc import netrc
def main(argv=None):
""" """
# if argv is None:
# args = sys.argv[1:]
#
# if len(args) != 0:
# print "[docker-tools] 0 argument required, %i provided" % len(args)
# return 0
filename = expanduser("~/.docker_missing_tools_repositories")
try:
n = netrc(filename)
hosts = n.hosts.keys()
except IOError:
hosts = None
if hosts is None:
return 0
for host in hosts:
try:
n = netrc(filename)
credentials = n.hosts.get(host, None)
except IOError:
credentials = None
if credentials is not None:
try:
username = credentials[0]
except IndexError:
username = " "
try:
password = credentials[2]
except IndexError:
password = " "
sys.stdout.write("%s %s %s\n" % (host, username, password))
return 0
if __name__ == "__main__":
main()