uploader_7.py 1019 B

1234567891011121314151617181920212223242526272829303132
  1. def upload(button, pictures, enhancer=None, slack_bot=None):
  2. """Check upload targets and upload accordingly."""
  3. # TODO Test this
  4. # bool(int('1'))) ? I know, I'm fun at parties
  5. email = get_bool_key('Output', 'mail')
  6. actions = eval(button['action'])
  7. upload_targets = set_upload_targets(actions)
  8. mail_list = []
  9. # Why trust positions of file names, if we could trust,
  10. # that files ready for upload are always *.jpg
  11. uploads = []
  12. for picture in pictures:
  13. if picture.find(".jpg") != -1:
  14. uploads.append(picture)
  15. if enhancer is not None:
  16. enhancer.join() # Waits until enhancer terminates
  17. for action, activated in upload_targets.items():
  18. if activated:
  19. if action == 'slack':
  20. upload_to_slack(uploads, slack_bot)
  21. else: # Can only be either slack or mail
  22. mail_list.append(action)
  23. if email:
  24. upload_by_mail(uploads, mail_list)
  25. print("done uploading")