Browse Source

py-i2phosts-injector: add -q/--quiet option

With this option program should print only errors
pull/1/head
Hidden Z 14 years ago
parent
commit
28a04f9240
  1. 10
      py-i2phosts-injector

10
py-i2phosts-injector

@ -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,7 +55,8 @@ 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:
print 'Adding %s' % hostname if not args.quiet:
print 'Adding %s' % hostname
host = i2phost(name=hostname, b64hash=base64, host = i2phost(name=hostname, b64hash=base64,
description=args.description, description=args.description,
activated=True, external=True) activated=True, external=True)

Loading…
Cancel
Save