improved attachment handling
This commit is contained in:
parent
8ec4c900e8
commit
7de5856829
|
@ -23,6 +23,7 @@
|
|||
* Store parsed data in Lodur text fields for copy/paste
|
||||
* Cleanup code into proper functions and classes
|
||||
* Lodur "API" class
|
||||
* Heartbeat
|
||||
|
||||
### Known instabilities
|
||||
|
||||
|
|
16
main.py
16
main.py
|
@ -77,11 +77,10 @@ def store_attachments(imap, msg_ids):
|
|||
subject = mail['subject']
|
||||
logger.info('Getting attachment from: ' + subject)
|
||||
for part in mail.walk():
|
||||
if part.get_content_maintype() == 'multipart':
|
||||
continue
|
||||
if part.get('Content-Disposition') is None:
|
||||
continue
|
||||
file_name = part.get_filename()
|
||||
if not file_name:
|
||||
logger.debug('Most probably not an attachment as no filename found')
|
||||
continue
|
||||
|
||||
logger.info('Extracting attachment: ' + file_name)
|
||||
|
||||
|
@ -220,6 +219,15 @@ def main():
|
|||
logger.info(
|
||||
'Einsatzrapport ' + f_id + ' already created in Lodur: ' + lodur_id
|
||||
)
|
||||
# Upload Alarmdepesche as it could contain more information than the first one
|
||||
upload_alarmdepesche(
|
||||
lodur_user,
|
||||
lodur_password,
|
||||
lodur_base_url,
|
||||
lodur_id,
|
||||
file_name,
|
||||
os.path.join(tmp_dir, file_name),
|
||||
)
|
||||
else:
|
||||
# this is real - publish Einsatz on MQTT
|
||||
mqtt_client.publish('pylokid/' + f_type, f_id)
|
||||
|
|
Loading…
Reference in New Issue