def upload(button, pictures, enhancer=None, slack_bot=None): """Check upload targets and upload accordingly.""" # TODO Test this # bool(int('1'))) ? I know, I'm fun at parties email = get_bool_key('Output', 'mail') actions = eval(button['action']) upload_targets = set_upload_targets(actions) mail_list = [] # Why trust positions of file names, if we could trust, # that files ready for upload are always *.jpg uploads = [] for picture in pictures: if picture.find(".jpg") != -1: uploads.append(picture) if enhancer is not None: enhancer.join() # Waits until enhancer terminates for action, activated in upload_targets.items(): if activated: if action == 'slack': upload_to_slack(uploads, slack_bot) else: # Can only be either slack or mail mail_list.append(action) if email: upload_by_mail(uploads, mail_list) print("done uploading")