Matrix bridge working and effectively pushing messages
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -22,5 +22,7 @@ def executeRequest(action, outputs, resolved):
|
||||
# session.cookies.set(
|
||||
# sessioncookies[cookie_name] = response[cookie_key],
|
||||
|
||||
|
||||
print(request)
|
||||
#print(response.status_code)
|
||||
#print(response.text)
|
||||
return response, outputs
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
def buildKey(key, outputs, resolved):
|
||||
value = key["keyvalue"]
|
||||
|
||||
if isinstance(value, dict) and "output" in value:
|
||||
value = outputs[value["output"]]
|
||||
if isinstance(value, dict):
|
||||
if "output" in value:
|
||||
value = outputs[value["output"]]
|
||||
|
||||
elif "resolved" in value:
|
||||
value = resolved[value["resolved"]]
|
||||
|
||||
if "prefix" in key["keyvalue"]:
|
||||
value = key["keyvalue"]["prefix"] + str(value)
|
||||
|
||||
return {
|
||||
key["keytitle"]: value,
|
||||
|
||||
@@ -7,5 +7,5 @@ def buildObject(keys, outputs, resolved):
|
||||
object.update(
|
||||
buildKey(key, outputs, resolved),
|
||||
)
|
||||
|
||||
|
||||
return object
|
||||
|
||||
+30
-6
@@ -1,4 +1,22 @@
|
||||
def buildPath(path, outputs, resolved):
|
||||
result = ""
|
||||
|
||||
for part in path:
|
||||
if isinstance(part, dict):
|
||||
if "resolved" in part:
|
||||
value = resolved[part["resolved"]]
|
||||
elif "output" in part:
|
||||
value = outputs[part["output"]]
|
||||
else:
|
||||
raise ValueError(f"Unsupported path component: {part}")
|
||||
|
||||
result += str(value)
|
||||
else:
|
||||
result += str(part)
|
||||
|
||||
return result
|
||||
|
||||
def buildPath3(path, outputs, resolved):
|
||||
if isinstance(path, str):
|
||||
return path
|
||||
|
||||
@@ -6,18 +24,24 @@ def buildPath(path, outputs, resolved):
|
||||
|
||||
for part in path:
|
||||
if isinstance(part, dict):
|
||||
if "resolved" in part:
|
||||
#for key, val in part.items():
|
||||
#value = outputs[part["output"]][part["keys"]]
|
||||
value = resolved["path"]
|
||||
value = resolved[part["resolved"]]
|
||||
#print("DEBUG path", value)
|
||||
|
||||
|
||||
#for key in part.get("keys", []):
|
||||
#value = value[key]
|
||||
if "suffix" in part:
|
||||
suffix = part["suffix"]
|
||||
|
||||
result += str(value)
|
||||
else:
|
||||
result += part
|
||||
#print(result)
|
||||
if value != None:
|
||||
result += str(value)
|
||||
if suffix != None:
|
||||
result += str(suffix)
|
||||
else:
|
||||
result += part
|
||||
print(result)
|
||||
return result
|
||||
|
||||
def buildPath2(path, outputs, resolved):
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from .object import buildObject
|
||||
from .path import buildPath
|
||||
import os
|
||||
|
||||
def buildRequest(definition, outputs, resolved):
|
||||
path = buildPath(definition.path, outputs, resolved)
|
||||
@@ -20,6 +21,9 @@ def buildRequest(definition, outputs, resolved):
|
||||
|
||||
if isinstance(value, dict) and "output" in header_value:
|
||||
value = outputs[value["output"]]
|
||||
if isinstance(value, dict) and "os" in header_value:
|
||||
#value = os.environ[definition.headers[header_name]["os"]]
|
||||
value = os.environ["AS_TOKEN"]
|
||||
|
||||
if isinstance(header_value, dict) and "prefix" in header_value:
|
||||
value = header_value["prefix"] + value
|
||||
|
||||
Binary file not shown.
@@ -23,5 +23,5 @@ def buildOperation(definition):
|
||||
|
||||
#except Exception as error:
|
||||
#outputs = manageFailure(error, action, outputs)
|
||||
|
||||
#print(outputs)
|
||||
return outputs
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
def skipStep(definition, action, outputs):
|
||||
try:
|
||||
if action in definition.skipstep:
|
||||
condition = definition.skipstep[action]
|
||||
|
||||
#if outputs.get([condition["output"]]) is None:
|
||||
#return False
|
||||
#current_value = 1
|
||||
#else:
|
||||
current_value = outputs[condition["output"]]
|
||||
#current_value = 1
|
||||
|
||||
if condition["operator"] == ">=":
|
||||
if current_value >= condition["value"]:
|
||||
print(f"Skipping {action.name}")
|
||||
return True
|
||||
|
||||
except KeyError:
|
||||
#outputs = manageFailure(error)
|
||||
return False
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -15,6 +15,7 @@ def buildLog (action, outputs, response):
|
||||
print(f"{action.name} successful")
|
||||
|
||||
elif action.showstatus is True and response.status_code != 200:
|
||||
print(f"{action.name} failed")
|
||||
print(f"{action.name} failed with status code {response.status_code}")
|
||||
print(f"Response: {response.json()["error"]}")
|
||||
|
||||
return
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
def buildOutput(response, action, outputs):#, select_data):
|
||||
def buildOutput(response, action, outputs):
|
||||
#if select_data != "not applied":
|
||||
#response_data = select_data
|
||||
#else:
|
||||
|
||||
@@ -8,26 +8,8 @@ def recursiveAction(definition, outputs):
|
||||
|
||||
for job in recursiveset:
|
||||
outputs, response = buildAction(job, outputs)
|
||||
#outputs[action.recursive["target"]] = item
|
||||
|
||||
print(outputs["profile"])
|
||||
print(outputs["messages"])
|
||||
return outputs
|
||||
|
||||
def recursiveActionStale(action, outputs):
|
||||
#if hasattr(action, "recursive"):
|
||||
#outputs[action.recursive["target"]] = {}
|
||||
for item in outputs[action.recursive["source"]]:
|
||||
#resolved = resolveItem(action, item)#, outputs)#, resolved)
|
||||
#print("DEBUG Resolved value:", resolved)
|
||||
#outputs[action.recursive["target"]] = outputs[action.recursive["source"]][][action.recursive["target"]]
|
||||
#print(outputs[action.recursive["target"]])
|
||||
|
||||
#Target may be phased out here. its not quite necessary after resolve
|
||||
outputs[action.recursive["target"]] = item
|
||||
|
||||
#print(outputs[action.recursive["target"]])
|
||||
#target = outputs[action.recursive["source"]["target"]
|
||||
outputs, response = buildAction(action, outputs)#, resolved)
|
||||
#print(outputs)
|
||||
return outputs
|
||||
|
||||
@@ -1,75 +1,11 @@
|
||||
def resolveItem(action, item):
|
||||
resolved = {}
|
||||
if hasattr(action, "resolve"):
|
||||
#label = action.resolve["label"]
|
||||
#targetkeys = action.resolve["targetkeys"]
|
||||
#print(item)
|
||||
#target = item
|
||||
|
||||
#for key in targetkeys:
|
||||
# target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
|
||||
for label, keys in action.resolve.items():
|
||||
target = item
|
||||
#print(item)
|
||||
#print(target)
|
||||
|
||||
for key in keys:
|
||||
target = target[key]
|
||||
|
||||
resolved[label] = target
|
||||
#print(resolved[label])
|
||||
|
||||
return resolved
|
||||
|
||||
def resolveItem2(action, item, outputs):
|
||||
#resolved = {}
|
||||
label = action.resolve["label"]
|
||||
targetkeys = action.resolve["targetkeys"]
|
||||
#print(item)
|
||||
target = item
|
||||
|
||||
for key in targetkeys:
|
||||
target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
|
||||
#for label, keys in action.resolve.items():
|
||||
#target = item
|
||||
|
||||
#print(target)
|
||||
#for key in keys:
|
||||
#target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
#print(resolved[label])
|
||||
|
||||
outputs[label] = target
|
||||
#print("Resolver DEBUG", target, outputs[label])
|
||||
return outputs
|
||||
|
||||
def resolveItemBackup(action, item):
|
||||
resolved = {}
|
||||
if hasattr(action, "resolve"):
|
||||
#label = action.resolve["label"]
|
||||
#targetkeys = action.resolve["targetkeys"]
|
||||
#print(item)
|
||||
#target = item
|
||||
|
||||
#for key in targetkeys:
|
||||
# target = target[key]
|
||||
|
||||
#resolved[label] = target
|
||||
|
||||
for label, keys in action.resolve.items():
|
||||
target = item
|
||||
#print(item)
|
||||
#print(target)
|
||||
for key in keys:
|
||||
target = target[key]
|
||||
|
||||
resolved[label] = target
|
||||
print(resolved[label])
|
||||
|
||||
return resolved
|
||||
|
||||
@@ -28,7 +28,7 @@ def buildSelect(action, outputs):
|
||||
#print(select_data)
|
||||
|
||||
return select_data, action, outputs
|
||||
except (KeyError, TypeError):
|
||||
select_data = ["no selection"]
|
||||
except: (KeyError, TypeError)
|
||||
#select_data = ["no selection"]
|
||||
return select_data, action, outputs
|
||||
|
||||
|
||||
Reference in New Issue
Block a user