|
|
@ -13,7 +13,7 @@ parser = argparse.ArgumentParser( |
|
|
|
epilog='Report bugs to http://zzz.i2p/topics/733') |
|
|
|
epilog='Report bugs to http://zzz.i2p/topics/733') |
|
|
|
parser.add_argument('-c', '--config', default='/etc/py-i2phosts/injector.conf', dest='config_file', |
|
|
|
parser.add_argument('-c', '--config', default='/etc/py-i2phosts/injector.conf', dest='config_file', |
|
|
|
help='config file to use') |
|
|
|
help='config file to use') |
|
|
|
parser.add_argument('-f', '--file', default=os.environ['HOME'] + '/.i2p/hosts.txt', dest='hostsfile', |
|
|
|
parser.add_argument('-f', '--file', dest='hostsfile', |
|
|
|
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') |
|
|
@ -53,6 +53,17 @@ else: |
|
|
|
if args.quiet: |
|
|
|
if args.quiet: |
|
|
|
args.supress = True |
|
|
|
args.supress = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# determine what hosts.txt file we should parse |
|
|
|
|
|
|
|
if args.hostsfile: |
|
|
|
|
|
|
|
hostsfile = args.hostsfile |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
env = os.environ |
|
|
|
|
|
|
|
if 'HOME' in env: |
|
|
|
|
|
|
|
hostsfile = os.environ['HOME'] + '/.i2p/hosts.txt' |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
sys.stderr.write('unable to determine hosts file for parsing\n') |
|
|
|
|
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
|
|
|
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 |
|
|
|