Commit 3c63a65d authored by Aaron Wells's avatar Aaron Wells

Revert "Replacing getopt with argparse"

This reverts commit 4743e238.

Never mind, argparse wasn't introduced until python 3.2, and
on hudrit we're still on python 2.6.5.
parent 4743e238
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from email.mime.text import MIMEText from email.mime.text import MIMEText
import argparse from getopt import getopt
import re import re
import smtplib import smtplib
import subprocess import subprocess
...@@ -157,15 +157,27 @@ def submit_to_cia(project, commit, branch, git_log): ...@@ -157,15 +157,27 @@ def submit_to_cia(project, commit, branch, git_log):
def main(): def main():
# https://gerrit.googlecode.com/svn/documentation/2.1.6/config-hooks.html#change-merged # https://gerrit.googlecode.com/svn/documentation/2.1.6/config-hooks.html#change-merged
parser = argparse.ArgumentParser() gerrit_args = ['change=', 'change-url=', 'project=', 'branch=', 'submitter=', 'commit=']
parser.add_argument('--change', required=True) args, unused = getopt(sys.argv[1:], '', gerrit_args)
parser.add_argument('--project', required=True)
parser.add_argument('--branch', require=True) change_url = project = branch = submitter = commit = None
parser.add_argument('--submitter', required=True) for argname, argv in args:
parser.add_argument('--commit', required=True) if argname == '--change-url':
args = parser.parse_known_args() change_url = argv
elif argname == '--project':
send_notifications(args.change_url, args.project, args.branch, args.submitter, args.commit) project = argv
elif argname == '--branch':
branch = argv
elif argname == '--submitter':
submitter = argv
elif argname == '--commit':
commit = argv
if change_url and project and branch and submitter and commit:
send_notifications(change_url, project, branch, submitter, commit)
else:
print 'Missing arguments'
return 1
return 0; return 0;
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from email.mime.text import MIMEText from email.mime.text import MIMEText
import argparse from getopt import getopt
import re import re
import smtplib import smtplib
import subprocess import subprocess
...@@ -72,19 +72,47 @@ def send_bug_mail(bug_number, change_url, project, commit, uploader, branch, git ...@@ -72,19 +72,47 @@ def send_bug_mail(bug_number, change_url, project, commit, uploader, branch, git
def main(): def main():
# See https://git.eclipse.org/r/Documentation/config-hooks.html#_patchset_created # See https://git.eclipse.org/r/Documentation/config-hooks.html#_patchset_created
parser = argparse.ArgumentParser() gerrit_args = ['change=', 'is-draft=', 'change-url=', 'project=', 'branch=', 'topic=', 'uploader=', 'commit=', 'patchset=']
parser.add_argument('--change_url', required=True) args, unused = getopt(sys.argv[1:], '', gerrit_args)
parser.add_argument('--project', required=True)
parser.add_argument('--branch', required=True) change_url = project = branch = uploader = commit = None
parser.add_argument('--uploader', required=True) for argname, argv in args:
parser.add_argument('--commit', required=True) if argname == '--change-url':
parser.add_argument('--is-draft', required=True) change_url = argv
parser.add_argument('--patchset', required=True) elif argname == '--project':
args = parser.parse_known_args() project = argv
elif argname == '--branch':
# Comment on Launchpad only on first patchset for each change, and no notification for drafts. branch = argv
if args.is_draft != 'true' and args.patchset == '1': elif argname == '--uploader':
send_notifications(args.change_url, args.project, args.branch, args.uploader, args.commit) uploader = argv
elif argname == '--commit':
commit = argv
elif argname == '--is-draft':
is_draft = argv
elif argname == '--patchset':
patchset = argv
if change_url and project and branch and uploader and commit and patchset and is_draft:
# Comment on Launchpad only on first patchset for each change, and no notification for drafts.
if is_draft != 'true' and patchset == '1':
send_notifications(change_url, project, branch, uploader, commit)
else:
print 'Missing arguments: '
if not change_url:
print 'change_url '
if not project:
print 'project '
if not branch:
print 'branch '
if not uploader:
print 'uploader '
if not commit:
print 'commit '
if not patchset:
print 'patchset '
if not is_draft:
print 'is_draft '
return 1
return 0; return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment