|
|
@ -23,9 +23,14 @@ parser.add_argument('-f', '--file', default=os.environ['HOME'] + '/.i2p/hosts.tx |
|
|
|
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', |
|
|
|
parser.add_argument('-s', '--supress', action='store_true', |
|
|
|
help='supress warnings about already existed hostnames') |
|
|
|
help='supress warnings about already existed hostnames'), |
|
|
|
|
|
|
|
parser.add_argument('-q', '--quiet', action='store_true', |
|
|
|
|
|
|
|
help='be completely quiet, print only errors') |
|
|
|
args = parser.parse_args() |
|
|
|
args = parser.parse_args() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if args.quiet: |
|
|
|
|
|
|
|
args.supress = True |
|
|
|
|
|
|
|
|
|
|
|
f = open(args.hostsfile, 'r') |
|
|
|
f = open(args.hostsfile, 'r') |
|
|
|
for line in f: |
|
|
|
for line in f: |
|
|
|
# ignore comments and empty lines |
|
|
|
# ignore comments and empty lines |
|
|
@ -50,6 +55,7 @@ for line in f: |
|
|
|
if not args.supress: |
|
|
|
if not args.supress: |
|
|
|
print 'Host %s already exists' % hostname |
|
|
|
print 'Host %s already exists' % hostname |
|
|
|
else: |
|
|
|
else: |
|
|
|
|
|
|
|
if not args.quiet: |
|
|
|
print 'Adding %s' % hostname |
|
|
|
print 'Adding %s' % hostname |
|
|
|
host = i2phost(name=hostname, b64hash=base64, |
|
|
|
host = i2phost(name=hostname, b64hash=base64, |
|
|
|
description=args.description, |
|
|
|
description=args.description, |
|
|
|