esc-reporting/common.py | 10 +++++----- esc-reporting/esc-analyze.py | 32 ++++++++++++++++++-------------- esc-reporting/esc-automate.py | 9 +++++---- esc-reporting/esc-collect.py | 12 ++++++------ esc-reporting/esc-report.py | 40 ++++++++++++++++++++++------------------ 5 files changed, 56 insertions(+), 47 deletions(-)
New commits: commit b8a5ac0da7f4724ad41470f81dcffa4a201261c0 Author: Xisco Fauli <xiscofa...@libreoffice.org> Date: Tue Mar 6 12:16:35 2018 +0100 ESC: Replace another os.system diff --git a/esc-reporting/common.py b/esc-reporting/common.py index 3116122..327db68 100644 --- a/esc-reporting/common.py +++ b/esc-reporting/common.py @@ -26,10 +26,10 @@ def sendMail(cfg, mail, subject, content, attachFile=None): msg.attach(MIMEText(content)) if attachFile: - fp = open(attachFile, 'rb') - attach = MIMEApplication(fp.read(), 'pdf') + fp = open(attachFile['path'], 'rb') + attach = MIMEApplication(fp.read(), attachFile['extension']) fp.close() - attach.add_header('Content-Disposition', "attachment'; filename=award.pdf") + attach.add_header('Content-Disposition','attachment; filename="{}"'.format(attachFile['name'])) msg.attach(attach) p = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE) diff --git a/esc-reporting/esc-automate.py b/esc-reporting/esc-automate.py index dff1b4f..3a8c5ee 100755 --- a/esc-reporting/esc-automate.py +++ b/esc-reporting/esc-automate.py @@ -84,7 +84,7 @@ def doGerrit(id, command): raise Exception('error: ' + cmd + ' failed') -def doMail(mail, subject, content, attachFile=None): +def doMail(cfg, mail, subject, content, attachFile=None): error = common.sendMail(cfg, mail, subject, content, attachFile) if error: raise Exception('mail failed') @@ -163,13 +163,14 @@ def handle_mail_pdf(email, name): filePdf = '/tmp/award.pdf' pdfGen = 'pdftk ' + cfg['homedir'] + 'AcknowledgmentForm.pdf fill_form ' + fileFdf + ' output ' + filePdf + attachFile= {'path': filePdf, 'name': 'award.pdf', 'extension': 'pdf'} r = os.system(pdfGen) if r != 0: raise Exception('pdf generation failed ') text = cfg['automate']['1st award']['content'].format(name) - doMail(email, cfg['automate']['1st award']['subject'], text, attachFile=filePdf) + doMail(cfg, email, cfg['automate']['1st award']['subject'], text, attachFile) @@ -177,7 +178,7 @@ def handle_mail_miss_you(email, name): global cfg text = cfg['automate']['we miss you']['content'].format(name) - doMail(email, cfg['automate']['we miss you']['subject'], text) + doMail(cfg, email, cfg['automate']['we miss you']['subject'], text) diff --git a/esc-reporting/esc-report.py b/esc-reporting/esc-report.py index dc0d7cf..33f548a 100755 --- a/esc-reporting/esc-report.py +++ b/esc-reporting/esc-report.py @@ -446,11 +446,12 @@ def report_bug_metrics(): # only generate un tuesdays return - filename = cfg['homedir'] + 'bug-metrics/bug-metrics.ods' + fileName = 'bug-metrics/bug-metrics.ods' + filePath = cfg['homedir'] + fileName fileContent = '/tmp/bugs/content.xml' os.system('rm -rf /tmp/bugs') - os.system('unzip -d /tmp/bugs ' + filename) + os.system('unzip -d /tmp/bugs ' + filePath) fp = open(fileContent, encoding='utf-8') text = fp.read() fp.close() @@ -485,7 +486,7 @@ def report_bug_metrics(): fp = open(fileContent, 'w', encoding='utf-8') print(text, file=fp) fp.close() - os.system('cd /tmp/bugs; zip ' + filename + ' *') + os.system('cd /tmp/bugs; zip ' + filePath + ' *') os.system('cd ' + cfg['homedir'] + 'bug-metrics; git add *; git commit -m \'new version ' + statList['addDate'] + '\'') fileBody='/tmp/esc_odf.txt' @@ -494,7 +495,8 @@ def report_bug_metrics(): fp.close() data = 'ESC bug_metric.fods, based on stats.json from '+statList['addDate'] - return {'title': data, 'mail': 'mentor...@documentfoundation.org', 'attach': filename, 'file' : fileBody} + return {'title': data, 'mail': 'mentor...@documentfoundation.org', + 'attach': {'name': fileName, 'path': filePath, 'extension': 'ods'}, 'file' : fileBody} @@ -823,12 +825,14 @@ def runReport(): pass for i in xMail: - if 'attach' in i: - attach = '-a ' + i['attach'] + ' ' - else: - attach = '' - r = os.system("mail -r mentor...@documentfoundation.org " + cfg['mail']['bcc'] + " -s '" + i['title'] + "' " + attach + i['mail'] + " < " + i['file']) - if r != 0: + with open(i['file'], 'r') as content_file: + text = content_file.read() + + if 'attach' not in i: + i['attach'] = None + + error = common.sendMail(cfg, i['mail'], i['title'], text, i['attach']) + if error: common.util_errorMail(cfg, 'esc-report', 'ERROR: mailing failed with ' + str(e)) commit e94577eadf1fc36fc37ae65a6c45a953a2b9dce3 Author: Xisco Fauli <xiscofa...@libreoffice.org> Date: Tue Mar 6 11:15:37 2018 +0100 ESC: Use correct filename in subject diff --git a/esc-reporting/common.py b/esc-reporting/common.py index b7c8420..3116122 100644 --- a/esc-reporting/common.py +++ b/esc-reporting/common.py @@ -36,8 +36,8 @@ def sendMail(cfg, mail, subject, content, attachFile=None): output, error = p.communicate(msg.as_string().encode('ascii')) return error -def util_errorMail(cfg, text): +def util_errorMail(cfg, fileName, text): print(text) - subject = "ERROR: esc-automate FAILED" + subject = "ERROR: " + fileName + " FAILED" message = text + '\nPlease have a look at vm174' sendMail(cfg, 'mentor...@documentfoundation.org', subject, message) diff --git a/esc-reporting/esc-analyze.py b/esc-reporting/esc-analyze.py index e0b7324..c57e832 100755 --- a/esc-reporting/esc-analyze.py +++ b/esc-reporting/esc-analyze.py @@ -938,42 +938,42 @@ def runAnalyze(): try: runLoadCSV() except Exception as e: - common.util_errorMail(cfg, 'ERROR: runLoadCSV failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: runLoadCSV failed with ' + str(e)) pass try: analyze_mentoring() except Exception as e: - common.util_errorMail(cfg, 'ERROR: analyze_mentoring failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: analyze_mentoring failed with ' + str(e)) pass try: analyze_ui() except Exception as e: - common.util_errorMail(cfg, 'ERROR: analyze_ui failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: analyze_ui failed with ' + str(e)) pass try: analyze_qa() except Exception as e: - common.util_errorMail(cfg, 'ERROR: analyze_qa failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: analyze_qa failed with ' + str(e)) pass try: analyze_esc() except Exception as e: - common.util_errorMail(cfg, 'ERROR: analyze_esc failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: analyze_esc failed with ' + str(e)) pass try: analyze_myfunc() except Exception as e: - common.util_errorMail(cfg, 'ERROR: analyze_myfunc failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: analyze_myfunc failed with ' + str(e)) pass try: analyze_reports() except Exception as e: - common.util_errorMail(cfg, 'ERROR: analyze_reports failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: analyze_reports failed with ' + str(e)) pass try: analyze_final() except Exception as e: - common.util_errorMail(cfg, 'ERROR: analyze_final failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-analyze', 'ERROR: analyze_final failed with ' + str(e)) pass diff --git a/esc-reporting/esc-automate.py b/esc-reporting/esc-automate.py index d008e69..dff1b4f 100755 --- a/esc-reporting/esc-automate.py +++ b/esc-reporting/esc-automate.py @@ -188,7 +188,7 @@ def executeLoop(func, xType, xName): for id in autoList[xType][xName]: func(id, autoList[xType][xName][id]) except Exception as e: - common.util_errorMail(cfg, 'ERROR: ' + str(func) + ' failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-automate', 'ERROR: ' + str(func) + ' failed with ' + str(e)) return del autoList[xType][xName] diff --git a/esc-reporting/esc-collect.py b/esc-reporting/esc-collect.py index 8b812d3..6f55588 100755 --- a/esc-reporting/esc-collect.py +++ b/esc-reporting/esc-collect.py @@ -721,32 +721,32 @@ def runBuild(cfg): try: gerritData = get_gerrit(cfg) except Exception as e: - common.util_errorMail(cfg, 'ERROR: get_gerrit failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-collect', 'ERROR: get_gerrit failed with ' + str(e)) pass try: crashData = get_crash(cfg) except Exception as e: - common.util_errorMail(cfg, 'ERROR: get_crash failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-collect', 'ERROR: get_crash failed with ' + str(e)) pass try: openhubData = get_openhub(cfg) except Exception as e: - common.util_errorMail(cfg, 'ERROR: get_openhub failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-collect', 'ERROR: get_openhub failed with ' + str(e)) pass try: bugzillaData = get_bugzilla(cfg) except Exception as e: - common.util_errorMail(cfg, 'ERROR: get_bugzilla failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-collect', 'ERROR: get_bugzilla failed with ' + str(e)) pass try: ESCData = get_esc_bugzilla(cfg) except Exception as e: - common.util_errorMail(cfg, 'ERROR: get_esc_bugzilla failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-collect', 'ERROR: get_esc_bugzilla failed with ' + str(e)) pass try: gitData = get_git(cfg) except Exception as e: - common.util_errorMail(cfg, 'ERROR: get_git failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-collect', 'ERROR: get_git failed with ' + str(e)) pass diff --git a/esc-reporting/esc-report.py b/esc-reporting/esc-report.py index ebe0b5f..dc0d7cf 100755 --- a/esc-reporting/esc-report.py +++ b/esc-reporting/esc-report.py @@ -777,49 +777,49 @@ def runReport(): if not x is None: xMail.append(x) except Exception as e: - common.util_errorMail(cfg, 'ERROR: report_bug_metrics failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: report_bug_metrics failed with ' + str(e)) pass try: x = report_day_mentoring() if not x is None: xMail.append(x) except Exception as e: - common.util_errorMail(cfg, 'ERROR: report_day_mentoring failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: report_day_mentoring failed with ' + str(e)) pass try: x = report_mentoring() if not x is None: xMail.append(x) except Exception as e: - common.util_errorMail(cfg, 'ERROR: report_mentoring failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: report_mentoring failed with ' + str(e)) pass try: x = report_ui() if not x is None: xMail.append(x) except Exception as e: - common.util_errorMail(cfg, 'ERROR: report_ui failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: report_ui failed with ' + str(e)) pass try: x = report_qa() if not x is None: xMail.append(x) except Exception as e: - common.util_errorMail(cfg, 'ERROR: report_qa failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: report_qa failed with ' + str(e)) pass try: x = report_myfunc() if not x is None: xMail.append(x) except Exception as e: - common.util_errorMail(cfg, 'ERROR: report_myfunc failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: report_myfunc failed with ' + str(e)) pass try: x = report_esc_prototype() if not x is None: xMail.append(x) except Exception as e: - common.util_errorMail(cfg, 'ERROR: report_esc_prototype failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: report_esc_prototype failed with ' + str(e)) pass for i in xMail: @@ -829,7 +829,7 @@ def runReport(): attach = '' r = os.system("mail -r mentor...@documentfoundation.org " + cfg['mail']['bcc'] + " -s '" + i['title'] + "' " + attach + i['mail'] + " < " + i['file']) if r != 0: - common.util_errorMail(cfg, 'ERROR: mailing failed with ' + str(e)) + common.util_errorMail(cfg, 'esc-report', 'ERROR: mailing failed with ' + str(e)) if __name__ == '__main__': commit 511f4ab959d568d45923bb5ea98c070bc343808e Author: Xisco Fauli <xiscofa...@libreoffice.org> Date: Tue Mar 6 10:55:50 2018 +0100 ESC: Ignore *dummy* email diff --git a/esc-reporting/esc-analyze.py b/esc-reporting/esc-analyze.py index 1305a73..e0b7324 100755 --- a/esc-reporting/esc-analyze.py +++ b/esc-reporting/esc-analyze.py @@ -235,13 +235,17 @@ def util_create_statList(): def util_check_mail(name, xmail): global statList - match = re.search(r'[\w\.-]+@[\w\.-]+', xmail.lower()) - if match: - mail = match.group(0) + if xmail.lower() == '*dummy*': + mail = xmail.lower() else: - # Return a fake email in order to not break the script - mail = 'fake-em...@fake-email-script-esc.com' - common.sendMail(cfg, 'xiscofa...@libreoffice.org', 'Error parsing email', 'ERROR parsing' + str(xmail)) + match = re.search(r'[\w\.-]+@[\w\.-]+', xmail.lower()) + if match: + mail = match.group(0) + else: + # Return a fake email in order to not break the script + mail = 'fake-em...@fake-email-script-esc.com' + common.sendMail(cfg, 'xiscofa...@libreoffice.org', 'Error parsing email', 'ERROR parsing' + str(xmail)) + if mail in statList['aliases']: mail = statList['aliases'][mail] if not mail in statList['people']: _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits