Skip to content

Commit 9caf098

Browse files
committed
Subflow & excel fixes for auth
1 parent e33a5dd commit 9caf098

File tree

4 files changed

+57
-17
lines changed

4 files changed

+57
-17
lines changed

microsoft-excel/1.0.0/src/app.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,17 @@ def get_excel_file_data(self, file_id):
169169
try:
170170
print("Filename: %s" % filedata["filename"])
171171
if "csv" in filedata["filename"]:
172-
filedata["data"] = filedata["data"].decode("utf-8")
172+
try:
173+
filedata["data"] = filedata["data"].decode("utf-8")
174+
except:
175+
try:
176+
filedata["data"] = filedata["data"].decode("utf-16")
177+
except:
178+
filedata["data"] = filedata["data"].decode("latin-1")
179+
173180
returndata = csv_parse(filedata["data"])
174181
return returndata
182+
175183
except Exception as e:
176184
print("Error parsing file with csv parser for file %s: %s" % (filedata["filename"], e))
177185

@@ -185,7 +193,7 @@ def get_excel_file_data(self, file_id):
185193
except Exception as e:
186194
return {
187195
"success": False,
188-
"reason": "The file is invalid. Are you sure it's a valid excel file? CSV files are not supported."
196+
"reason": "The file is invalid. Are you sure it's a valid excel file? CSV files are not supported.",
189197
"exception": "Error: %s" % e,
190198
}
191199

shuffle-subflow/1.0.0/src/app.py

+31-7
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,34 @@ def __init__(self, redis, logger, console_logger=None):
2121
super().__init__(redis, logger, console_logger)
2222

2323
# Should run user input
24-
def run_userinput(self, user_apikey, sms="", email="", subflow="", information="", startnode="", backend_url=""):
24+
def run_userinput(self, user_apikey, sms="", email="", subflow="", information="", startnode="", backend_url="", source_node=""):
2525
#url = "%s/api/v1/workflows/%s/execute" % (self.url, workflow)
2626

2727
headers = {
2828
"Authorization": "Bearer %s" % user_apikey,
29-
"User-Agent": "Shuffle Userinput 1.0.0"
29+
"User-Agent": "Shuffle Userinput 1.1.0"
3030
}
3131

3232
result = {
3333
"success": True,
3434
"source": "userinput",
35-
"reason": "Userinput data sent and workflow paused. Waiting for user input before continuing workflow."
35+
"reason": "Userinput data sent and workflow paused. Waiting for user input before continuing workflow.",
36+
"information": information,
37+
"click_info": {
38+
"clicked": False,
39+
"time": "",
40+
"ip": "",
41+
"user": "",
42+
"note": "",
43+
}
3644
}
3745

3846
url = self.url
47+
if len(self.base_url) > 0:
48+
url = self.base_url
49+
3950
if len(str(backend_url)) > 0:
40-
url = "%s" % (backend_url)
51+
url = backend_url
4152

4253
print("Found backend url: %s" % url)
4354
#if len(information):
@@ -50,20 +61,31 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
5061
#print("Subflows to run from userinput: ", subflows)
5162

5263
subflows = subflow.split(",")
64+
frontend_url = url
65+
if ":5001" in frontend_url:
66+
print("Should change port to 3001.")
67+
if "appspot.com" in frontend_url:
68+
frontend_url = "https://shuffler.io"
69+
5370
for item in subflows:
5471
# In case of URL being passed, and not just ID
5572
if "/" in item:
5673
item = item.split("/")[-1]
5774

75+
# Subflow should be the subflow to run
76+
# Workflow in the URL should be the source workflow
5877
argument = json.dumps({
5978
"information": information,
6079
"parent_workflow": self.full_execution["workflow"]["id"],
61-
"continue_url": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (url, item, user_apikey, self.full_execution["execution_id"]),
62-
"abort_url": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (url, item, user_apikey, self.full_execution["execution_id"]),
80+
"frontend_continue": "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=true" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
81+
"frontend_abort": "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=false" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
82+
"api_continue": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
83+
"api_abort": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=false" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
6384
})
6485

65-
ret = self.run_subflow(user_apikey, item, argument, source_workflow=self.full_execution["workflow"]["id"], source_execution=self.full_execution["execution_id"], source_auth=self.full_execution["authorization"], startnode=startnode, backend_url=backend_url)
86+
ret = self.run_subflow(user_apikey, item, argument, source_workflow=self.full_execution["workflow"]["id"], source_execution=self.full_execution["execution_id"], source_auth=self.full_execution["authorization"], startnode=startnode, backend_url=backend_url, source_node=source_node)
6687
result["subflow"] = ret
88+
result["subflow_url"] = "%s/workflows/%s" % (frontend_url, item)
6789

6890
if len(email):
6991
jsondata = {
@@ -74,6 +96,7 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
7496
"start": startnode,
7597
"workflow_id": self.full_execution["workflow"]["id"],
7698
"reference_execution": self.full_execution["execution_id"],
99+
"authorization": self.full_execution["authorization"],
77100
}
78101

79102
for item in email.split(","):
@@ -98,6 +121,7 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
98121
"start": startnode,
99122
"workflow_id": self.full_execution["workflow"]["id"],
100123
"reference_execution": self.full_execution["execution_id"],
124+
"authorization": self.full_execution["authorization"],
101125
}
102126

103127
for item in sms.split(","):

shuffle-subflow/1.1.0/src/app.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
5151
url = backend_url
5252

5353
print("Found backend url: %s" % url)
54+
print("AUTH: %s" % self.full_execution["authorization"])
5455
#if len(information):
5556
# print("Should run arg: %s", information)
5657

@@ -67,6 +68,7 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
6768
if "appspot.com" in frontend_url:
6869
frontend_url = "https://shuffler.io"
6970

71+
7072
for item in subflows:
7173
# In case of URL being passed, and not just ID
7274
if "/" in item:
@@ -77,10 +79,10 @@ def run_userinput(self, user_apikey, sms="", email="", subflow="", information="
7779
argument = json.dumps({
7880
"information": information,
7981
"parent_workflow": self.full_execution["workflow"]["id"],
80-
"frontend_continue": "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=true" % (frontend_url, self.full_execution["workflow"]["id"], user_apikey, self.full_execution["execution_id"]),
81-
"frontend_abort": "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=false" % (frontend_url, self.full_execution["workflow"]["id"], user_apikey, self.full_execution["execution_id"]),
82-
"api_continue": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (frontend_url, self.full_execution["workflow"]["id"], user_apikey, self.full_execution["execution_id"]),
83-
"api_abort": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=false" % (frontend_url, self.full_execution["workflow"]["id"], user_apikey, self.full_execution["execution_id"]),
82+
"frontend_continue": "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=true" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
83+
"frontend_abort": "%s/workflows/%s/run?authorization=%s&reference_execution=%s&answer=false" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
84+
"api_continue": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=true" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
85+
"api_abort": "%s/api/v1/workflows/%s/execute?authorization=%s&reference_execution=%s&answer=false" % (frontend_url, self.full_execution["workflow"]["id"], self.full_execution["authorization"], self.full_execution["execution_id"]),
8486
})
8587

8688
ret = self.run_subflow(user_apikey, item, argument, source_workflow=self.full_execution["workflow"]["id"], source_execution=self.full_execution["execution_id"], source_auth=self.full_execution["authorization"], startnode=startnode, backend_url=backend_url, source_node=source_node)

shuffle-tools/1.2.0/src/app.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -971,10 +971,16 @@ def get_file_value(self, filedata):
971971
try:
972972
return filedata["data"].decode("utf-16")
973973
except:
974-
return {
975-
"success": False,
976-
"reason": "Got the file, but the encoding can't be printed",
977-
}
974+
try:
975+
return filedata["data"].decode("utf-8")
976+
except:
977+
try:
978+
return filedata["data"].decode("latin-1")
979+
except:
980+
return {
981+
"success": False,
982+
"reason": "Got the file, but the encoding can't be printed",
983+
}
978984

979985
def download_remote_file(self, url, custom_filename=""):
980986
ret = requests.get(url, verify=False) # nosec

0 commit comments

Comments
 (0)