update package structure, move non-executables to lib

This commit is contained in:
Martin Weinelt 2015-03-24 22:10:54 +01:00
parent 629adc13cb
commit c74b7b95fb
10 changed files with 21 additions and 16 deletions

View file

@ -6,20 +6,19 @@ https://github.com/ffnord/ffmap-backend
import argparse import argparse
import json import json
import os import os
import networkx as nx
from datetime import datetime from datetime import datetime
import networkx as nx
from networkx.readwrite import json_graph from networkx.readwrite import json_graph
import alfred from lib import alfred, graph, nodes
import nodes from lib.batman import Batman
import graph from lib.rrddb import RRD
from batman import Batman
from rrddb import RRD
def main(params): def main(params):
nodes_fn = os.path.join(params['destination_directory'], 'nodes.json') nodes_fn = os.path.join(params['dest_dir'], 'nodes.json')
graph_fn = os.path.join(params['destination_directory'], 'graph.json') graph_fn = os.path.join(params['dest_dir'], 'graph.json')
now = datetime.utcnow().replace(microsecond=0) now = datetime.utcnow().replace(microsecond=0)
@ -77,7 +76,7 @@ def main(params):
if params['rrd']: if params['rrd']:
script_directory = os.path.dirname(os.path.realpath(__file__)) script_directory = os.path.dirname(os.path.realpath(__file__))
rrd = RRD(os.path.join(script_directory, 'nodedb'), rrd = RRD(os.path.join(script_directory, 'nodedb'),
os.path.join(params['destination_directory'], 'nodes')) os.path.join(params['dest_dir'], 'nodes'))
rrd.update_database(nodedb['nodes']) rrd.update_database(nodedb['nodes'])
rrd.update_images() rrd.update_images()
@ -92,7 +91,7 @@ if __name__ == '__main__':
parser.add_argument('-m', '--mesh', action='append', parser.add_argument('-m', '--mesh', action='append',
default=['bat0'], default=['bat0'],
help='batman mesh interface (defaults to bat0)') help='batman mesh interface (defaults to bat0)')
parser.add_argument('-d', '--destination-directory', action='store', parser.add_argument('-d', '--dest-dir', action='store',
help='destination directory for generated files', help='destination directory for generated files',
required=True) required=True)
parser.add_argument('--vpn', action='append', metavar='MAC', parser.add_argument('--vpn', action='append', metavar='MAC',

View file

@ -1,6 +1,7 @@
import os import os
import subprocess import subprocess
from RRD import RRD, DS, RRA
from lib.RRD import DS, RRA, RRD
class GlobalRRD(RRD): class GlobalRRD(RRD):

View file

@ -1,6 +1,7 @@
import os import os
import subprocess import subprocess
from RRD import RRD, DS, RRA
from lib.RRD import DS, RRA, RRD
class NodeRRD(RRD): class NodeRRD(RRD):

View file

1
lib/__init__.py Normal file
View file

@ -0,0 +1 @@
__author__ = 'hexa'

View file

@ -1,7 +1,9 @@
import networkx as nx
from functools import reduce from functools import reduce
from itertools import chain from itertools import chain
from nodes import build_mac_table
import networkx as nx
from lib.nodes import build_mac_table
def import_vis_data(graph, nodes, vis_data): def import_vis_data(graph, nodes, vis_data):

View file

@ -1,8 +1,9 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import time import time
import os import os
from GlobalRRD import GlobalRRD
from NodeRRD import NodeRRD from lib.GlobalRRD import GlobalRRD
from lib.NodeRRD import NodeRRD
class RRD(object): class RRD(object):