daily pastebin goal
51%
SHARE
TWEET

Untitled

a guest Feb 20th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if email_message.is_multipart():
  2. message = ''
  3. if "apply" in receiver_email.split('@')[0].split('_')[0] and isinstance(int(receiver_email.split('@')[0].split('_')[1]), int):
  4.     for part in email_message.walk():
  5.         content_type = str(part.get_content_type()).lower()
  6.         content_dispo = str(part.get('Content-Disposition')).lower()
  7.         print(content_type, content_dispo)
  8.  
  9.         if 'text/plain' in content_type and "attachment" not in content_dispo:
  10.             message = part.get_payload()
  11.  
  12.  
  13.         if content_type in ['application/pdf', 'text/plain', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'image/jpeg', 'image/jpg', 'image/png', 'image/gif'] and "attachment" in content_dispo:
  14.             filename = part.get_filename()
  15.             # open('/tmp/local' + filename, 'wb').write(part.get_payload(decode=True))
  16.             # s3r.meta.client.upload_file('/tmp/local' + filename, bucket_to_upload, filename)
  17.  
  18.             data = {
  19.                 'base64_resume': part.get_payload(),
  20.                 'filename': filename,
  21.             }
  22.             data_list.append(data)
  23.     try:
  24.         api_data = {
  25.             'email_data': email_data,
  26.             'resumes_data': data_list
  27.         }
  28.         print(len(data_list))
  29.         response = requests.post(url, data=json.dumps(api_data),
  30.                                  headers={'content-type': 'application/json'})
  31.         print(response.status_code, response.content)
  32.     except Exception as e:
  33.         print("error %s" % e)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top