mirror of
https://github.com/r4sas/py-i2phosts
synced 2025-02-02 01:44:40 +00:00
py-i2phosts-builder: add cli and config option for output file
This commit is contained in:
parent
6bfc7d7fb3
commit
47d0957550
@ -11,6 +11,8 @@ 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/builder.conf', dest='config_file',
|
parser.add_argument('-c', '--config', default='/etc/py-i2phosts/builder.conf', dest='config_file',
|
||||||
help='config file to use')
|
help='config file to use')
|
||||||
|
parser.add_argument('-f', '--file',
|
||||||
|
help='write hosts into specified file')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# read config
|
# read config
|
||||||
@ -30,7 +32,10 @@ os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
|
|||||||
from web.postkey.models import i2phost
|
from web.postkey.models import i2phost
|
||||||
|
|
||||||
# result hosts.txt
|
# result hosts.txt
|
||||||
hostsfile = 'hosts.txt'
|
if 'hostsfile' in config:
|
||||||
|
hostsfile = config['hostsfile']
|
||||||
|
if args.file:
|
||||||
|
hostsfile = args.file
|
||||||
|
|
||||||
f = open(hostsfile, 'w')
|
f = open(hostsfile, 'w')
|
||||||
# get activated hosts
|
# get activated hosts
|
||||||
|
Loading…
x
Reference in New Issue
Block a user