Started looking at ways to parse invalid JSON patterns

This commit is contained in:
frikky
2022-02-16 20:14:52 +01:00
parent be31c329de
commit 8af27d2800
4 changed files with 430 additions and 395 deletions
+24 -1
View File
@@ -16,6 +16,7 @@ import urllib.parse
import jinja2
from io import BytesIO
from liquid import Liquid
#import barely_json
runtime = os.getenv("SHUFFLE_SWARM_CONFIG", "")
@@ -171,6 +172,7 @@ class AppBase:
# Try it with some magic
self.logger.info(f"""[DEBUG] Inside Send result with status {action_result["status"]}""")
#if isinstance(action_result,
# FIXME: Add cleanup of parameters to not send to frontend here
params = {}
@@ -1745,7 +1747,7 @@ class AppBase:
basejson = json.loads(baseresult)
except json.decoder.JSONDecodeError as e:
try:
baseresult = baseresult.replace("\'", "\"")
#baseresult = baseresult.replace("\'", "\"")
basejson = json.loads(baseresult)
except json.decoder.JSONDecodeError as e:
print("Parser issue with JSON: %s" % e)
@@ -2333,6 +2335,27 @@ class AppBase:
return True, ""
#
#
#
#
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
# CONT
#
#
#
#
# THE START IS ACTUALLY RIGHT HERE :O
# Checks whether conditions are met, otherwise set
+12 -1
View File
@@ -5177,8 +5177,19 @@ func handleCloudSetup(resp http.ResponseWriter, request *http.Request) {
_, err = handleStopCloudSync(syncPath, *org)
if err != nil {
ret := shuffle.ResultChecker{
Success: false,
Reason: err,
}
resp.WriteHeader(401)
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err)))
b, err := json.Marshal(requestData)
if err != nil {
resp.Write([]byte(fmt.Sprintf(`{"success": false, "reason": "%s"}`, err)))
return
}
resp.Write([]byte(fmt.Sprintf(b)))
} else {
resp.WriteHeader(200)
resp.Write([]byte(fmt.Sprintf(`{"success": true, "reason": "Successfully disabled cloud sync for org."}`)))