-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemail_notify.py
70 lines (51 loc) · 1.79 KB
/
email_notify.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import os
import json
api_cred = "E:/Work/python_dev/Glacier_pipeline_tools/creds/gmail_app.json"
#get email and password
with open(api_cred) as config_file:
config = json.load(config_file)
MAIL_ID = config.get("MAIL_ID")
PASSWORD = config.get("PASSWORD")
# print("from docs")
def email_notif():
import smtplib
from email.message import EmailMessage
import hou
import time
#Creds
my_email = MAIL_ID
password = PASSWORD
receiver = [MAIL_ID]
#mail template
current_node = hou.pwd()
#All Supported output nodes
out_nodes = {"filecache":"file","rop_alembic":"filename","rop_geometry":"sopoutput",
"opengl":"picture","ifd":"vm_picture","usdexport":"lopoutput",
"file":"file","usdrender":"outputimage"}
#Set Up the render dirs
render_dir = ""
for type,out_path in out_nodes.items():
# print(type,out_path)
if current_node.type().name() == type:
if type == "rop_geometry":
render_dir = current_node.parm(out_path).eval()
current_node = current_node.parent()
else:
render_dir = current_node.parm(out_path).eval()
# print(render_dir)
# print(current_node)
subject = "Render {} is Complete!".format(current_node)
body = """Hey,
Your render task for {} is successfully done at {}. And saved in {}.
Regards,
Glacier Tools""".format(current_node,str(time.ctime()),render_dir)
msg = EmailMessage()
msg['Subject'] = subject
msg['From'] = my_email
msg['To'] = receiver
msg.set_content(body)
# print(body)
with smtplib.SMTP_SSL('smtp.gmail.com',465) as smtp:
smtp.login(my_email,password)
smtp.send_message(msg)
# hou.session.email_notif = email_notif