Python: Further fix of consequent errors.

This commit is contained in:
Schimon Jehudah, Adv. 2024-10-15 23:20:51 +03:00
parent 3a4e05bd5c
commit 8ef7685d0f

11
fasi.py
View file

@ -319,7 +319,7 @@ class HttpInstance:
jid_bare, jid_info, jid_kind, node_name, item_id)
# Graphic files
filename, filepath, filetype, selection = FileUtilities.handle_photo(jid_bare, jid_vcard)
filename, filepath, filetype, selection = FileUtilities.handle_photo(jid_bare, jid_vcard, link_href)
#except Exception as e:
else:
@ -550,7 +550,7 @@ class HttpInstance:
jid_bare, jid_info, jid_kind, node_name)
# Graphic files
filename, filepath, filetype, selection = FileUtilities.handle_photo(jid_bare, jid_vcard)
filename, filepath, filetype, selection = FileUtilities.handle_photo(jid_bare, jid_vcard, link_href)
#except Exception as e:
else:
@ -835,15 +835,14 @@ class FileUtilities:
return jid_details
def handle_photo(jid_bare, jid_vcard, link_href):
filetype = selection = None
filename = filepath = filetype = mimetype = selection = None
filecirca = 'photo/{}.*'.format(jid_bare)
filepath_guess = glob.glob(filecirca)
if filepath_guess:
filepath_guess = filepath_guess[0]
filetype = filepath_guess.split('.').pop()
filepath = filepath_guess[0]
filetype = filepath.split('.').pop()
filename = '{}.{}'.format(jid_bare, filetype)
elif jid_vcard:
mimetype = filename = filepath = None
if jid_vcard['type']:
mimetype = jid_vcard['type']
if mimetype: