backend.py: use argparser to set mesh default, join paths with os.path.join
This commit is contained in:
parent
d4a7c83553
commit
1fb61db963
12
backend.py
12
backend.py
|
@ -18,9 +18,6 @@ from rrddb import RRD
|
||||||
|
|
||||||
|
|
||||||
def main(params):
|
def main(params):
|
||||||
if not params['mesh']:
|
|
||||||
params['mesh'] = ['bat0']
|
|
||||||
|
|
||||||
nodes_fn = os.path.join(params['destination_directory'], 'nodes.json')
|
nodes_fn = os.path.join(params['destination_directory'], 'nodes.json')
|
||||||
graph_fn = os.path.join(params['destination_directory'], 'graph.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:
|
with open(graph_fn, 'w') as f:
|
||||||
json.dump({'batadv': json_graph.node_link_data(batadv_graph)}, f)
|
json.dump({'batadv': json_graph.node_link_data(batadv_graph)}, f)
|
||||||
|
|
||||||
scriptdir = os.path.dirname(os.path.realpath(__file__))
|
script_directory = os.path.dirname(os.path.realpath(__file__))
|
||||||
rrd = RRD("{}/nodedb/".format(scriptdir),
|
rrd = RRD(os.path.join(script_directory, 'nodedb'),
|
||||||
"{}/nodes".format(params['destination_directory']))
|
os.path.join(params['destination_directory'], 'nodes'))
|
||||||
rrd.update_database(nodedb['nodes'])
|
rrd.update_database(nodedb['nodes'])
|
||||||
rrd.update_images()
|
rrd.update_images()
|
||||||
|
|
||||||
|
@ -92,7 +89,8 @@ if __name__ == '__main__':
|
||||||
default=[], action='append',
|
default=[], action='append',
|
||||||
metavar='FILE')
|
metavar='FILE')
|
||||||
parser.add_argument('-m', '--mesh', action='append',
|
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',
|
parser.add_argument('-d', '--destination-directory', action='store',
|
||||||
help='destination directory for generated files',
|
help='destination directory for generated files',
|
||||||
required=True)
|
required=True)
|
||||||
|
|
Loading…
Reference in a new issue