|
12 | 12 | # python notifyCassiopee.py --valid --prod=<prod_name> --full |
13 | 13 | import os |
14 | 14 | import sys |
| 15 | +import re |
15 | 16 | from glob import glob |
16 | 17 | from time import strptime, strftime |
17 | 18 |
|
@@ -414,7 +415,7 @@ def checkValidStatus(sessionSuffix=""): |
414 | 415 | messageText += '\n\nIf the prod. you wish to use is marked as FAILED, '\ |
415 | 416 | 'please contact the maintainers:\nchristophe.benoit@onera.fr, '\ |
416 | 417 | 'vincent.casseau@onera.fr\nor list remaining issues with:\n'\ |
417 | | - 'notifyCassiopee --valid --prod=your_prod_name --full' |
| 418 | + 'notifyCassiopee --valid --prod=your_prod_name --full\n' |
418 | 419 |
|
419 | 420 | return messageSubject, messageText |
420 | 421 |
|
@@ -514,8 +515,8 @@ def compareSessionLogs(logFiles=[], showExecTimeDiffs=False, |
514 | 515 |
|
515 | 516 | baseStateMsg = "" |
516 | 517 | tlog, tlog2 = getTimeFromLog(logFiles[1]) |
517 | | - messageSubject = "[validCassiopee - {}] {} - State: {}".format(prod, tlog, |
518 | | - baseState) |
| 518 | + sessionSuffixMod = sessionSuffix if sessionSuffix else "Cassiopee" |
| 519 | + messageSubject = f"[V&V {sessionSuffixMod} - {prod}] {tlog} - State: {baseState}" |
519 | 520 | messageText = header + compStr + baseStateMsg |
520 | 521 |
|
521 | 522 | if showTestLogs: |
@@ -578,34 +579,60 @@ def compareSessionLogs(logFiles=[], showExecTimeDiffs=False, |
578 | 579 | elif scriptArgs.checkout: |
579 | 580 | messageSubject, messageText = checkCheckoutStatus(sendEmail=scriptArgs.email) |
580 | 581 | elif scriptArgs.valid: |
581 | | - if scriptArgs.prod: |
582 | | - findRef = False if scriptArgs.logs == "latest" else True |
583 | | - scriptArgs.logs = findLogs(scriptArgs.prod, findRef=findRef, |
584 | | - sessionSuffix=scriptArgs.sessionSuffix) |
585 | | - if not( |
586 | | - isinstance(scriptArgs.logs, list) and |
587 | | - len(scriptArgs.logs) == 2 |
588 | | - ): |
589 | | - raise Exception("Two session logs were not found for " |
590 | | - "prod. {}".format(scriptArgs.prod)) |
591 | | - mode = "compare" |
592 | | - elif scriptArgs.logs: |
593 | | - scriptArgs.logs = scriptArgs.logs.split(' ') |
594 | | - if len(scriptArgs.logs) != 2: |
595 | | - raise Exception("Two session logs must be provided using the " |
596 | | - "flag -l or --logs") |
597 | | - mode = "compare" |
598 | | - |
599 | | - if mode == "overview": |
600 | | - messageSubject, messageText = checkValidStatus(sessionSuffix=scriptArgs.sessionSuffix) |
| 582 | + sessionSuffixes=scriptArgs.sessionSuffix.split(' ') |
| 583 | + messageSubject = [] |
| 584 | + messageText = [] |
| 585 | + exitStatus = 0 |
| 586 | + for sessionSuffix in sessionSuffixes: |
| 587 | + if scriptArgs.prod: |
| 588 | + findRef = False if scriptArgs.logs == "latest" else True |
| 589 | + scriptArgs.logs = findLogs(scriptArgs.prod, findRef=findRef, |
| 590 | + sessionSuffix=sessionSuffix) |
| 591 | + if not( |
| 592 | + isinstance(scriptArgs.logs, list) and |
| 593 | + len(scriptArgs.logs) == 2 |
| 594 | + ): |
| 595 | + raise Exception("Two session logs were not found for " |
| 596 | + "prod. {}".format(scriptArgs.prod)) |
| 597 | + mode = "compare" |
| 598 | + elif scriptArgs.logs: |
| 599 | + scriptArgs.logs = scriptArgs.logs.split(' ') |
| 600 | + if len(scriptArgs.logs) != 2: |
| 601 | + raise Exception("Two session logs must be provided using the " |
| 602 | + "flag -l or --logs") |
| 603 | + mode = "compare" |
| 604 | + |
| 605 | + if mode == "overview": |
| 606 | + subject, text = checkValidStatus(sessionSuffix=sessionSuffix) |
| 607 | + messageSubject.append(subject) |
| 608 | + messageText.append(text) |
| 609 | + else: |
| 610 | + subject, text, exitCode = compareSessionLogs( |
| 611 | + logFiles=scriptArgs.logs, |
| 612 | + showExecTimeDiffs=scriptArgs.email, |
| 613 | + showTestLogs=scriptArgs.full, |
| 614 | + update=scriptArgs.update, |
| 615 | + sessionSuffix=sessionSuffix |
| 616 | + ) |
| 617 | + messageSubject.append(subject) |
| 618 | + messageText.append(text) |
| 619 | + if exitStatus == 1: pass |
| 620 | + else: exitStatus = max(exitStatus, exitCode) |
| 621 | + |
| 622 | + if len(messageSubject) == 1: messageSubject = messageSubject[0] |
601 | 623 | else: |
602 | | - messageSubject, messageText, exitStatus = compareSessionLogs( |
603 | | - logFiles=scriptArgs.logs, |
604 | | - showExecTimeDiffs=scriptArgs.email, |
605 | | - showTestLogs=scriptArgs.full, |
606 | | - update=scriptArgs.update, |
607 | | - sessionSuffix=scriptArgs.sessionSuffix |
608 | | - ) |
| 624 | + mods = [s.split("V&V ")[1].split(']')[0].split(' -')[0] for s in messageSubject] |
| 625 | + statuses = [s.split("State: ")[1] for s in messageSubject] |
| 626 | + if "FAILED" in statuses: status = "FAILED" |
| 627 | + elif "MEMLEAK" in statuses: status = "MEMLEAK" |
| 628 | + else: status = "OK" |
| 629 | + messageSubject = messageSubject[0].split(' ') |
| 630 | + messageSubject[1] = ', '.join(mods) |
| 631 | + messageSubject[-1] = status |
| 632 | + if len(messageSubject) == 10: messageSubject[4:7] = "" |
| 633 | + elif len(messageSubject) == 4: messageSubject[1] += ']' |
| 634 | + messageSubject = ' '.join(messageSubject) |
| 635 | + messageText = f"\n\n{83*'#'}\n\n\n".join(messageText) |
609 | 636 |
|
610 | 637 | if scriptArgs.email: |
611 | 638 | notify(recipients=recipients, |
|
0 commit comments