# Path: service/server.py
# class Server():
#     def __init__(self, name, port):
#     def add_component_post(self, route, component):
#         def binder():
#             def binded():
#     def add_component_get(self, route, component):
#         def binder():
#             def binded():
#     def run(self):
# 
# Path: inference/inference_service.py
# class InferenceClient(LocalClient):
#     def get_attack_graph(self):
#         return self.get("/attack_graph")
# 
# Path: database/database_service.py
# class DBClient(LocalClient):
#     """
#     The Database Client is a local client as we will only do
#     request from the populator or from the CLI/front-end.
#     """
#     def db_request(self, resource, product, version):
#         product = str(product)
#         version = str(version)
# 
#         db_json = {
#             "product" : product,
#             "version" : version
#         }
# 
#         output = self.post(resource, json=db_json)
#         return output
# 
# Path: service/client.py
# class LocalClient(Client):
#     def __init__(self, port):
#         self._url = "http://127.0.0.1"
#         self._port = port


import os, sys, time
import argparse
import threading
from pprint import pprint
from clint.textui import puts, indent, prompt, colored, progress
from random import random
from service.server import config
from inference.inference_service import InferenceClient
from database.database_service import DBClient
from service.client import LocalClient

    def dispatch(self, args):
        def new_packet():
            if len(self.packet_cache) == 0:
                self.packet_cache += LocalClient(config["sniffer"]).get("/newpackets", default=[])
            if len(self.packet_cache) == 0:
                return None
            packet = self.packet_cache[0]
            self.packet_cache = list(self.packet_cache[1:])
            return packet

        dispatch_map = [{
                "input" : args.echo,
                "func" : lambda x: x
            }, {
                "no_args" : args.gen,
                "func" : lambda: InferenceClient(config["inference"]).get_attack_graph(),
                "wait" : "gen: "
            }, {
                "no_args" : args.exit
            }, {
                "input" : args.vul,
                "func" : lambda: DBClient(config["database"]).db_request("/vulnerability", args.vul[0], args.vul[1]),
                "wait" : "vul: "
            }, {
                "input" : args.priv,
                "func" : lambda: DBClient(config["database"]).db_request("/privileges", args.priv[0], args.priv[1]),
                "wait" : "priv: "
            }, {
                "no_args" : args.graph,

# Path: service/server.py
# class Server():
#     def __init__(self, name, port):
#     def add_component_post(self, route, component):
#         def binder():
#             def binded():
#     def add_component_get(self, route, component):
#         def binder():
#             def binded():
#     def run(self):
# 
# Path: inference/inference_service.py
# class InferenceClient(LocalClient):
#     def get_attack_graph(self):
#         return self.get("/attack_graph")
# 
# Path: database/database_service.py
# class DBClient(LocalClient):
#     """
#     The Database Client is a local client as we will only do
#     request from the populator or from the CLI/front-end.
#     """
#     def db_request(self, resource, product, version):
#         product = str(product)
#         version = str(version)
# 
#         db_json = {
#             "product" : product,
#             "version" : version
#         }
# 
#         output = self.post(resource, json=db_json)
#         return output
# 
# Path: service/client.py
# class LocalClient(Client):
#     def __init__(self, port):
#         self._url = "http://127.0.0.1"
#         self._port = port


# Path: service/cli.py
import os, sys, time
import argparse
import threading
from pprint import pprint
from clint.textui import puts, indent, prompt, colored, progress
from random import random
from service.server import config
from inference.inference_service import InferenceClient
from database.database_service import DBClient
from service.client import LocalClient


    def dispatch(self, args):
        def new_packet():
            if len(self.packet_cache) == 0:
                self.packet_cache += LocalClient(config["sniffer"]).get("/newpackets", default=[])
            if len(self.packet_cache) == 0:
                return None
            packet = self.packet_cache[0]
            self.packet_cache = list(self.packet_cache[1:])
            return packet

        dispatch_map = [{
                "input" : args.echo,
                "func" : lambda x: x
            }, {
                "no_args" : args.gen,
                "func" : lambda: InferenceClient(config["inference"]).get_attack_graph(),
                "wait" : "gen: "
            }, {
                "no_args" : args.exit
            }, {
                "input" : args.vul,
                "func" : lambda: DBClient(config["database"]).db_request("/vulnerability", args.vul[0], args.vul[1]),
                "wait" : "vul: "
            }, {
                "input" : args.priv,
                "func" : lambda: DBClient(config["database"]).db_request("/privileges", args.priv[0], args.priv[1]),
                "wait" : "priv: "
            }, {
                "no_args" : args.graph,

                "func" : lambda: LocalClient(config["graph"]).get("/graph"),