From 1fb61db96339a8babd030112e0acfe6a81342427 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 24 Mar 2015 17:50:36 +0100 Subject: [PATCH] backend.py: use argparser to set mesh default, join paths with os.path.join --- backend.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/backend.py b/backend.py index 7b7d0e5..0a91153 100755 --- a/backend.py +++ b/backend.py @@ -18,9 +18,6 @@ from rrddb import RRD def main(params): - if not params['mesh']: - params['mesh'] = ['bat0'] - nodes_fn = os.path.join(params['destination_directory'], 'nodes.json') graph_fn = os.path.join(params['destination_directory'], 'graph.json') @@ -77,9 +74,9 @@ def main(params): with open(graph_fn, 'w') as f: json.dump({'batadv': json_graph.node_link_data(batadv_graph)}, f) - scriptdir = os.path.dirname(os.path.realpath(__file__)) - rrd = RRD("{}/nodedb/".format(scriptdir), - "{}/nodes".format(params['destination_directory'])) + script_directory = os.path.dirname(os.path.realpath(__file__)) + rrd = RRD(os.path.join(script_directory, 'nodedb'), + os.path.join(params['destination_directory'], 'nodes')) rrd.update_database(nodedb['nodes']) rrd.update_images() @@ -92,7 +89,8 @@ if __name__ == '__main__': default=[], action='append', metavar='FILE') parser.add_argument('-m', '--mesh', action='append', - help='batman mesh interface') + default=['bat0'], + help='batman mesh interface (defaults to bat0)') parser.add_argument('-d', '--destination-directory', action='store', help='destination directory for generated files', required=True)