diff options
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/launcher.py')
-rwxr-xr-x | bitbake/lib/toaster/contrib/tts/launcher.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/launcher.py b/bitbake/lib/toaster/contrib/tts/launcher.py index 90c6d95c58..e5794c1c56 100755 --- a/bitbake/lib/toaster/contrib/tts/launcher.py +++ b/bitbake/lib/toaster/contrib/tts/launcher.py | |||
@@ -31,13 +31,11 @@ import smtplib | |||
31 | # Import the email modules we'll need | 31 | # Import the email modules we'll need |
32 | from email.mime.text import MIMEText | 32 | from email.mime.text import MIMEText |
33 | 33 | ||
34 | DEBUG=True | ||
35 | |||
36 | def _take_lockfile(): | 34 | def _take_lockfile(): |
37 | return shellutils.lockfile(shellutils.mk_lock_filename()) | 35 | return shellutils.lockfile(shellutils.mk_lock_filename()) |
38 | 36 | ||
39 | 37 | ||
40 | def read_next_task_by_state(task_state, task_name = None): | 38 | def read_next_task_by_state(task_state, task_name=None): |
41 | if not os.path.exists(os.path.join(os.path.dirname(__file__), config.BACKLOGFILE)): | 39 | if not os.path.exists(os.path.join(os.path.dirname(__file__), config.BACKLOGFILE)): |
42 | return None | 40 | return None |
43 | os.rename(config.BACKLOGFILE, config.BACKLOGFILE + ".tmp") | 41 | os.rename(config.BACKLOGFILE, config.BACKLOGFILE + ".tmp") |
@@ -56,28 +54,28 @@ def read_next_task_by_state(task_state, task_name = None): | |||
56 | os.remove(config.BACKLOGFILE + ".tmp") | 54 | os.remove(config.BACKLOGFILE + ".tmp") |
57 | return task | 55 | return task |
58 | 56 | ||
59 | def send_report(task_name, plaintext, errtext = None): | 57 | def send_report(task_name, plaintext, errtext=None): |
60 | if errtext is None: | 58 | if errtext is None: |
61 | msg = MIMEText(plaintext) | 59 | msg = MIMEText(plaintext) |
62 | else: | 60 | else: |
63 | if plaintext is None: | 61 | if plaintext is None: |
64 | plaintext="" | 62 | plaintext = "" |
65 | msg = MIMEText("--STDOUT dump--\n\n%s\n\n--STDERR dump--\n\n%s" % (plaintext, errtext)) | 63 | msg = MIMEText("--STDOUT dump--\n\n%s\n\n--STDERR dump--\n\n%s" % (plaintext, errtext)) |
66 | 64 | ||
67 | msg['Subject'] = "[review-request] %s - smoke test results" % task_name | 65 | msg['Subject'] = "[review-request] %s - smoke test results" % task_name |
68 | msg['From'] = config.OWN_EMAIL_ADDRESS | 66 | msg['From'] = config.OWN_EMAIL_ADDRESS |
69 | msg['To'] = config.REPORT_EMAIL_ADDRESS | 67 | msg['To'] = config.REPORT_EMAIL_ADDRESS |
70 | 68 | ||
71 | s = smtplib.SMTP("localhost") | 69 | smtp_connection = smtplib.SMTP("localhost") |
72 | s.sendmail(config.OWN_EMAIL_ADDRESS, [config.REPORT_EMAIL_ADDRESS], msg.as_string()) | 70 | smtp_connection.sendmail(config.OWN_EMAIL_ADDRESS, [config.REPORT_EMAIL_ADDRESS], msg.as_string()) |
73 | s.quit() | 71 | smtp_connection.quit() |
74 | 72 | ||
75 | if __name__ == "__main__": | 73 | def main(): |
76 | # we don't do anything if we have another instance of us running | 74 | # we don't do anything if we have another instance of us running |
77 | lf = _take_lockfile() | 75 | lock_file = _take_lockfile() |
78 | 76 | ||
79 | if lf is None: | 77 | if lock_file is None: |
80 | if DEBUG: | 78 | if config.DEBUG: |
81 | print("Concurrent script in progress, exiting") | 79 | print("Concurrent script in progress, exiting") |
82 | sys.exit(1) | 80 | sys.exit(1) |
83 | 81 | ||
@@ -88,13 +86,16 @@ if __name__ == "__main__": | |||
88 | out = None | 86 | out = None |
89 | try: | 87 | try: |
90 | out = shellutils.run_shell_cmd("%s %s" % (os.path.join(os.path.dirname(__file__), "runner.py"), next_task)) | 88 | out = shellutils.run_shell_cmd("%s %s" % (os.path.join(os.path.dirname(__file__), "runner.py"), next_task)) |
91 | pass | 89 | except ShellCmdException as exc: |
92 | except ShellCmdException as e: | 90 | print("Failed while running the test runner: %s", exc) |
93 | print("Failed while running the test runner: %s", e) | 91 | errtext = exc.__str__() |
94 | errtext = e.__str__() | ||
95 | send_report(next_task, out, errtext) | 92 | send_report(next_task, out, errtext) |
96 | read_next_task_by_state(config.TASKS.INPROGRESS, next_task) | 93 | read_next_task_by_state(config.TASKS.INPROGRESS, next_task) |
97 | else: | 94 | else: |
98 | print("No task") | 95 | print("No task") |
99 | 96 | ||
100 | shellutils.unlockfile(lf) | 97 | shellutils.unlockfile(lock_file) |
98 | |||
99 | |||
100 | if __name__ == "__main__": | ||
101 | main() | ||