From 1b0e830e162c5e99b277ba0450d9fb278bdf870f Mon Sep 17 00:00:00 2001 From: Daniel Ehlers Date: Mon, 18 Nov 2013 10:58:12 +0100 Subject: [PATCH] Add destination directory argument and write content instead of piping. --- bat2nodes.py | 7 ++++++- mkmap.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/bat2nodes.py b/bat2nodes.py index 917136a..a3d3fb1 100755 --- a/bat2nodes.py +++ b/bat2nodes.py @@ -28,6 +28,9 @@ parser.add_argument('-g', '--gateway', action='append', parser.add_argument('batmanjson', help='output of batman vd json') +parser.add_argument('-d', '--destination-directory', action='store', + help='destination directory for generated files',required=True) + args = parser.parse_args() options = vars(args) @@ -44,4 +47,6 @@ if options['gateway']: m = D3MapBuilder(db) -print(m.build()) +nodes_json = open(options['destination_directory'] + '/nodes.json.new','w') +nodes_json.write(m.build()) +nodes_json.close() diff --git a/mkmap.sh b/mkmap.sh index 13ec9ec..064d1b9 100755 --- a/mkmap.sh +++ b/mkmap.sh @@ -20,7 +20,7 @@ fi "$(dirname "$0")"/ffhlwiki.py http://freifunk.metameute.de/wiki/Knoten > "$(dirname "$0")"/aliases_hl.json "$(dirname "$0")"/ffhlwiki.py http://freifunk.metameute.de/wiki/Moelln:Knoten > "$(dirname "$0")"/aliases_moelln.json -batctl vd json -n | "$(dirname "$0")"/bat2nodes.py -a "$(dirname "$0")"/aliases.json -a aliases_hl.json -a aliases_moelln.json $GWS - > $DEST/nodes.json.new +batctl vd json -n | "$(dirname "$0")"/bat2nodes.py -a "$(dirname "$0")"/aliases.json -a aliases_hl.json -a aliases_moelln.json -d $DEST $GWS - mv $DEST/nodes.json.new $DEST/nodes.json