Fix graphics creation and selection error (Thanks. ThUnD3r|Gr33n).

This commit is contained in:
Schimon Jehudah, Adv. 2024-10-15 23:13:10 +03:00
parent 129e80e8ba
commit 3a4e05bd5c

14
fasi.py
View file

@ -149,7 +149,7 @@ class HttpInstance:
jid_bare, jid_info, jid_kind, node_name) jid_bare, jid_info, jid_kind, node_name)
# Graphic files # 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: #except Exception as e:
else: else:
@ -827,18 +827,20 @@ class FileUtilities:
print(jid_details) print(jid_details)
FileUtilities.handle_photo(jid_bare, jid_vcard, link_href)
filename = 'details/{}.toml'.format(jid_bare) filename = 'details/{}.toml'.format(jid_bare)
Data.save_to_toml(filename, jid_details) Data.save_to_toml(filename, jid_details)
return jid_details return jid_details
def handle_photo(jid_bare, jid_vcard): def handle_photo(jid_bare, jid_vcard, link_href):
filetype = selection = None filetype = selection = None
filecirca = 'photo/{}.*'.format(jid_bare) filecirca = 'photo/{}.*'.format(jid_bare)
filepath = glob.glob(filecirca) filepath_guess = glob.glob(filecirca)
if filepath: if filepath_guess:
filepath = filepath[0] filepath_guess = filepath_guess[0]
filetype = filepath.split('.').pop() filetype = filepath_guess.split('.').pop()
filename = '{}.{}'.format(jid_bare, filetype) filename = '{}.{}'.format(jid_bare, filetype)
elif jid_vcard: elif jid_vcard:
mimetype = filename = filepath = None mimetype = filename = filepath = None