From c74b7b95fb5d65dcf0fee7eb5a5525ae884ab209 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 24 Mar 2015 22:10:54 +0100 Subject: [PATCH] update package structure, move non-executables to lib --- backend.py | 19 +++++++++---------- GlobalRRD.py => lib/GlobalRRD.py | 3 ++- NodeRRD.py => lib/NodeRRD.py | 3 ++- RRD.py => lib/RRD.py | 0 lib/__init__.py | 1 + alfred.py => lib/alfred.py | 0 batman.py => lib/batman.py | 0 graph.py => lib/graph.py | 6 ++++-- nodes.py => lib/nodes.py | 0 rrddb.py => lib/rrddb.py | 5 +++-- 10 files changed, 21 insertions(+), 16 deletions(-) rename GlobalRRD.py => lib/GlobalRRD.py (97%) rename NodeRRD.py => lib/NodeRRD.py (98%) rename RRD.py => lib/RRD.py (100%) create mode 100644 lib/__init__.py rename alfred.py => lib/alfred.py (100%) rename batman.py => lib/batman.py (100%) rename graph.py => lib/graph.py (98%) rename nodes.py => lib/nodes.py (100%) rename rrddb.py => lib/rrddb.py (96%) diff --git a/backend.py b/backend.py index 2d8cc9a..5b60d3e 100755 --- a/backend.py +++ b/backend.py @@ -6,20 +6,19 @@ https://github.com/ffnord/ffmap-backend import argparse import json import os -import networkx as nx from datetime import datetime + +import networkx as nx from networkx.readwrite import json_graph -import alfred -import nodes -import graph -from batman import Batman -from rrddb import RRD +from lib import alfred, graph, nodes +from lib.batman import Batman +from lib.rrddb import RRD def main(params): - nodes_fn = os.path.join(params['destination_directory'], 'nodes.json') - graph_fn = os.path.join(params['destination_directory'], 'graph.json') + nodes_fn = os.path.join(params['dest_dir'], 'nodes.json') + graph_fn = os.path.join(params['dest_dir'], 'graph.json') now = datetime.utcnow().replace(microsecond=0) @@ -77,7 +76,7 @@ def main(params): if params['rrd']: script_directory = os.path.dirname(os.path.realpath(__file__)) 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_images() @@ -92,7 +91,7 @@ if __name__ == '__main__': parser.add_argument('-m', '--mesh', action='append', default=['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', required=True) parser.add_argument('--vpn', action='append', metavar='MAC', diff --git a/GlobalRRD.py b/lib/GlobalRRD.py similarity index 97% rename from GlobalRRD.py rename to lib/GlobalRRD.py index 9c09549..47235f2 100644 --- a/GlobalRRD.py +++ b/lib/GlobalRRD.py @@ -1,6 +1,7 @@ import os import subprocess -from RRD import RRD, DS, RRA + +from lib.RRD import DS, RRA, RRD class GlobalRRD(RRD): diff --git a/NodeRRD.py b/lib/NodeRRD.py similarity index 98% rename from NodeRRD.py rename to lib/NodeRRD.py index a4ec092..37bc6f9 100644 --- a/NodeRRD.py +++ b/lib/NodeRRD.py @@ -1,6 +1,7 @@ import os import subprocess -from RRD import RRD, DS, RRA + +from lib.RRD import DS, RRA, RRD class NodeRRD(RRD): diff --git a/RRD.py b/lib/RRD.py similarity index 100% rename from RRD.py rename to lib/RRD.py diff --git a/lib/__init__.py b/lib/__init__.py new file mode 100644 index 0000000..64bd3f3 --- /dev/null +++ b/lib/__init__.py @@ -0,0 +1 @@ +__author__ = 'hexa' diff --git a/alfred.py b/lib/alfred.py similarity index 100% rename from alfred.py rename to lib/alfred.py diff --git a/batman.py b/lib/batman.py similarity index 100% rename from batman.py rename to lib/batman.py diff --git a/graph.py b/lib/graph.py similarity index 98% rename from graph.py rename to lib/graph.py index 460e327..d5163ff 100644 --- a/graph.py +++ b/lib/graph.py @@ -1,7 +1,9 @@ -import networkx as nx from functools import reduce 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): diff --git a/nodes.py b/lib/nodes.py similarity index 100% rename from nodes.py rename to lib/nodes.py diff --git a/rrddb.py b/lib/rrddb.py similarity index 96% rename from rrddb.py rename to lib/rrddb.py index b023e6b..bcd33b3 100644 --- a/rrddb.py +++ b/lib/rrddb.py @@ -1,8 +1,9 @@ #!/usr/bin/env python3 import time import os -from GlobalRRD import GlobalRRD -from NodeRRD import NodeRRD + +from lib.GlobalRRD import GlobalRRD +from lib.NodeRRD import NodeRRD class RRD(object):