backend.py: use argparser to set mesh default, join paths with os.path.join
This commit is contained in:
parent
10e10944a5
commit
84746de048
11
backend.py
11
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')
|
||||||
|
|
||||||
|
@ -73,8 +70,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(scriptdir + '/nodedb/', params['destination_directory'] + '/nodes')
|
rrd = RRD(os.path.join(script_directory, 'nodedb'),
|
||||||
|
os.path.join(params['destination_directory'], 'nodes'))
|
||||||
rrd.update_database(nodedb['nodes'])
|
rrd.update_database(nodedb['nodes'])
|
||||||
rrd.update_images()
|
rrd.update_images()
|
||||||
|
|
||||||
|
@ -87,7 +85,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