mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
fx
This commit is contained in:
+30
-22
@@ -20,14 +20,13 @@ prepped_tracks = {
|
|||||||
"prio":"",
|
"prio":"",
|
||||||
"jingles":""
|
"jingles":""
|
||||||
}
|
}
|
||||||
logger = logging.getLogger("discord")
|
|
||||||
|
|
||||||
class QueryControl:
|
class QueryControl:
|
||||||
"""
|
"""
|
||||||
This class `QueryControl` is used to manage queries with information about the author, UUID,
|
This class `QueryControl` is used to manage queries with information about the author, UUID,
|
||||||
content, logger, context, and replies.
|
content, logger, context, and replies.
|
||||||
"""
|
"""
|
||||||
def __init__(self, query_author, query_uuid, query_content, uplogger, ctx) -> None:
|
def __init__(self, query_author, query_uuid, query_content, ctx) -> None:
|
||||||
self.author = query_author
|
self.author = query_author
|
||||||
self.uuid = query_uuid
|
self.uuid = query_uuid
|
||||||
self.content = query_content
|
self.content = query_content
|
||||||
@@ -41,10 +40,12 @@ class QueryControl:
|
|||||||
|
|
||||||
@app.route("/prepped_tracks", methods=["POST"])
|
@app.route("/prepped_tracks", methods=["POST"])
|
||||||
def log_radio_tracks():
|
def log_radio_tracks():
|
||||||
app.logger.info(request)
|
logger = logging.getLogger("discord")
|
||||||
|
|
||||||
|
logger.info(request)
|
||||||
record = json.loads(request.data)
|
record = json.loads(request.data)
|
||||||
app.logger.info(record)
|
logger.info(record)
|
||||||
app.logger.info("DATA RECEIVED")
|
logger.info("DATA RECEIVED")
|
||||||
return jsonify("SUCCESS")
|
return jsonify("SUCCESS")
|
||||||
|
|
||||||
|
|
||||||
@@ -56,10 +57,11 @@ def answer_external_command():
|
|||||||
:return: The function `answer_external_command()` is returning a JSON response with the message
|
:return: The function `answer_external_command()` is returning a JSON response with the message
|
||||||
"SUCCESS".
|
"SUCCESS".
|
||||||
"""
|
"""
|
||||||
app.logger.info(request)
|
logger = logging.getLogger("discord")
|
||||||
|
logger.info(request)
|
||||||
record = json.loads(request.data)
|
record = json.loads(request.data)
|
||||||
app.logger.info(record)
|
logger.info(record)
|
||||||
app.logger.info("DATA RECEIVED")
|
logger.info("DATA RECEIVED")
|
||||||
incoming_q.put(record)
|
incoming_q.put(record)
|
||||||
return jsonify("SUCCESS")
|
return jsonify("SUCCESS")
|
||||||
|
|
||||||
@@ -74,25 +76,29 @@ def check_alive():
|
|||||||
"""
|
"""
|
||||||
return jsonify("ALIVE")
|
return jsonify("ALIVE")
|
||||||
|
|
||||||
def flask_debug(_logger):
|
def flask_debug():
|
||||||
"""
|
"""
|
||||||
The `flask_debug` function starts a Flask application in debug mode without using the reloader.
|
The `flask_debug` function starts a Flask application in debug mode without using the reloader.
|
||||||
Do not use for production for fucks sake.
|
Do not use for production for fucks sake.
|
||||||
"""
|
"""
|
||||||
_logger.info("Attempt debug")
|
logger = logging.getLogger("discord")
|
||||||
|
|
||||||
|
logger.info("Attempt debug")
|
||||||
# trunk-ignore(bandit/B201)
|
# trunk-ignore(bandit/B201)
|
||||||
app.run(debug=True, use_reloader=False, host=HOST_ADDRESS, port=PORT_ADDRESS)
|
app.run(debug=True, use_reloader=False, host=HOST_ADDRESS, port=PORT_ADDRESS)
|
||||||
|
|
||||||
|
|
||||||
def waitress_run(_logger):
|
def waitress_run():
|
||||||
"""
|
"""
|
||||||
The `waitress_run` function serves the `app` on host "0.0.0.0"
|
The `waitress_run` function serves the `app` on host "0.0.0.0"
|
||||||
and port 5000 using the Waitress WSGI server.
|
and port 5000 using the Waitress WSGI server.
|
||||||
"""
|
"""
|
||||||
_logger.info("Attempt waitress")
|
logger = logging.getLogger("discord")
|
||||||
|
|
||||||
|
logger.info("Attempt waitress")
|
||||||
serve(app, host=HOST_ADDRESS, port=PORT_ADDRESS)
|
serve(app, host=HOST_ADDRESS, port=PORT_ADDRESS)
|
||||||
|
|
||||||
def scan_queue(_logger):
|
def scan_queue():
|
||||||
"""
|
"""
|
||||||
The function `scan_queue` reads data from a queue, logs it, and appends it to another queue.
|
The function `scan_queue` reads data from a queue, logs it, and appends it to another queue.
|
||||||
|
|
||||||
@@ -101,12 +107,13 @@ def scan_queue(_logger):
|
|||||||
and provide information for debugging purposes. In this code snippet, the `_logger` object is used
|
and provide information for debugging purposes. In this code snippet, the `_logger` object is used
|
||||||
to log the
|
to log the
|
||||||
"""
|
"""
|
||||||
|
logger = logging.getLogger("discord")
|
||||||
while True:
|
while True:
|
||||||
data = OUT_COMM_Q.get()
|
data = OUT_COMM_Q.get()
|
||||||
_logger.info(data)
|
logger.info(data)
|
||||||
awaiting_q.append(data)
|
awaiting_q.append(data)
|
||||||
|
|
||||||
def scan_incoming(_logger):
|
def scan_incoming():
|
||||||
"""
|
"""
|
||||||
The `scan_incoming` function continuously checks for incoming data, processes it, and logs when data
|
The `scan_incoming` function continuously checks for incoming data, processes it, and logs when data
|
||||||
is found.
|
is found.
|
||||||
@@ -116,10 +123,11 @@ def scan_incoming(_logger):
|
|||||||
debugging, monitoring, or tracking the flow of the program. In this case, the `_logger` is being
|
debugging, monitoring, or tracking the flow of the program. In this case, the `_logger` is being
|
||||||
used
|
used
|
||||||
"""
|
"""
|
||||||
|
logger = logging.getLogger("discord")
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
answer = incoming_q.get(block=False)
|
answer = incoming_q.get(block=False)
|
||||||
_logger.info("DATA FOUND")
|
logger.info("DATA FOUND")
|
||||||
record_stored = False
|
record_stored = False
|
||||||
for record in awaiting_q:
|
for record in awaiting_q:
|
||||||
if record.uuid in answer.keys():
|
if record.uuid in answer.keys():
|
||||||
@@ -129,7 +137,7 @@ def scan_incoming(_logger):
|
|||||||
IN_COMM_Q.put(record)
|
IN_COMM_Q.put(record)
|
||||||
if not record_stored:
|
if not record_stored:
|
||||||
for key in answer.keys():
|
for key in answer.keys():
|
||||||
record = QueryControl("Orphaned", key, "Orphan", _logger, None)
|
record = QueryControl("Orphaned", key, "Orphan", None)
|
||||||
record.stop = True
|
record.stop = True
|
||||||
record.entries = answer[record.uuid]
|
record.entries = answer[record.uuid]
|
||||||
IN_COMM_Q.put(record)
|
IN_COMM_Q.put(record)
|
||||||
@@ -147,12 +155,12 @@ def comm_subroutine(logger):
|
|||||||
"""
|
"""
|
||||||
#logger.setLevel(logging.DEBUG)
|
#logger.setLevel(logging.DEBUG)
|
||||||
logger = logging.getLogger("discord")
|
logger = logging.getLogger("discord")
|
||||||
logger.info("Started")
|
logger.info("Started comms")
|
||||||
threads = []
|
threads = []
|
||||||
#threads.append(threading.Thread(target=flask_debug, args=(logger,)))
|
#threads.append(threading.Thread(target=flask_debug))
|
||||||
threads.append(threading.Thread(target=waitress_run, args=(logger,)))
|
threads.append(threading.Thread(target=waitress_run))
|
||||||
threads.append(threading.Thread(target=scan_queue,args=(logger,)))
|
threads.append(threading.Thread(target=scan_queue))
|
||||||
threads.append(threading.Thread(target=scan_incoming,args=(logger,)))
|
threads.append(threading.Thread(target=scan_incoming))
|
||||||
|
|
||||||
|
|
||||||
for worker in threads:
|
for worker in threads:
|
||||||
|
|||||||
Reference in New Issue
Block a user