forked from SrinivasaBharath/bugzilla-reports-tool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlast_48hour_buglist.py
executable file
·82 lines (66 loc) · 2.42 KB
/
last_48hour_buglist.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
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
from jinja2 import Environment, FileSystemLoader,select_autoescape
from jinja_markdown import MarkdownExtension
import os
import time
from helpers import *
import datetime
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from cephQeInfra import commonFunctions
from datetime import datetime
import pytz
items=[]
target=""
UTC = pytz.utc
IST = pytz.timezone('Asia/Kolkata')
datetime_ist = datetime.now(IST)
start_time=datetime_ist.strftime("%d %b %Y %H:%M")
project_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
print(project_dir)
template_dir=os.path.join(project_dir, "bugzilla-reports-tool-master/html_template")
g = gapi.GoogleSpreadSheetAPI(SPREADSHEET_NAME, "New_Bugs")
bugs=get_ceph_new_arrivals(5,"-24h")
print("The number of bugs are ::::",len(bugs))
for idx, bug in enumerate(bugs):
print("The bug id is ::::::",bug.bug_id)
print("The bug creator is ::",bug.creator)
target_list=[*bug.target_release]
target=target.join(target_list)
blocker_status=commonFunctions.get_blocker_status(bug.flags)
an_item = dict(bug_id=bug.bug_id,summary=bug.summary,reporter=bug.creator, status=bug.status,
component=bug.component,severity=bug.severity,
is_Blocker=blocker_status,
version=bug.version,target_release=target
)
items.append(an_item)
jinja_env = Environment(extensions=[MarkdownExtension],
loader=FileSystemLoader(template_dir),
autoescape=select_autoescape(["html", "xml"]),
)
template = jinja_env.get_template("last_48hrs_bugs.html")
html = template.render(items=items)
sender = "[email protected]"
#sender = "[email protected]"
recipients = ["[email protected]"]
#recipients = ["[email protected]"]
msg = MIMEMultipart("alternative")
msg["Subject"] = "Last 24 hrs Reported bugs -Auto generated at "\
+ start_time +"[IST]"
msg["From"] = sender
msg["To"] = ", ".join(recipients)
part1 = MIMEText(html, "html")
msg.attach(part1)
try:
s = smtplib.SMTP("localhost")
s.sendmail(sender, recipients, msg.as_string())
s.quit()
print(
"Results have been emailed to {recipients}".format(
recipients=recipients
)
)
except Exception as e:
print("\n")
#log.exception(e)
print("done")