Beispiel #1
0
def init_db():
    """Initialize Library on each request"""
    logging.debug('Getting Neo4j Database Connections')
    nglib.verbose = debug
    nglib.init_nglib(config_file, initdb=False)
    nglib.bolt_ses = get_bolt_db()
    g.neo4j_db_bolt = nglib.bolt_ses
    nglib.py2neo_ses = get_py2neo_db()
    g.neo4j_db_py2neo = nglib.py2neo_ses
Beispiel #2
0
def init_db():
    nglib.verbose = debug
    nglib.init_nglib(config_file)
Beispiel #3
0
if 'api' in config:
    use_api = True
    try:
        api['url'] = config['api']['url']
        api['user'] = config['api']['user']
        api['pass'] = config['api']['pass']
        api['verify'] = config['api']['verify']
    except KeyError:
        raise Exception("Please configure the API url, user and pass")
    if api['verify'] == 'False' or api['verify'] == '0':
        api['verify'] = False
    else:
        api['verify'] = True
else:
    # Initialize Library
    nglib.init_nglib(config_file)

###########
# Queries #
###########

## Firewall Path
if args.fpath:
    if use_api:
        print("Error: API Currently Not Supported for this call, " \
              "use quick path: netgrph src dst", file=sys.stderr)
        sys.exit(1)
    nglib.query.path.get_fw_path(args.fpath, args.search, {"depth": depth})

elif args.spath:
    rtype = "TREE"
Beispiel #4
0
    if not os.path.exists(alt_config):
        raise Exception("Configuration File not found", config_file)
    else:
        config_file = alt_config

verbose = 0
if args.v:
    verbose = 1
if args.debug:
    verbose = args.debug

# Setup Globals Debugging
nglib.verbose = verbose

# Initialize Library
nglib.init_nglib(config_file)
logger = logging.getLogger("updatengdb")

# Local config files to import
config = configparser.ConfigParser()
config.read(config_file)
ngfiles = config['ngfiles']


def run_cmd(func, fileName=None, devFile=None):
    """
    Run a function and optionally time it

    FIXME: Refactor to accept *args
    """