Browse Source

injector: add -s/--supress option

With this option messages about already existed hostnames will be
supressed.
pull/1/head
Hidden Z 14 years ago
parent
commit
d0f157450b
  1. 3
      injector

3
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,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

Loading…
Cancel
Save