Reestablished working state
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.
+16
-10
@@ -1,11 +1,17 @@
|
||||
def buildLog (action, outputs):
|
||||
# try:
|
||||
for print_name, print_key in action.prints.items():
|
||||
print(
|
||||
f"{print_name}:",
|
||||
f"{outputs[print_key]}",
|
||||
)
|
||||
import logging
|
||||
|
||||
# except KeyError:
|
||||
#outputs[print_key] = "N/A"
|
||||
# return
|
||||
def buildLog (action, outputs):
|
||||
#if response.status_code == 200:
|
||||
#print(f"{action.name} successful")
|
||||
try:
|
||||
for print_name, print_key in action.prints.items():
|
||||
print(
|
||||
f"{print_name}:",
|
||||
f"{outputs[print_key]}",
|
||||
)
|
||||
|
||||
|
||||
#else:
|
||||
#print(f"{action.name} failed")
|
||||
except: KeyError, TypeError
|
||||
return
|
||||
|
||||
@@ -7,13 +7,22 @@ def manageFailure(error, action, outputs):
|
||||
errors = action.recoverPolicy
|
||||
error_type = type(error)
|
||||
|
||||
print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.")
|
||||
#print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.")
|
||||
|
||||
if error_type in errors:
|
||||
repairs = errors[error_type]
|
||||
|
||||
|
||||
for repair in repairs:
|
||||
outputs, response = buildAction(repair, outputs)
|
||||
if repair == False:
|
||||
return False
|
||||
|
||||
return outputs
|
||||
elif repair is None:
|
||||
return
|
||||
|
||||
else:
|
||||
print(f"{type(error).__name__} detected during {action.name}. Applying recovery policy.")
|
||||
|
||||
outputs, response = buildAction(repair, outputs)
|
||||
|
||||
return outputs
|
||||
print(f"{error}")
|
||||
|
||||
@@ -17,5 +17,3 @@ def buildOutput(response, action, outputs):
|
||||
|
||||
|
||||
return outputs
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
from core.runtime import buildOutput, buildSave, buildLog
|
||||
|
||||
def buildRuntimeAttr(action, outputs, response):
|
||||
#print("BEFORE buildOutput:", type(outputs))
|
||||
if hasattr(action, "outputs"):
|
||||
outputs = buildOutput(response, action, outputs)
|
||||
|
||||
#print("AFTER buildOutput:", type(outputs))
|
||||
#print("DEBUG buildSave")
|
||||
#print("outputs type:", type(outputs))
|
||||
#print("action type:", type(action))
|
||||
#print("outputs keys:", list(outputs) if isinstance(outputs, dict) else "NOT A DICT")
|
||||
|
||||
if hasattr(action, "savedata"):
|
||||
buildSave(outputs, action)
|
||||
|
||||
if hasattr(action, "prints"):
|
||||
buildLog(action, outputs)
|
||||
|
||||
#if hasattr(action, "conversion"):
|
||||
#conversions = action.conversion.items()
|
||||
#for key in action.conversion.items():
|
||||
#print(f"{action.conversion.items[key]}")
|
||||
#convertedoutput = conversions[key]
|
||||
#outputs[conversions[key]] = convertedoutput
|
||||
|
||||
if action.showstatus is True and response.status_code == 200:
|
||||
print(f"{action.name} successful")
|
||||
|
||||
return outputs, response
|
||||
@@ -9,9 +9,9 @@ def buildSave(outputs, action):
|
||||
with open(f"{action.savepath}", "w") as save_file:
|
||||
json.dump(save_data, save_file)
|
||||
|
||||
print(f"{save_name} saved by {action.name}")
|
||||
|
||||
return save_file
|
||||
#print(f"{save_name} saved by {action.name}")
|
||||
print(f"Data saved by {action.name} to {action.savepath}")
|
||||
return outputs
|
||||
|
||||
def loadSave(outputs, action):
|
||||
with open(f"{action.savepath}", "r") as save_file:
|
||||
@@ -19,6 +19,7 @@ def loadSave(outputs, action):
|
||||
|
||||
for load_name in action.loaddata:
|
||||
outputs[load_name] = load_data[load_name]
|
||||
print(f"{load_name} loaded by {action.name}")
|
||||
#print(f"{load_name} loaded by {action.name}")
|
||||
|
||||
print(f"Data loaded by {action.name} from {action.savepath}")
|
||||
return outputs
|
||||
|
||||
Reference in New Issue
Block a user