Successfully built RMASS message push module, sender id resolver from DM room and included processing for 204 HTTP response with no content when handling incoming JSON
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -11,11 +11,13 @@ def buildLog (action, outputs, response):
|
||||
|
||||
except: (KeyError, TypeError)
|
||||
|
||||
if action.showstatus is True and response.status_code == 200:
|
||||
if action.showstatus is True and response.status_code in [200, 204]:
|
||||
print(f"{action.name} successful")
|
||||
|
||||
elif action.showstatus is True and response.status_code != 200:
|
||||
elif action.showstatus is True and response.status_code not in [200, 204]:
|
||||
print(f"{action.name} failed with status code {response.status_code}")
|
||||
print(f"Response: {response.json()["error"]}")
|
||||
|
||||
try:
|
||||
print(f"Response: {response.json()["error"]}")
|
||||
except KeyError:
|
||||
print(f"Response:", response.json())
|
||||
return
|
||||
|
||||
+20
-18
@@ -1,30 +1,32 @@
|
||||
import json
|
||||
|
||||
def buildOutput(response, action, outputs):
|
||||
#if select_data != "not applied":
|
||||
#response_data = select_data
|
||||
#else:
|
||||
#response_data = response.json()
|
||||
if hasattr(action, "outputs"):
|
||||
try:
|
||||
response_data = response.json()
|
||||
except AttributeError:
|
||||
response_data = json.loads(response)
|
||||
response_objects = [response_data]
|
||||
if response != None:
|
||||
try:
|
||||
response_data = response.json()
|
||||
except AttributeError:
|
||||
response_data = json.loads(response)
|
||||
response_objects = [response_data]
|
||||
|
||||
while response_objects:
|
||||
response_object = response_objects.pop()
|
||||
while response_objects:
|
||||
response_object = response_objects.pop()
|
||||
|
||||
for key, value, in response_object.items():
|
||||
for key, value, in response_object.items():
|
||||
|
||||
if isinstance(value, dict):
|
||||
response_objects.append(value)
|
||||
if isinstance(value, dict):
|
||||
response_objects.append(value)
|
||||
|
||||
for output_name, response_key in action.outputs.items():
|
||||
if key == response_key:
|
||||
outputs[output_name] = value
|
||||
for output_name, response_key in action.outputs.items():
|
||||
if key == response_key:
|
||||
outputs[output_name] = value
|
||||
return outputs
|
||||
|
||||
else:
|
||||
return outputs
|
||||
|
||||
|
||||
|
||||
return outputs
|
||||
#return outputs
|
||||
|
||||
|
||||
|
||||
@@ -11,8 +11,8 @@ def recursiveSet(definition, outputs):
|
||||
for job in recursiveset:
|
||||
outputs, response = buildAction(job, outputs)
|
||||
|
||||
#print(outputs["profile"])
|
||||
#print(outputs["messages"])
|
||||
print("MESSAGE BODY DEBUG")
|
||||
print(resolved["messages"])
|
||||
return outputs
|
||||
|
||||
from core.execution.action.action import buildAction
|
||||
|
||||
@@ -26,4 +26,15 @@ def resolveItem(action, item):
|
||||
if resolved[source] == key:
|
||||
resolved[source] = value
|
||||
|
||||
if "deconstruct" in action.resolve:
|
||||
for source, mutation in action.resolve["deconstruct"].items():
|
||||
deconstructed = str(resolved[source])
|
||||
|
||||
for item in mutation:
|
||||
|
||||
deconstructed = deconstructed.replace(str(item), "")
|
||||
print("DECONSTRUCT TESTING")
|
||||
print(deconstructed)
|
||||
resolved[source] = deconstructed
|
||||
print(resolved["sender"])
|
||||
return resolved
|
||||
|
||||
@@ -17,8 +17,8 @@ def buildSave(action, outputs):
|
||||
for key, value in save_data.items():
|
||||
database.execute("""
|
||||
CREATE TABLE IF NOT EXISTS output_test (
|
||||
dictionary TEXT NOT NULL UNIQUE,
|
||||
value TEXT NOT NULL UNIQUE
|
||||
dictionary TEXT PRIMARY KEY,
|
||||
value TEXT NOT NULL
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user