|
|
@ -22,6 +22,8 @@ parser.add_argument('-f', '--file', default=os.environ['HOME'] + '/.i2p/hosts.tx |
|
|
|
help='hosts.txt for parsing') |
|
|
|
help='hosts.txt for parsing') |
|
|
|
parser.add_argument('-d', '--description', default='Auto-added from external hosts.txt', |
|
|
|
parser.add_argument('-d', '--description', default='Auto-added from external hosts.txt', |
|
|
|
help='provide custom description message') |
|
|
|
help='provide custom description message') |
|
|
|
|
|
|
|
parser.add_argument('-s', '--supress', action='store_true', |
|
|
|
|
|
|
|
help='supress warnings about already existed hostnames') |
|
|
|
args = parser.parse_args() |
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
|
|
|
|
f = open(args.hostsfile, 'r') |
|
|
|
f = open(args.hostsfile, 'r') |
|
|
@ -45,6 +47,7 @@ for line in f: |
|
|
|
# beacuse they will fail anyway. |
|
|
|
# beacuse they will fail anyway. |
|
|
|
qs = i2phost.objects.filter(name=hostname) |
|
|
|
qs = i2phost.objects.filter(name=hostname) |
|
|
|
if qs.exists(): |
|
|
|
if qs.exists(): |
|
|
|
|
|
|
|
if not args.supress: |
|
|
|
print 'Host %s already exists' % hostname |
|
|
|
print 'Host %s already exists' % hostname |
|
|
|
else: |
|
|
|
else: |
|
|
|
print 'Adding %s' % hostname |
|
|
|
print 'Adding %s' % hostname |
|
|
|