From 0f500a97c50884b3c7e39cc2505fedeb07666f39 Mon Sep 17 00:00:00 2001 From: Innovation Date: Wed, 3 Apr 2024 08:18:31 +0100 Subject: [PATCH] Finished up Malfunction reporting in the backend. Removed forgotten print statement. --- src/nightserver.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/nightserver.py b/src/nightserver.py index 4819fc8..fe1b8c2 100644 --- a/src/nightserver.py +++ b/src/nightserver.py @@ -163,11 +163,13 @@ def addCyberware(): try: tempName = json['name'] tempHotpluggable = json['hotpluggable'] + tempCanSet = json['canSet'] tempNewCyberware = copy(newCyberwareTemplate) tempNewCyberware['uuid'] = str(uuid.uuid4()) tempNewCyberware['name'] = tempName tempNewCyberware['hotpluggable'] = tempHotpluggable + tempNewCyberware['canSet'] = tempCanSet cyberware.append(tempNewCyberware) @@ -219,6 +221,21 @@ def getCyberwareMalfunctions(): return jsonify(returnArr), 200 +# Arguments { uuid: STRING, malfunction: STRING } +@app.route('/api/cyberware/malfunctions', methods=['POST']) +def setCyberwareMalfunction(): + json = request.get_json() + + try: + desiredId = json['uuid'] + malfunction = json['malfunction'] + + requestedCyberware = getCyberwareHelper(desiredId) + + requestedCyberware['lastMalfunction'] = malfunction + except: + return 'Incorrect usage.\nUsage: { malfunction: STRING, uuid: STRING }\n', 400 + @app.route('/api/cyberware/messages') def getCyberwareMessages(): returnArr = [] @@ -227,7 +244,6 @@ def getCyberwareMessages(): if c['messages'] != None: returnArr.append({ 'name': c['name'], 'messages': c['messages'] }) resetMessages() - print(returnArr) return jsonify(returnArr), 200 # Arguments { uuid: STRING, message:{ title: STRING, message: STRING, progress: INT } } @@ -416,6 +432,9 @@ def authenticate(uuid, endpoint): requestedHardware = c break + if requestedHardware['canSet'] == None: + return False + for e in requestedHardware['canSet']: # Endpoint match if e == endpoint: return True