parser=argparse.ArgumentParser(description='This Script generates a hierarchical nodes list for node migration using nginx geo feature.')
parser.add_argument('--json-path',required=False,default='https://service.freifunk-muensterland.de/maps/data/',help='Path of nodes.json and graph.json (can be local folder or remote URL).')
parser.add_argument('--targets-file',required=False,help='Json file of targets for nominatim geocoder.',default='./targets.json')
parser.add_argument('-t','--targets',nargs='*',required=False,help='List of target names from target-file which should be proceeded. Example: -t citya -t cityb ...')
parser.add_argument('-a','--all','--all-targets',required=False,help='Proceed all targets from targets file.',action='store_true')
parser.add_argument('--out-path',required=False,help='Directory where the generated Output should stored.',default='./webserver-configuration/')
parser.add_argument('--only-specific-branch',required=False,help='Only attend nodes from specific branch.',default=None)
parser.add_argument('-p','--print-status',required=False,action='store_true',help='Print Status (like geocoder tasks).')
args=parser.parse_args()
defprepareTargets(args):
resource=open(args.targets_file)
targets=json.loads(resource.read())
resource.close()
iflen(targets)==0:
print"\033[91mError:\033[0m No targets were found in targets file."
sys.exit(1)
ifargs.all==True:
returntargets
elifargs.targets==Noneorlen(args.targets)==0:
print"\033[91mError:\033[0m No target was given as argument and even --all switch was not enabled."