mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-02-02 01:44:40 +00:00
injector: add -s/--supress option
With this option messages about already existed hostnames will be supressed.
This commit is contained in:
parent
9b88d61af5
commit
d0f157450b
5
injector
5
injector
@ -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,7 +47,8 @@ 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():
|
||||||
print 'Host %s already exists' % hostname
|
if not args.supress:
|
||||||
|
print 'Host %s already exists' % hostname
|
||||||
else:
|
else:
|
||||||
print 'Adding %s' % hostname
|
print 'Adding %s' % hostname
|
||||||
host = i2phost(name=hostname, b64hash=base64,
|
host = i2phost(name=hostname, b64hash=base64,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user