summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/contrib/tts/recv.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/contrib/tts/recv.py')
-rwxr-xr-xbitbake/lib/toaster/contrib/tts/recv.py51
1 files changed, 51 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/contrib/tts/recv.py b/bitbake/lib/toaster/contrib/tts/recv.py
new file mode 100755
index 0000000000..168294acab
--- /dev/null
+++ b/bitbake/lib/toaster/contrib/tts/recv.py
@@ -0,0 +1,51 @@
1#!/usr/bin/python
2
3# ex:ts=4:sw=4:sts=4:et
4# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
5#
6# Copyright (C) 2015 Alexandru Damian for Intel Corp.
7#
8# This program is free software; you can redistribute it and/or modify
9# it under the terms of the GNU General Public License version 2 as
10# published by the Free Software Foundation.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21# Program to receive review requests by email and log tasks to backlog.txt
22# Designed to be run by the email system from a .forward file:
23#
24# cat .forward
25# |[full/path]/recv.py
26
27from __future__ import print_function
28import sys, os, config, shellutils
29from shellutils import ShellCmdException
30
31from email.parser import Parser
32
33def recv_mail(datastring):
34 headers = Parser().parsestr(datastring)
35 return headers['subject']
36
37
38if __name__ == "__main__":
39 lf = shellutils.lockfile(shellutils.mk_lock_filename(), retry = True)
40
41 subject = recv_mail(sys.stdin.read())
42
43 subject_parts = subject.split()
44 if "[review-request]" in subject_parts:
45 task_name = subject_parts[subject_parts.index("[review-request]") + 1]
46 with open(os.path.join(os.path.dirname(__file__), config.BACKLOGFILE), "a") as fout:
47 line = "%s|%s\n" % (task_name, config.TASKS.PENDING)
48 fout.write(line)
49
50 shellutils.unlockfile(lf)
51