chore: improve Controller

This commit is contained in:
thomasabishop 2025-01-17 11:03:30 +00:00
parent 7c199adba9
commit 81a59122e8
4 changed files with 180 additions and 54 deletions

Binary file not shown.

View file

@ -289,7 +289,11 @@
"type": "tag" "type": "tag"
}, },
{ {
"id": "#ecosolpoc", "id": "#sound",
"type": "tag"
},
{
"id": "#analogue",
"type": "tag" "type": "tag"
}, },
{ {
@ -304,10 +308,6 @@
"id": "#number-theory", "id": "#number-theory",
"type": "tag" "type": "tag"
}, },
{
"id": "#analogue",
"type": "tag"
},
{ {
"id": "#file-system", "id": "#file-system",
"type": "tag" "type": "tag"
@ -344,10 +344,6 @@
"id": "#kernel", "id": "#kernel",
"type": "tag" "type": "tag"
}, },
{
"id": "#sound",
"type": "tag"
},
{ {
"id": "#theory-of-computation", "id": "#theory-of-computation",
"type": "tag" "type": "tag"
@ -436,6 +432,14 @@
"id": "653c0b1d_host_protocols_of_ARPANET", "id": "653c0b1d_host_protocols_of_ARPANET",
"type": "entry" "type": "entry"
}, },
{
"id": "738d0481_sound_recording_as_wave_phenomena",
"type": "entry"
},
{
"id": "747589ad_effects_of_privacy_violation",
"type": "entry"
},
{ {
"id": "82f9c228_dissolution_of_ARPANET", "id": "82f9c228_dissolution_of_ARPANET",
"type": "entry" "type": "entry"
@ -1252,6 +1256,10 @@
"id": "Hexadecimal_number_system", "id": "Hexadecimal_number_system",
"type": "entry" "type": "entry"
}, },
{
"id": "ICMP_Protocol",
"type": "entry"
},
{ {
"id": "IP_addresses", "id": "IP_addresses",
"type": "entry" "type": "entry"
@ -1548,6 +1556,10 @@
"id": "MongoDB_connection", "id": "MongoDB_connection",
"type": "entry" "type": "entry"
}, },
{
"id": "Monitor_DNS_resolution_and_internet_connectivity_script",
"type": "entry"
},
{ {
"id": "Monitoring_processes_and_resources", "id": "Monitoring_processes_and_resources",
"type": "entry" "type": "entry"
@ -1608,10 +1620,6 @@
"id": "Network_card", "id": "Network_card",
"type": "entry" "type": "entry"
}, },
{
"id": "Network_debugging",
"type": "entry"
},
{ {
"id": "Network_fundamentals", "id": "Network_fundamentals",
"type": "entry" "type": "entry"
@ -1708,6 +1716,10 @@
"id": "Peer_to_peer_network", "id": "Peer_to_peer_network",
"type": "entry" "type": "entry"
}, },
{
"id": "Ping",
"type": "entry"
},
{ {
"id": "Ports_in_NodeJS", "id": "Ports_in_NodeJS",
"type": "entry" "type": "entry"
@ -1848,6 +1860,10 @@
"id": "Reciprocals", "id": "Reciprocals",
"type": "entry" "type": "entry"
}, },
{
"id": "Recording_and_playback_of_sound",
"type": "entry"
},
{ {
"id": "Recursion", "id": "Recursion",
"type": "entry" "type": "entry"
@ -2276,6 +2292,10 @@
"id": "Variables_in_C", "id": "Variables_in_C",
"type": "entry" "type": "entry"
}, },
{
"id": "View_IP_addresses",
"type": "entry"
},
{ {
"id": "Viewing_remote_changes_without_merging", "id": "Viewing_remote_changes_without_merging",
"type": "entry" "type": "entry"
@ -2850,6 +2870,14 @@
"source": "#nand-to-tetris", "source": "#nand-to-tetris",
"target": "Hardware_Description_Language" "target": "Hardware_Description_Language"
}, },
{
"source": "#networks",
"target": "Monitor_DNS_resolution_and_internet_connectivity_script"
},
{
"source": "#procedural",
"target": "Monitor_DNS_resolution_and_internet_connectivity_script"
},
{ {
"source": "#javascript", "source": "#javascript",
"target": "React_useReducer" "target": "React_useReducer"
@ -3130,6 +3158,10 @@
"source": "#javascript", "source": "#javascript",
"target": "Map_and_filter_to_reduce_in_JS" "target": "Map_and_filter_to_reduce_in_JS"
}, },
{
"source": "#networks",
"target": "ICMP_Protocol"
},
{ {
"source": "#AWS", "source": "#AWS",
"target": "Accessing_secrets_from_a_Lambda" "target": "Accessing_secrets_from_a_Lambda"
@ -3523,7 +3555,7 @@
"target": "Weaving_the_Web_Berners_Lee" "target": "Weaving_the_Web_Berners_Lee"
}, },
{ {
"source": "#ecosolpoc", "source": "#ecopolsoc",
"target": "Weaving_the_Web_Berners_Lee" "target": "Weaving_the_Web_Berners_Lee"
}, },
{ {
@ -3542,6 +3574,18 @@
"source": "#internet", "source": "#internet",
"target": "Architecture_of_the_World_Wide_Web" "target": "Architecture_of_the_World_Wide_Web"
}, },
{
"source": "#sound",
"target": "Binary_encoding_of_sound"
},
{
"source": "#binary",
"target": "Binary_encoding_of_sound"
},
{
"source": "#analogue",
"target": "Binary_encoding_of_sound"
},
{ {
"source": "#mongo-db", "source": "#mongo-db",
"target": "Modelling_relationships_in_MongoDB" "target": "Modelling_relationships_in_MongoDB"
@ -4374,6 +4418,18 @@
"source": "#typescript", "source": "#typescript",
"target": "Type_guarding_and_narrowing_in_TS" "target": "Type_guarding_and_narrowing_in_TS"
}, },
{
"source": "#ecopolsoc",
"target": "747589ad_effects_of_privacy_violation"
},
{
"source": "#privacy",
"target": "747589ad_effects_of_privacy_violation"
},
{
"source": "#surveillance-capitalism",
"target": "747589ad_effects_of_privacy_violation"
},
{ {
"source": "#operating-systems", "source": "#operating-systems",
"target": "Processes" "target": "Processes"
@ -4806,18 +4862,6 @@
"source": "#Turing", "source": "#Turing",
"target": "Turing_machines" "target": "Turing_machines"
}, },
{
"source": "#procedural",
"target": "Network_debugging"
},
{
"source": "#Linux",
"target": "Network_debugging"
},
{
"source": "#networks",
"target": "Network_debugging"
},
{ {
"source": "#systems-programming", "source": "#systems-programming",
"target": "journald" "target": "journald"
@ -4982,6 +5026,30 @@
"source": "#binary", "source": "#binary",
"target": "Bitwise_operators" "target": "Bitwise_operators"
}, },
{
"source": "#sound",
"target": "Recording_and_playback_of_sound"
},
{
"source": "#analogue",
"target": "Recording_and_playback_of_sound"
},
{
"source": "#physics",
"target": "Recording_and_playback_of_sound"
},
{
"source": "#networks",
"target": "View_IP_addresses"
},
{
"source": "#procedural",
"target": "View_IP_addresses"
},
{
"source": "#Linux",
"target": "View_IP_addresses"
},
{ {
"source": "#propositional-logic", "source": "#propositional-logic",
"target": "Logical_indeterminacy" "target": "Logical_indeterminacy"
@ -5274,6 +5342,14 @@
"source": "#computer-history", "source": "#computer-history",
"target": "e470bf3d_IMPs_in_the_ARPANET" "target": "e470bf3d_IMPs_in_the_ARPANET"
}, },
{
"source": "#networks",
"target": "Ping"
},
{
"source": "#procedural",
"target": "Ping"
},
{ {
"source": "#prealgebra", "source": "#prealgebra",
"target": "Reciprocals" "target": "Reciprocals"
@ -5610,6 +5686,18 @@
"source": "#databases", "source": "#databases",
"target": "Node_and_MySQL_db" "target": "Node_and_MySQL_db"
}, },
{
"source": "#sound",
"target": "738d0481_sound_recording_as_wave_phenomena"
},
{
"source": "#analogue",
"target": "738d0481_sound_recording_as_wave_phenomena"
},
{
"source": "#physics",
"target": "738d0481_sound_recording_as_wave_phenomena"
},
{ {
"source": "#AWS", "source": "#AWS",
"target": "Secrets_or_env_vars_in_AWS" "target": "Secrets_or_env_vars_in_AWS"
@ -6159,7 +6247,7 @@
"target": "f6564af9_AOL_and_early_internet_enclosure" "target": "f6564af9_AOL_and_early_internet_enclosure"
}, },
{ {
"source": "#ecosolpoc", "source": "#ecopolsoc",
"target": "f6564af9_AOL_and_early_internet_enclosure" "target": "f6564af9_AOL_and_early_internet_enclosure"
}, },
{ {
@ -6394,6 +6482,10 @@
"source": "Hardware_Description_Language", "source": "Hardware_Description_Language",
"target": "Boolean_functions" "target": "Boolean_functions"
}, },
{
"source": "Monitor_DNS_resolution_and_internet_connectivity_script",
"target": "Ping"
},
{ {
"source": "React_useReducer", "source": "React_useReducer",
"target": "React_useState" "target": "React_useState"
@ -6478,6 +6570,22 @@
"source": "Application_state_management_with_React_hooks", "source": "Application_state_management_with_React_hooks",
"target": "React_useContext" "target": "React_useContext"
}, },
{
"source": "ICMP_Protocol",
"target": "Internet_Layer_of_Internet_Protocol"
},
{
"source": "ICMP_Protocol",
"target": "Transport_Layer_of_Internet_Protocol"
},
{
"source": "ICMP_Protocol",
"target": "Application_Layer_of_Internet_Protocol"
},
{
"source": "ICMP_Protocol",
"target": "Ping"
},
{ {
"source": "Accessing_secrets_from_a_Lambda", "source": "Accessing_secrets_from_a_Lambda",
"target": "Fetch_from_Secrets_Manager" "target": "Fetch_from_Secrets_Manager"
@ -6630,6 +6738,10 @@
"source": "Architecture_of_the_World_Wide_Web", "source": "Architecture_of_the_World_Wide_Web",
"target": "IP_addresses" "target": "IP_addresses"
}, },
{
"source": "Binary_encoding_of_sound",
"target": "Recording_and_playback_of_sound"
},
{ {
"source": "Practical_walkthrough_Lambda_creation_within_AWS", "source": "Practical_walkthrough_Lambda_creation_within_AWS",
"target": "Lambda_triggers" "target": "Lambda_triggers"
@ -7030,10 +7142,6 @@
"source": "Using_GraphQL_with_Node", "source": "Using_GraphQL_with_Node",
"target": "Middleware_in_NodeJS" "target": "Middleware_in_NodeJS"
}, },
{
"source": "Network_debugging",
"target": "Network_scanning"
},
{ {
"source": "journald", "source": "journald",
"target": "systemd" "target": "systemd"
@ -7094,6 +7202,14 @@
"source": "Python_data_types", "source": "Python_data_types",
"target": "Strings_in_Python" "target": "Strings_in_Python"
}, },
{
"source": "Recording_and_playback_of_sound",
"target": "Binary_encoding_of_sound"
},
{
"source": "View_IP_addresses",
"target": "IP_addresses"
},
{ {
"source": "Magnetic_tape", "source": "Magnetic_tape",
"target": "The_History_of_Computing_Swade" "target": "The_History_of_Computing_Swade"
@ -7202,10 +7318,6 @@
"source": "Set_DNS_settings", "source": "Set_DNS_settings",
"target": "Network_scanning" "target": "Network_scanning"
}, },
{
"source": "Set_DNS_settings",
"target": "Network_debugging"
},
{ {
"source": "Docker_Compose", "source": "Docker_Compose",
"target": "Node_and_MySQL_db" "target": "Node_and_MySQL_db"
@ -7238,6 +7350,10 @@
"source": "e470bf3d_IMPs_in_the_ARPANET", "source": "e470bf3d_IMPs_in_the_ARPANET",
"target": "Network_fundamentals" "target": "Network_fundamentals"
}, },
{
"source": "Ping",
"target": "ICMP_Protocol"
},
{ {
"source": "Magnetic_drum_memory", "source": "Magnetic_drum_memory",
"target": "Williams_Tube_memory" "target": "Williams_Tube_memory"

View file

@ -23,16 +23,19 @@ def main():
) )
parser.add_argument( parser.add_argument(
"command", "command",
choices=["populate-database", "generate-graph"], choices=["populate-database", "generate-graph", "export-tags"],
help="Command to execute", help="Command to execute",
) )
args = parser.parse_args() args = parser.parse_args()
if args.command == "populate-database": if args.command == "populate-database":
controller.populate_database() controller.execute("populate")
if args.command == "generate-graph": if args.command == "generate-graph":
controller.generate_graph() controller.execute("graph")
# if args.command == "export-tags":
# controller.export_tags()
if __name__ == "__main__": if __name__ == "__main__":

View file

@ -1,30 +1,37 @@
from termcolor import colored from termcolor import colored
class Controller: class Controller:
def __init__( def __init__(
self, database_service, table_service, parse_file_service, graph_service self,
database_service,
table_service,
parse_file_service,
graph_service,
# tag_service,
): ):
self.database_service = database_service self.database_service = database_service
self.table_service = table_service self.table_service = table_service
self.parse_file_service = parse_file_service self.parse_file_service = parse_file_service
self.graph_service = graph_service self.graph_service = graph_service
# self.tag_service = tag_service
def populate_database(self): def execute(self, operation):
try: try:
entries = self.parse_file_service.parse_source_directory() match operation:
self.table_service.populate_tables(entries) case "populate":
print(colored("SUCCESS Database populated", "green")) return self.__populate_database()
case "graph":
return self.__generate_graph()
except Exception as e: except Exception as e:
raise Exception(colored(f"ERROR {e}", "red")) raise Exception(colored(f"ERROR {e}", "red"))
finally: finally:
self.database_service.disconnect() self.database_service.disconnect()
print(colored("INFO Database connection closed", "blue"))
def generate_graph(self): def __populate_database(self):
try: entries = self.parse_file_service.parse_source_directory()
self.graph_service.generate_graph() self.table_service.populate_tables(entries)
print(colored("SUCCESS Graph generated", "green")) self.database_service.disconnect()
except Exception as e:
raise Exception(colored(f"ERROR {e}"), "red") def __generate_graph(self):
finally: self.graph_service.generate_graph()
self.database_service.disconnect()
print(colored("INFO Database connection closed", "blue"))