[Libreoffice-commits] dev-tools.git: 2 commits - esc-reporting/esc-automate.py esc-reporting/qa-tools.py
Xisco Fauli
anistenis at gmail.com
Tue Sep 26 17:04:24 UTC 2017
esc-reporting/esc-automate.py | 9 ----
esc-reporting/qa-tools.py | 78 ++++++++++++++++++++++++++++++++++++------
2 files changed, 68 insertions(+), 19 deletions(-)
New commits:
commit cb35ed6dd1aa3769193a20d0992fdce45c343d85
Author: Xisco Fauli <anistenis at gmail.com>
Date: Tue Sep 26 13:05:30 2017 +0200
QA tools: tag old untouch massping comments as obsolete automatically
The script tags as 'obsolete' all comment starting with
** Please read this message in its entirety before responding **
if the last comment is a massping and it's already tagged as obsolete,
remove it
diff --git a/esc-reporting/qa-tools.py b/esc-reporting/qa-tools.py
index 30eee2d..ace4e65 100755
--- a/esc-reporting/qa-tools.py
+++ b/esc-reporting/qa-tools.py
@@ -13,6 +13,7 @@ import datetime
import json
from pyshorteners import Shortener
import re
+import requests
homeDir = '/home/xisco/dev-tools/esc-reporting/'
@@ -176,12 +177,16 @@ def util_create_statList():
'massping':
{
'needinfo': [],
- 'obsolete': [],
'untouched': [],
'1year': [],
'2years': [],
'3years': []
},
+ 'tags':
+ {
+ 'addObsolete': [],
+ 'removeObsolete': []
+ },
'people': {},
'newUsersPeriod': {},
'targets': {t:{'count':0, 'people':{}} for t in targets_list},
@@ -205,10 +210,14 @@ def util_check_bugzilla_mail(statList, mail, name, date=None, bug=None):
if bug:
statList['people'][mail]['bugs'].add(bug)
-def get_bugzilla(cfg):
+def get_bugzilla():
fileName = homeDir + 'dump/bugzilla_dump.json'
return util_load_file(fileName)
+def get_config():
+ fileName = homeDir + 'config.json'
+ return util_load_file(fileName)
+
def isOpen(status):
return status == 'NEW' or status == 'ASSIGNED' or status == 'REOPENED'
@@ -371,6 +380,7 @@ def analyze_bugzilla(statList, bugzillaData, cfg, lIgnore):
isReopened = False
closeDate = None
reopenerEmail = ""
+
for action in row['history']:
actionMail = action['who']
actionDate = datetime.datetime.strptime(action['when'], "%Y-%m-%dT%H:%M:%SZ")
@@ -674,6 +684,11 @@ def analyze_bugzilla(statList, bugzillaData, cfg, lIgnore):
if commentDate >= cfg[reportPeriod]:
statList['detailedReport']['comments_count'] += 1
+ if isOpen(rowStatus) and \
+ "obsolete" not in [x.lower() for x in comment["tags"]] and \
+ (comment["text"].startswith(untouchedPingComment) or \
+ "[NinjaEdit]" in comment["text"]):
+ statList['tags']['addObsolete'].append(comment["id"])
if len(comments) > 0:
if comments[-1]["text"].startswith(untouchedPingComment):
@@ -685,8 +700,12 @@ def analyze_bugzilla(statList, bugzillaData, cfg, lIgnore):
statList['massping']['2years'].append(rowId)
else:
statList['massping']['1year'].append(rowId)
- if "obsolete" in comments[-1]["tags"]:
- statList['massping']['obsolete'].append(rowId)
+
+ if isOpen(rowStatus):
+ if "obsolete" not in [x.lower() for x in comments[-1]["tags"]]:
+ statList['tags']['addObsolete'].pop()
+ else:
+ statList['tags']['removeObsolete'].append(comments[-1]["id"])
elif needInfoPingComment in comments[-1]["text"]:
if rowStatus == 'NEEDINFO':
statList['massping']['needinfo'].append(rowId)
@@ -1019,11 +1038,10 @@ def create_wikimedia_table_by_period(cfg, statList):
print(output.replace('wikitable', 'wikitable sortable'), file=fp)
fp.close()
-def untouchedBugs_Report(startList):
+def untouchedBugs_Report(statList):
fp = open('/tmp/untouch_report.txt', 'w', encoding='utf-8')
print('* Untouched Bugs Report from {} to {}'.format(cfg[reportPeriod].strftime("%Y-%m-%d"), statList['stat']['newest']), file=fp )
-
for key, value in sorted(statList['massping'].items()):
print(file=fp)
print('* ' + key + ' - ' + str(len(value)) + ' bugs.', file=fp)
@@ -1038,7 +1056,44 @@ def untouchedBugs_Report(startList):
fp.close()
-def users_Report(statList) :
+def automated_tagging(statList):
+ #tags are sometimes not saved in bugzilla_dump.json
+ #thus, save those comments automatically tagged as obsolete
+ #so we don't tag them again next time
+ lAddObsolete = []
+ filename = "addObsolete.txt"
+ if os.path.exists(filename):
+ f = open(filename, 'r')
+ lAddObsolete = f.read().splitlines()
+ f.close()
+
+ for comment_id in statList['tags']['addObsolete']:
+ if str(comment_id) not in lAddObsolete:
+ command = '{"comment_id" : ' + str(comment_id) + ', "add" : ["obsolete"]}'
+ url = 'https://bugs.documentfoundation.org/rest/bug/comment/' + \
+ str(comment_id) + '/tags' + '?api_key=' + cfg['bugzilla']['api-key']
+ r = requests.put(url, command)
+ if os.path.exists(filename):
+ append_write = 'a'
+ else:
+ append_write = 'w'
+ f = open(filename,append_write)
+ f.write(str(comment_id) + '\n')
+ f.close()
+ print(str(comment_id) + ' - ' + r.text)
+ r.close()
+ else:
+ print(str(comment_id) + ' - doing nothing')
+
+ for comment_id in statList['tags']['removeObsolete']:
+ command = '{"comment_id" : ' + str(comment_id) + ', "remove" : ["obsolete"]}'
+ url = 'https://bugs.documentfoundation.org/rest/bug/comment/' + \
+ str(comment_id) + '/tags' + '?api_key=' + cfg['bugzilla']['api-key']
+ r = requests.put(url, command)
+ print(str(comment_id) + ' - ' + r.text)
+ r.close()
+
+def users_Report(statList):
print('Users report from {} to {}'.format(cfg[newUsersPeriod].strftime("%Y-%m-%d"), statList['stat']['newest']))
#fp = open('/tmp/users_report.txt', 'w', encoding='utf-8')
@@ -1253,7 +1308,7 @@ def Weekly_Report(statList) :
fp.close()
def runCfg(homeDir):
- cfg = {}
+ cfg = get_config()
cfg['homedir'] = homeDir
cfg['todayDate'] = datetime.datetime.now().replace(hour=0, minute=0,second=0)
cfg[reportPeriod] = cfg['todayDate'] - datetime.timedelta(days= int(reportPeriod[:-1]))
@@ -1273,12 +1328,13 @@ if __name__ == '__main__':
cfg = runCfg(homeDir)
- bugzillaData = get_bugzilla(cfg)
+ bugzillaData = get_bugzilla()
lIgnore = []
if os.path.exists("ignore.txt"):
f = open('ignore.txt', 'r')
lIgnore = f.read().splitlines()
+ f.close()
statList = util_create_statList()
analyze_bugzilla(statList, bugzillaData, cfg, lIgnore)
@@ -1298,10 +1354,12 @@ if __name__ == '__main__':
crashes_Report(statList)
elif sys.argv[1] == 'ping':
untouchedBugs_Report(statList)
+ elif sys.argv[1] == 'tag':
+ automated_tagging(statList)
elif sys.argv[1] == 'weekly':
Weekly_Report(statList)
else:
- print('You must use \'report\',\'blog\', \'target\', \'period\', \'users\', \'crash\', \'ping\' or \'weekly\' as parameter.')
+ print("You must use 'report','blog', 'target', 'period', 'users', 'crash', 'ping', 'tag' or 'weekly' as parameter.")
sys.exit(1)
print('End of report')
commit c781ea1972f9bab1159b23b8e1b1c148daa9dd00
Author: Xisco Fauli <anistenis at gmail.com>
Date: Tue Sep 26 02:20:58 2017 +0200
These are unused after 252dd394b1df99035c80a3b3da9c53dac3bdaf86
diff --git a/esc-reporting/esc-automate.py b/esc-reporting/esc-automate.py
index 3674147..2acfd97 100755
--- a/esc-reporting/esc-automate.py
+++ b/esc-reporting/esc-automate.py
@@ -168,12 +168,6 @@ def handle_bugzilla_cc(id, email):
-def handle_bugzilla_ui_cc(id, email):
- command = '{"cc": {"add": ["libreoffice-ux-advise at lists.freedesktop.org"]}}'
- doBugzilla(id, command)
-
-
-
def handle_mail_pdf(email, name):
global cfg, pdfFieldData
@@ -257,10 +251,7 @@ def runAutomate():
executeLoop(handle_gerrit_comment, 'gerrit', 'to_abandon_comment')
executeLoop(handle_bugzilla_unassign, 'bugzilla', 'to_unassign_unassign')
executeLoop(handle_bugzilla_comment, 'bugzilla', 'to_unassign_comment')
- executeLoop(handle_bugzilla_reset_status, 'bugzilla', 'assign_problem_status')
- executeLoop(handle_bugzilla_reset_user, 'bugzilla', 'assign_problem_user')
executeLoop(handle_bugzilla_cc, 'bugzilla', 'missing_cc')
- executeLoop(handle_bugzilla_ui_cc, 'bugzilla', 'missing_ui_cc')
executeLoop(handle_mail_miss_you, 'mail', 'we_miss_you_email')
executeLoop(handle_mail_pdf, 'mail', 'award_1st_email')
More information about the Libreoffice-commits
mailing list