Trigger Jenkins job to accept submission.
.RE
+.PP
+\-e \-\-edit
+.RS 2
+Run editor to edit comment. Editor is taken from EDITOR environment variable.
+.RE
+
.\"
.\" The "reject" command description
.\"
Trigger Jenkins job to reject submission.
.RE
+.PP
+\-e \-\-edit
+.RS 2
+Run editor to edit comment. Editor is taken from EDITOR environment variable.
+.RE
+
.\"
.\" The "group" command description
.\"
Rebuild only one package.
.RE
+.PP
+\-e \-\-edit
+.RS 2
+Run editor to edit comment. Editor is taken from EDITOR environment variable.
+.RE
+
.\"
.\" The "lock" command description
.\"
Provide a comment with the explanation of a reason for lock. Mandatory option.
.RE
+.PP
+\-e \-\-edit
+.RS 2
+Run editor to edit comment. Editor is taken from EDITOR environment variable.
+.RE
+
.\"
.\" The "unlock" command description
.\"
Provide a comment with the explanation of a reason for unlock.
.RE
+.PP
+\-e \-\-edit
+.RS 2
+Run editor to edit comment. Editor is taken from EDITOR environment variable.
+.RE
.\"
.\" The "remove" command description
Provide a comment with the explanation of a reason for remove. This is mandatory option.
.RE
+.PP
+\-e \-\-edit
+.RS 2
+Run editor to edit comment. Editor is taken from EDITOR environment variable.
+.RE
+
.SH CONFIGURATION FILE
.RS 2
showtime = off
.RE
-
-
+.RS 2
+accept_comment = default comment
+ for accept
+ command
+.RE
+.RS 2
+reject_comment = default comment
+ for reject
+ command
+.RE
+.RS 2
+rebuild_comment = default comment
+ for rebuild
+ command
+.RE
+.RS 2
+lock_comment = default comment
+ for lock
+ command
+.RE
+.RS 2
+unlock_comment = default comment
+ for unlock
+ command
+.RE
+.RS 2
+remove_comment = default comment
+ for remove
+ command
+.RE
.RS 2
Mandatory options: apiurl, apiuser, apipasswd, jenkins_url, jenkins_user, jenkins_passwd and project
from repa.obs import OBS
from repa.main import sub_main
-from repa.common import accept_or_reject
+from repa.common import accept_or_reject, edit
class Accept(object):
help = description
@staticmethod
- def add_arguments(parser, _):
+ def add_arguments(parser, config):
"""Adds arguments to the parser. Called from [sub_]main."""
+
parser.add_argument('submission', help='submission or group')
- parser.add_argument('-c', '--comment', help='comment', default='')
+ parser.add_argument('-c', '--comment', help='comment',
+ default=config.get('accept_comment', ''))
parser.add_argument('-j', '--jenkins', action='store_true',
help='trigger Jenkins job')
+ parser.add_argument('-e', '--edit', action='store_true',
+ help='run editor to edit comment')
@staticmethod
def run(argv):
"""Command line entry point. Called from [sub_]main."""
+ if argv.edit:
+ argv.comment = edit(argv.comment)
+
obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd)
cred = None
import os
import time
import json
+import tempfile
+import subprocess
from functools import wraps, partial
+from distutils.spawn import find_executable
from repa.jenkins import trigger_build
return os.path.join(buildurl, 'project/show?project=home:prerelease:%s:%s'
% (meta['obs_target_prj'], name.replace('/', ':')))
+
+def edit(content):
+ """
+ Launch an editor to get input from user.
+ Returns: content of user input.
+ """
+ editor = os.getenv('EDITOR') or 'vi'
+
+ if not find_executable(editor):
+ raise RepaException("editor %s not found. Please set EDITOR "
+ "environment variable or install vi" % editor)
+
+ fds, path = tempfile.mkstemp('.tmp', 'repa-', text=True)
+ try:
+ if content:
+ os.write(fds, content)
+ os.close(fds)
+
+ try:
+ subprocess.call([editor, path])
+ except OSError as error:
+ raise RepaException("Can't run %s %s: %s" % (editor, path, error))
+
+ with open(path) as fobj:
+ result = fobj.read()
+ finally:
+ os.unlink(path)
+
+ return result
+
from repa.main import sub_main
from repa.jenkins import trigger_build
+from repa.common import edit
class Lock(object):
"""Subcommand: lock submissions."""
help = description
@staticmethod
- def add_arguments(parser, _):
+ def add_arguments(parser, config):
"""Adds arguments to the parser. Called from [sub_]main."""
parser.add_argument('submission', help='submission')
- parser.add_argument('-c', '--comment', help='comment', required=True)
+ parser.add_argument('-c', '--comment', help='comment',
+ default=config.get('lock_comment', ''))
+ parser.add_argument('-e', '--edit', action='store_true',
+ help='run editor to edit comment')
@staticmethod
def run(argv):
"""Command line entry point. Called from [sub_]main."""
+ if argv.edit:
+ argv.comment = edit(argv.comment)
job = 're'
cred = namedtuple('cred', ['url', 'username', 'password'])(\
argv.jenkins_url, argv.jenkins_user, argv.jenkins_passwd)
from repa.main import sub_main
from repa.jenkins import trigger_build
+from repa.common import edit
class Rebuild(object):
"""Subcommand: rebuild submissions."""
help = description
@staticmethod
- def add_arguments(parser, _):
+ def add_arguments(parser, config):
"""Adds arguments to the parser. Called from [sub_]main."""
parser.add_argument('submission', help='submission')
parser.add_argument('-p', '--package', help='package')
- parser.add_argument('-c', '--comment', help='comment', required=True)
+ parser.add_argument('-c', '--comment', help='comment',
+ default=config.get('rebuild_comment', ''))
+ parser.add_argument('-e', '--edit', action='store_true',
+ help='run editor to edit comment')
@staticmethod
def run(argv):
"""Command line entry point. Called from [sub_]main."""
+ if argv.edit:
+ argv.comment = edit(argv.comment)
job = 're'
cred = namedtuple('cred', ['url', 'username', 'password'])(\
argv.jenkins_url, argv.jenkins_user, argv.jenkins_passwd)
from repa.obs import OBS
from repa.main import sub_main
-from repa.common import accept_or_reject
+from repa.common import accept_or_reject, edit
class Reject(object):
help = description
@staticmethod
- def add_arguments(parser, _):
+ def add_arguments(parser, config):
"""Adds arguments to the parser. Called from [sub_]main."""
parser.add_argument('submission', help='submission or group')
- parser.add_argument('-c', '--comment', help='comment', default='')
+ parser.add_argument('-c', '--comment', help='comment',
+ default=config.get('reject_comment', ''))
parser.add_argument('-j', '--jenkins', action='store_true',
help='trigger Jenkins job')
+ parser.add_argument('-e', '--edit', action='store_true',
+ help='run editor to edit comment')
@staticmethod
def run(argv):
"""Command line entry point. Called from [sub_]main."""
+ if argv.edit:
+ argv.comment = edit(argv.comment)
+
obs = OBS(argv.apiurl, argv.apiuser, argv.apipasswd)
cred = None
from repa.main import sub_main
from repa.jenkins import trigger_build
+from repa.common import edit
class Remove(object):
"""Subcommand: remove submissions."""
help = description
@staticmethod
- def add_arguments(parser, _):
+ def add_arguments(parser, config):
"""Adds arguments to the parser. Called from [sub_]main."""
parser.add_argument('submission', help='submission')
- parser.add_argument('-c', '--comment', help='comment', required=True)
+ parser.add_argument('-c', '--comment', help='comment',
+ default=config.get('remove_comment', ''))
+ parser.add_argument('-e', '--edit', action='store_true',
+ help='run editor to edit comment')
@staticmethod
def run(argv):
"""Command line entry point. Called from [sub_]main."""
+ if argv.edit:
+ argv.comment = edit(argv.comment)
job = 're'
cred = namedtuple('cred', ['url', 'username', 'password'])(\
argv.jenkins_url, argv.jenkins_user, argv.jenkins_passwd)
from repa.main import sub_main
from repa.jenkins import trigger_build
+from repa.common import edit
class Unlock(object):
"""Subcommand: unlock submissions."""
help = description
@staticmethod
- def add_arguments(parser, _):
+ def add_arguments(parser, config):
"""Adds arguments to the parser. Called from [sub_]main."""
parser.add_argument('submission', help='submission')
- parser.add_argument('-c', '--comment', help='comment')
+ parser.add_argument('-c', '--comment', help='comment',
+ default=config.get('unlock_comment', ''))
+ parser.add_argument('-e', '--edit', action='store_true',
+ help='run editor to edit comment')
@staticmethod
def run(argv):
"""Command line entry point. Called from [sub_]main."""
+ if argv.edit:
+ argv.comment = edit(argv.comment)
job = 're'
cred = namedtuple('cred', ['url', 'username', 'password'])(\
argv.jenkins_url, argv.jenkins_user, argv.jenkins_passwd)