[MediaWiki-commits] [Gerrit] labs/toollabs[master]: Package jmail

2017-02-27 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/339920 )

Change subject: Package jmail
..


Package jmail

Bug: T158722
Change-Id: I2a2a86ecf1f0129374733f9222decf241d13e708
---
M configure.ac
M debian/changelog
M debian/control
M debian/copyright
M debian/jobutils.install
M debian/jobutils.manpages
M jobutils/bin/Makefile.am
A jobutils/bin/jmail
M jobutils/man/Makefile.am
A jobutils/man/jmail.1.in
M tox.ini
11 files changed, 124 insertions(+), 7 deletions(-)

Approvals:
  Tim Landscheidt: Looks good to me, approved
  BryanDavis: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/configure.ac b/configure.ac
index 5a3b7d5..bc7795b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@
  jobutils/Makefile
  jobutils/bin/Makefile
  jobutils/man/Makefile
+ jobutils/man/jmail.1
  jobutils/man/job.1
  jobutils/man/jstop.1
  jobutils/man/jsub.1
diff --git a/debian/changelog b/debian/changelog
index 0d8b543..e03cda4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+toollabs (1.20~dev) trusty; urgency=medium
+
+  * Package jmail
+
+ -- Tim Landscheidt   Mon, 27 Feb 2017 17:50:41 +
+
 toollabs (1.19) trusty; urgency=medium
 
   * Remove toolwatcher
diff --git a/debian/control b/debian/control
index 3c9c82c..bb7aeb6 100644
--- a/debian/control
+++ b/debian/control
@@ -22,7 +22,8 @@
 Package: jobutils
 Architecture: all
 Depends: ${misc:Depends}, ${perl:Depends}, ${python:Depends},
- gridengine-client, libipc-run-perl, libstring-shellquote-perl, python
+ gridengine-client, libipc-run-perl, libstring-shellquote-perl,
+ python, python3
 Description: Set of utilities to use on wikimedia bots and tools cluster
  This package will install jstart (jsub) and jstop, the Tool Labs (more)
  user-friendly wrappers to submit jobs to the gridengine
diff --git a/debian/copyright b/debian/copyright
index f3d9372..f545288 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -5,6 +5,10 @@
 Copyright: 2013 Marc-André Pelletier 
 License: ISC
 
+Files: jobutils/bin/jmail jobutils/man/jmail.1.in
+Copyright: Copyright 2017 Tim Landscheidt 
+License: GPL-3.0+
+
 Files: debian/*
 Copyright: 2013 Carl Fürstenberg 
 License: GPL-3.0+
diff --git a/debian/jobutils.install b/debian/jobutils.install
index 3b8bf2f..956f91f 100644
--- a/debian/jobutils.install
+++ b/debian/jobutils.install
@@ -1,3 +1,4 @@
+usr/bin/jmail
 usr/bin/job
 usr/bin/jstart
 usr/bin/jstop
diff --git a/debian/jobutils.manpages b/debian/jobutils.manpages
index 92a5a84..c6a457c 100644
--- a/debian/jobutils.manpages
+++ b/debian/jobutils.manpages
@@ -1,3 +1,4 @@
+debian/tmp/usr/share/man/man1/jmail.1
 debian/tmp/usr/share/man/man1/job.1
 debian/tmp/usr/share/man/man1/jstop.1
 debian/tmp/usr/share/man/man1/jsub.1
diff --git a/jobutils/bin/Makefile.am b/jobutils/bin/Makefile.am
index 764fc98..7312c92 100644
--- a/jobutils/bin/Makefile.am
+++ b/jobutils/bin/Makefile.am
@@ -1,4 +1,4 @@
-bin_SCRIPTS = job jstop jsub
+bin_SCRIPTS = jmail job jstop jsub
 
 install-exec-hook:
cd $(DESTDIR)$(bindir) && \
diff --git a/jobutils/bin/jmail b/jobutils/bin/jmail
new file mode 100755
index 000..d996f68
--- /dev/null
+++ b/jobutils/bin/jmail
@@ -0,0 +1,61 @@
+#!/usr/bin/python3
+#
+# Copyright (C) 2017  Tim Landscheidt
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+import os
+import pwd
+import shutil
+import subprocess
+import sys
+import tempfile
+
+# Both temporary files need to be created in the tool's home directory
+# on NFS so they can be accessed from any grid host.
+home_directory = pwd.getpwuid(os.getuid()).pw_dir
+with tempfile.NamedTemporaryFile(mode='w+',
+ suffix='.in',
+ prefix='jmail-',
+ dir=home_directory) as input, \
+ tempfile.NamedTemporaryFile(mode='w+',
+ suffix='.out',
+ prefix='jmail-',
+ dir=home_directory) as output:
+# Determine the full path of the program to execute.
+program = shutil.which(sys.argv[1])
+if program is None:
+sys.exit('Processing program unava

[MediaWiki-commits] [Gerrit] labs/toollabs[master]: Package jmail

2017-02-25 Thread Tim Landscheidt (Code Review)
Tim Landscheidt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/339920 )

Change subject: Package jmail
..

Package jmail

Bug: T158722
Change-Id: I2a2a86ecf1f0129374733f9222decf241d13e708
---
M configure.ac
M debian/changelog
M debian/copyright
M debian/jobutils.install
M debian/jobutils.manpages
M jobutils/bin/Makefile.am
A jobutils/bin/jmail
M jobutils/man/Makefile.am
A jobutils/man/jmail.1.in
9 files changed, 103 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/labs/toollabs 
refs/changes/20/339920/1

diff --git a/configure.ac b/configure.ac
index 1cc660e..0f72408 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@
  jobutils/Makefile
  jobutils/bin/Makefile
  jobutils/man/Makefile
+ jobutils/man/jmail.1
  jobutils/man/job.1
  jobutils/man/jstop.1
  jobutils/man/jsub.1
diff --git a/debian/changelog b/debian/changelog
index 8ed41f5..0bc809e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,8 +4,9 @@
   * Do not hardcore database hosts in list-user-databases
   * State dependency on python
   * Set target distribution to Ubuntu Trusty
+  * Package jmail
 
- -- Tim Landscheidt   Sun, 26 Feb 2017 01:38:04 +
+ -- Tim Landscheidt   Sun, 26 Feb 2017 05:42:05 +
 
 toollabs (1.18) unstable; urgency=medium
 
diff --git a/debian/copyright b/debian/copyright
index f3d9372..f545288 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -5,6 +5,10 @@
 Copyright: 2013 Marc-André Pelletier 
 License: ISC
 
+Files: jobutils/bin/jmail jobutils/man/jmail.1.in
+Copyright: Copyright 2017 Tim Landscheidt 
+License: GPL-3.0+
+
 Files: debian/*
 Copyright: 2013 Carl Fürstenberg 
 License: GPL-3.0+
diff --git a/debian/jobutils.install b/debian/jobutils.install
index 3b8bf2f..956f91f 100644
--- a/debian/jobutils.install
+++ b/debian/jobutils.install
@@ -1,3 +1,4 @@
+usr/bin/jmail
 usr/bin/job
 usr/bin/jstart
 usr/bin/jstop
diff --git a/debian/jobutils.manpages b/debian/jobutils.manpages
index 92a5a84..c6a457c 100644
--- a/debian/jobutils.manpages
+++ b/debian/jobutils.manpages
@@ -1,3 +1,4 @@
+debian/tmp/usr/share/man/man1/jmail.1
 debian/tmp/usr/share/man/man1/job.1
 debian/tmp/usr/share/man/man1/jstop.1
 debian/tmp/usr/share/man/man1/jsub.1
diff --git a/jobutils/bin/Makefile.am b/jobutils/bin/Makefile.am
index 764fc98..7312c92 100644
--- a/jobutils/bin/Makefile.am
+++ b/jobutils/bin/Makefile.am
@@ -1,4 +1,4 @@
-bin_SCRIPTS = job jstop jsub
+bin_SCRIPTS = jmail job jstop jsub
 
 install-exec-hook:
cd $(DESTDIR)$(bindir) && \
diff --git a/jobutils/bin/jmail b/jobutils/bin/jmail
new file mode 100755
index 000..3c2793d
--- /dev/null
+++ b/jobutils/bin/jmail
@@ -0,0 +1,54 @@
+#!/usr/bin/python3
+#
+# Copyright (C) 2017  Tim Landscheidt
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see .
+
+import os
+import pwd
+import shutil
+import subprocess
+import sys
+import tempfile
+
+# Both temporary files need to be created in the tool's home directory
+# on NFS so they can be accessed from any grid host.
+home_directory = pwd.getpwuid(os.getuid()).pw_dir
+with tempfile.NamedTemporaryFile(mode='w+', suffix='.in', prefix='jmail-', 
dir=home_directory) as input, tempfile.NamedTemporaryFile(mode='w+', 
suffix='.out', prefix='jmail-', dir=home_directory) as output:
+# Determine the full path of the program to execute.
+program = shutil.which(sys.argv[1])
+if program is None:
+sys.exit('Processing program unavailable')
+
+# Copy the incoming message from stdin to the temporary file.
+shutil.copyfileobj(sys.stdin, input)
+input.flush()
+
+# Execute the given program synchronously on the grid.
+rv = subprocess.call(['/usr/bin/qsub',
+  '-N', 'mail.' + pwd.getpwuid(os.getuid()).pw_name,
+  '-sync', 'y',
+  '-b', 'y',
+  '-m', 'n',
+  '-o', output.name,
+  '-j', 'y',
+  '-i', input.name,
+  '-q', 'mailq',
+  '-l', 'h_vmem=500M',
+  '-r', 'n', program] + sys.argv[2:],
+ stdout=subprocess.DEVNULL)