Skip to content

Commit 66ccc3a

Browse files
operation
1 parent 1a72ba2 commit 66ccc3a

File tree

3 files changed

+42
-43
lines changed

3 files changed

+42
-43
lines changed

apps/application/flow/step_node/variable_assign_node/impl/base_variable_assign_node.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def execute(self, variable_list, **kwargs) -> NodeResult:
7171
result_list = []
7272
is_chat = False
7373
for variable in variable_list:
74-
if 'fields' not in variable:
74+
if not variable.get('fields'):
7575
continue
7676

7777
if 'global' == variable['fields'][0]:

apps/common/handle/impl/common_handle.py

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -86,46 +86,45 @@ def handle_images(deps, archive: ZipFile) -> []:
8686

8787

8888
def xlsx_embed_cells_images(buffer) -> {}:
89-
archive = ZipFile(buffer)
90-
# 解析cellImage.xml文件
91-
deps = get_dependents(archive, get_rels_path("xl/cellimages.xml"))
92-
image_rel = handle_images(deps=deps, archive=archive)
93-
# 工作表及其中图片ID
94-
sheet_list = {}
95-
for item in archive.namelist():
96-
if not item.startswith('xl/worksheets/sheet'):
97-
continue
98-
key = item.split('/')[-1].split('.')[0].split('sheet')[-1]
99-
sheet_list[key] = parse_element_sheet_xml(fromstring(archive.read(item)))
100-
cell_images_xml = parse_element(fromstring(archive.read("xl/cellimages.xml")))
101-
cell_images_rel = {}
102-
for image in image_rel:
103-
cell_images_rel[image.embed] = image
104-
for cnv, embed in cell_images_xml.items():
105-
cell_images_xml[cnv] = cell_images_rel.get(embed)
106-
result = {}
107-
for key, img in cell_images_xml.items():
108-
all_cells = [
109-
cell
110-
for _sheet_id, sheet in sheet_list.items()
111-
if sheet is not None
112-
for cell in sheet or []
113-
]
89+
with ZipFile(buffer) as archive:
90+
# 解析cellImage.xml文件
91+
deps = get_dependents(archive, get_rels_path("xl/cellimages.xml"))
92+
image_rel = handle_images(deps=deps, archive=archive)
93+
# 工作表及其中图片ID
94+
sheet_list = {}
95+
for item in archive.namelist():
96+
if not item.startswith('xl/worksheets/sheet'):
97+
continue
98+
key = item.split('/')[-1].split('.')[0].split('sheet')[-1]
99+
sheet_list[key] = parse_element_sheet_xml(fromstring(archive.read(item)))
100+
cell_images_xml = parse_element(fromstring(archive.read("xl/cellimages.xml")))
101+
cell_images_rel = {}
102+
for image in image_rel:
103+
cell_images_rel[image.embed] = image
104+
for cnv, embed in cell_images_xml.items():
105+
cell_images_xml[cnv] = cell_images_rel.get(embed)
106+
result = {}
107+
for key, img in cell_images_xml.items():
108+
all_cells = [
109+
cell
110+
for _sheet_id, sheet in sheet_list.items()
111+
if sheet is not None
112+
for cell in sheet or []
113+
]
114114

115-
image_excel_id_list = [
116-
cell for cell in all_cells
117-
if isinstance(cell, str) and key in cell
118-
]
119-
# print(key, img)
120-
if img is None:
121-
continue
122-
if len(image_excel_id_list) > 0:
123-
image_excel_id = image_excel_id_list[-1]
124-
with archive.open(img.target) as f:
125-
img_byte = io.BytesIO()
126-
im = PILImage.open(f).convert('RGB')
127-
im.save(img_byte, format='JPEG')
128-
image = File(id=uuid.uuid7(), file_name=img.path, meta={'debug': False, 'content': img_byte.getvalue()})
129-
result['=' + image_excel_id] = image
130-
archive.close()
115+
image_excel_id_list = [
116+
cell for cell in all_cells
117+
if isinstance(cell, str) and key in cell
118+
]
119+
# print(key, img)
120+
if img is None:
121+
continue
122+
if len(image_excel_id_list) > 0:
123+
image_excel_id = image_excel_id_list[-1]
124+
with archive.open(img.target) as f:
125+
img_byte = io.BytesIO()
126+
im = PILImage.open(f).convert('RGB')
127+
im.save(img_byte, format='JPEG')
128+
image = File(id=uuid.uuid7(), file_name=img.path, meta={'debug': False, 'content': img_byte.getvalue()})
129+
result['=' + image_excel_id] = image
131130
return result

apps/trigger/handler/impl/trigger/event_trigger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def execute(trigger, request=None, **kwargs):
119119
trigger_setting = trigger.get('trigger_setting')
120120
if trigger_setting.get('token'):
121121
token = request.META.get('HTTP_AUTHORIZATION')
122-
if trigger_setting.get('token') != token.replace('Bearer ', ''):
122+
if not token or trigger_setting.get('token') != token.replace('Bearer ', ''):
123123
raise AppAuthenticationFailed(1002, _('Authentication information is incorrect'))
124124
is_active = trigger.get('is_active')
125125
if not is_active:

0 commit comments

Comments
 (0)