cleanup after automatic split
This commit is contained in:
parent
81b2b36d07
commit
37bcef025c
3 changed files with 162 additions and 135 deletions
94
cli/koji
94
cli/koji
|
|
@ -27,96 +27,18 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
import sys
|
import sys
|
||||||
from six.moves import range
|
|
||||||
from six.moves import zip
|
|
||||||
import six
|
import six
|
||||||
from six.moves import filter
|
|
||||||
from six.moves import map
|
|
||||||
try:
|
|
||||||
import krbV
|
|
||||||
except ImportError: # pragma: no cover
|
|
||||||
krbV = None
|
|
||||||
try:
|
|
||||||
import ast
|
|
||||||
except ImportError: # pragma: no cover
|
|
||||||
ast = None
|
|
||||||
try:
|
|
||||||
import json
|
|
||||||
except ImportError: # pragma: no cover
|
|
||||||
try:
|
|
||||||
import simplejson as json
|
|
||||||
except ImportError:
|
|
||||||
json = None
|
|
||||||
import six.moves.configparser
|
import six.moves.configparser
|
||||||
import base64
|
|
||||||
import dateutil.parser
|
|
||||||
import errno
|
|
||||||
import koji
|
import koji
|
||||||
import koji.util
|
import koji.util
|
||||||
import fnmatch
|
|
||||||
from koji.util import md5_constructor
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import pprint
|
|
||||||
import pycurl
|
|
||||||
import random
|
|
||||||
import socket
|
|
||||||
import stat
|
|
||||||
import string
|
|
||||||
import time
|
|
||||||
import traceback
|
|
||||||
import six.moves.xmlrpc_client
|
import six.moves.xmlrpc_client
|
||||||
try:
|
|
||||||
import libcomps
|
|
||||||
except ImportError: # pragma: no cover
|
|
||||||
libcomps = None
|
|
||||||
try:
|
|
||||||
import yum.comps as yumcomps
|
|
||||||
except ImportError:
|
|
||||||
yumcomps = None
|
|
||||||
import optparse
|
import optparse
|
||||||
|
|
||||||
|
from koji_cli.lib import _, OptionParser, get_epilog_str, greetings, \
|
||||||
# fix OptionParser for python 2.3 (optparse verion 1.4.1+)
|
warn, categories
|
||||||
# code taken from optparse version 1.5a2
|
|
||||||
OptionParser = optparse.OptionParser
|
|
||||||
if optparse.__version__ == "1.4.1+": # pragma: no cover
|
|
||||||
def _op_error(self, msg):
|
|
||||||
self.print_usage(sys.stderr)
|
|
||||||
msg = "%s: error: %s\n" % (self._get_prog_name(), msg)
|
|
||||||
if msg:
|
|
||||||
sys.stderr.write(msg)
|
|
||||||
sys.exit(2)
|
|
||||||
OptionParser.error = _op_error
|
|
||||||
|
|
||||||
greetings = ('hello', 'hi', 'yo', "what's up", "g'day", 'back to work',
|
|
||||||
'bonjour',
|
|
||||||
'hallo',
|
|
||||||
'ciao',
|
|
||||||
'hola',
|
|
||||||
u'olá',
|
|
||||||
u'dobrý den',
|
|
||||||
u'zdravstvuite',
|
|
||||||
u'góðan daginn',
|
|
||||||
'hej',
|
|
||||||
'tervehdys',
|
|
||||||
u'grüezi',
|
|
||||||
u'céad míle fáilte',
|
|
||||||
u'hylô',
|
|
||||||
u'bună ziua',
|
|
||||||
u'jó napot',
|
|
||||||
'dobre dan',
|
|
||||||
u'你好',
|
|
||||||
u'こんにちは',
|
|
||||||
u'नमस्कार',
|
|
||||||
u'안녕하세요')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ARGMAP = {'None': None,
|
|
||||||
'True': True,
|
|
||||||
'False': False}
|
|
||||||
|
|
||||||
|
|
||||||
def get_options():
|
def get_options():
|
||||||
|
|
@ -240,18 +162,6 @@ def get_options():
|
||||||
return options, cmd, args[1:]
|
return options, cmd, args[1:]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def handle_help(options, session, args):
|
def handle_help(options, session, args):
|
||||||
"[info] List available commands"
|
"[info] List available commands"
|
||||||
usage = _("usage: %prog help <category> ...")
|
usage = _("usage: %prog help <category> ...")
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,46 @@
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
import ast
|
||||||
|
import base64
|
||||||
|
import dateutil.parser
|
||||||
|
import fnmatch
|
||||||
|
import json
|
||||||
|
import logging
|
||||||
|
import optparse
|
||||||
|
import os
|
||||||
|
import pprint
|
||||||
|
import pycurl
|
||||||
|
import random
|
||||||
|
import re
|
||||||
|
import six
|
||||||
|
import stat
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
|
|
||||||
|
import six.moves.xmlrpc_client
|
||||||
|
from six.moves import filter
|
||||||
|
from six.moves import map
|
||||||
|
from six.moves import zip
|
||||||
|
|
||||||
|
try:
|
||||||
|
import libcomps
|
||||||
|
except ImportError: # pragma: no cover
|
||||||
|
libcomps = None
|
||||||
|
try:
|
||||||
|
import yum.comps as yumcomps
|
||||||
|
except ImportError:
|
||||||
|
yumcomps = None
|
||||||
|
|
||||||
|
import koji
|
||||||
|
from koji.util import md5_constructor
|
||||||
|
from koji_cli.lib import _, OptionParser, activate_session, parse_arches, \
|
||||||
|
_unique_path, _running_in_bg, _progress_callback, watch_tasks, \
|
||||||
|
arg_filter, linked_upload, list_task_output_all_volumes, \
|
||||||
|
print_task_headers, print_task_recurse, _format_size, watch_logs, \
|
||||||
|
error, greetings
|
||||||
|
|
||||||
|
|
||||||
def _printable_unicode(s):
|
def _printable_unicode(s):
|
||||||
if six.PY2:
|
if six.PY2:
|
||||||
return s.encode('utf-8')
|
return s.encode('utf-8')
|
||||||
|
|
@ -410,7 +453,8 @@ def handle_build(options, session, args):
|
||||||
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
||||||
if build_opts.wait or (build_opts.wait is None and not _running_in_bg()):
|
if build_opts.wait or (build_opts.wait is None and not _running_in_bg()):
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=build_opts.quiet)
|
return watch_tasks(session, [task_id], quiet=build_opts.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -487,7 +531,8 @@ def handle_chain_build(options, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=build_opts.quiet)
|
return watch_tasks(session, [task_id], quiet=build_opts.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
|
|
||||||
def handle_maven_build(options, session, args):
|
def handle_maven_build(options, session, args):
|
||||||
"[build] Build a Maven package from source"
|
"[build] Build a Maven package from source"
|
||||||
|
|
@ -585,7 +630,8 @@ def handle_maven_build(options, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=build_opts.quiet)
|
return watch_tasks(session, [task_id], quiet=build_opts.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
|
|
||||||
def handle_wrapper_rpm(options, session, args):
|
def handle_wrapper_rpm(options, session, args):
|
||||||
"""[build] Build wrapper rpms for any archives associated with a build."""
|
"""[build] Build wrapper rpms for any archives associated with a build."""
|
||||||
|
|
@ -651,7 +697,8 @@ def handle_wrapper_rpm(options, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session,[task_id],quiet=options.quiet)
|
return watch_tasks(session, [task_id], quiet=options.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
|
|
||||||
def handle_maven_chain(options, session, args):
|
def handle_maven_chain(options, session, args):
|
||||||
"[build] Run a set of Maven builds in dependency order"
|
"[build] Run a set of Maven builds in dependency order"
|
||||||
|
|
@ -703,9 +750,10 @@ def handle_maven_chain(options, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=options.quiet)
|
return watch_tasks(session, [task_id], quiet=options.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
|
|
||||||
def handle_resubmit(options, session, args):
|
def handle_resubmit(global_options, session, args):
|
||||||
"""[build] Retry a canceled or failed task, using the same parameter as the original task."""
|
"""[build] Retry a canceled or failed task, using the same parameter as the original task."""
|
||||||
usage = _("usage: %prog resubmit [options] taskID")
|
usage = _("usage: %prog resubmit [options] taskID")
|
||||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||||
|
|
@ -722,7 +770,7 @@ def handle_resubmit(options, session, args):
|
||||||
taskID = int(args[0])
|
taskID = int(args[0])
|
||||||
if not options.quiet:
|
if not options.quiet:
|
||||||
print("Resubmitting the following task:")
|
print("Resubmitting the following task:")
|
||||||
_printTaskInfo(session, taskID, 0, False, True)
|
_printTaskInfo(session, taskID, 0, global_options.topdir, False, True)
|
||||||
newID = session.resubmitTask(taskID)
|
newID = session.resubmitTask(taskID)
|
||||||
if not options.quiet:
|
if not options.quiet:
|
||||||
print("Resubmitted task %s as new task %s" % (taskID, newID))
|
print("Resubmitted task %s as new task %s" % (taskID, newID))
|
||||||
|
|
@ -730,7 +778,8 @@ def handle_resubmit(options, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [newID], quiet=options.quiet)
|
return watch_tasks(session, [newID], quiet=options.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
|
|
||||||
def handle_call(options, session, args):
|
def handle_call(options, session, args):
|
||||||
"Execute an arbitrary XML-RPC call"
|
"Execute an arbitrary XML-RPC call"
|
||||||
|
|
@ -963,7 +1012,8 @@ def handle_restart_hosts(options, session, args):
|
||||||
task_id = session.restartHosts()
|
task_id = session.restartHosts()
|
||||||
if my_opts.wait or (my_opts.wait is None and not _running_in_bg()):
|
if my_opts.wait or (my_opts.wait is None and not _running_in_bg()):
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=my_opts.quiet)
|
return watch_tasks(session, [task_id], quiet=my_opts.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
def handle_import(options, session, args):
|
def handle_import(options, session, args):
|
||||||
|
|
@ -2551,14 +2601,14 @@ def handle_unblock_group_req(options, session, args):
|
||||||
activate_session(session)
|
activate_session(session)
|
||||||
session.groupReqListUnblock(tag, group, req)
|
session.groupReqListUnblock(tag, group, req)
|
||||||
|
|
||||||
def anon_handle_list_channels(options, session, args):
|
def anon_handle_list_channels(goptions, session, args):
|
||||||
"[info] Print channels listing"
|
"[info] Print channels listing"
|
||||||
usage = _("usage: %prog list-channels")
|
usage = _("usage: %prog list-channels")
|
||||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||||
parser = OptionParser(usage=usage)
|
parser = OptionParser(usage=usage)
|
||||||
parser.add_option("--quiet", action="store_true", help=_("Do not print header information"), default=options.quiet)
|
parser.add_option("--quiet", action="store_true", help=_("Do not print header information"), default=goptions.quiet)
|
||||||
(options, args) = parser.parse_args(args)
|
(options, args) = parser.parse_args(args)
|
||||||
activate_session(session)
|
activate_session(session, goptions)
|
||||||
channels = session.listChannels()
|
channels = session.listChannels()
|
||||||
session.multicall = True
|
session.multicall = True
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
|
|
@ -3993,17 +4043,18 @@ def _handleOpts(lines, opts, prefix=''):
|
||||||
_handleMap(lines, opts, prefix)
|
_handleMap(lines, opts, prefix)
|
||||||
|
|
||||||
|
|
||||||
def _parseTaskParams(session, method, task_id):
|
def _parseTaskParams(session, method, task_id, topdir):
|
||||||
try:
|
try:
|
||||||
return _do_parseTaskParams(session, method, task_id)
|
return _do_parseTaskParams(session, method, task_id, topdir)
|
||||||
except Exception:
|
except Exception:
|
||||||
|
logger = logging.getLogger("koji")
|
||||||
if logger.isEnabledFor(logging.DEBUG):
|
if logger.isEnabledFor(logging.DEBUG):
|
||||||
tb_str = ''.join(traceback.format_exception(*sys.exc_info()))
|
tb_str = ''.join(traceback.format_exception(*sys.exc_info()))
|
||||||
logger.debug(tb_str)
|
logger.debug(tb_str)
|
||||||
return ['Unable to parse task parameters']
|
return ['Unable to parse task parameters']
|
||||||
|
|
||||||
|
|
||||||
def _do_parseTaskParams(session, method, task_id):
|
def _do_parseTaskParams(session, method, task_id, topdir):
|
||||||
"""Parse the return of getTaskRequest()"""
|
"""Parse the return of getTaskRequest()"""
|
||||||
params = session.getTaskRequest(task_id)
|
params = session.getTaskRequest(task_id)
|
||||||
|
|
||||||
|
|
@ -4014,7 +4065,7 @@ def _do_parseTaskParams(session, method, task_id):
|
||||||
elif method == 'buildSRPMFromSCM':
|
elif method == 'buildSRPMFromSCM':
|
||||||
lines.append("SCM URL: %s" % params[0])
|
lines.append("SCM URL: %s" % params[0])
|
||||||
elif method == 'buildArch':
|
elif method == 'buildArch':
|
||||||
lines.append("SRPM: %s/work/%s" % (options.topdir, params[0]))
|
lines.append("SRPM: %s/work/%s" % (topdir, params[0]))
|
||||||
lines.append("Build Tag: %s" % session.getTag(params[1])['name'])
|
lines.append("Build Tag: %s" % session.getTag(params[1])['name'])
|
||||||
lines.append("Build Arch: %s" % params[2])
|
lines.append("Build Arch: %s" % params[2])
|
||||||
lines.append("SRPM Kept: %r" % params[3])
|
lines.append("SRPM Kept: %r" % params[3])
|
||||||
|
|
@ -4151,7 +4202,7 @@ def _do_parseTaskParams(session, method, task_id):
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
def _printTaskInfo(session, task_id, level=0, recurse=True, verbose=True):
|
def _printTaskInfo(session, task_id, topdir, level=0, recurse=True, verbose=True):
|
||||||
"""Recursive function to print information about a task
|
"""Recursive function to print information about a task
|
||||||
and its children."""
|
and its children."""
|
||||||
|
|
||||||
|
|
@ -4189,7 +4240,7 @@ def _printTaskInfo(session, task_id, level=0, recurse=True, verbose=True):
|
||||||
print("%sType: %s" % (indent, info['method']))
|
print("%sType: %s" % (indent, info['method']))
|
||||||
if verbose:
|
if verbose:
|
||||||
print("%sRequest Parameters:" % indent)
|
print("%sRequest Parameters:" % indent)
|
||||||
for line in _parseTaskParams(session, info['method'], task_id):
|
for line in _parseTaskParams(session, info['method'], task_id, topdir):
|
||||||
print("%s %s" % (indent, line))
|
print("%s %s" % (indent, line))
|
||||||
print("%sOwner: %s" % (indent, owner))
|
print("%sOwner: %s" % (indent, owner))
|
||||||
print("%sState: %s" % (indent, koji.TASK_STATES[info['state']].lower()))
|
print("%sState: %s" % (indent, koji.TASK_STATES[info['state']].lower()))
|
||||||
|
|
@ -4223,9 +4274,9 @@ def _printTaskInfo(session, task_id, level=0, recurse=True, verbose=True):
|
||||||
children = session.getTaskChildren(task_id, request=True)
|
children = session.getTaskChildren(task_id, request=True)
|
||||||
children.sort(cmp=lambda a, b: cmp(a['id'], b['id']))
|
children.sort(cmp=lambda a, b: cmp(a['id'], b['id']))
|
||||||
for child in children:
|
for child in children:
|
||||||
_printTaskInfo(session, child['id'], level, verbose=verbose)
|
_printTaskInfo(session, child['id'], topdir, level, verbose=verbose)
|
||||||
|
|
||||||
def anon_handle_taskinfo(options, session, args):
|
def anon_handle_taskinfo(global_options, session, args):
|
||||||
"""[info] Show information about a task"""
|
"""[info] Show information about a task"""
|
||||||
usage = _("usage: %prog taskinfo [options] taskID [taskID...]")
|
usage = _("usage: %prog taskinfo [options] taskID [taskID...]")
|
||||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||||
|
|
@ -4241,7 +4292,7 @@ def anon_handle_taskinfo(options, session, args):
|
||||||
|
|
||||||
for arg in args:
|
for arg in args:
|
||||||
task_id = int(arg)
|
task_id = int(arg)
|
||||||
_printTaskInfo(session, task_id, 0, options.recurse, options.verbose)
|
_printTaskInfo(session, task_id, options.topdir, 0, options.recurse, options.verbose)
|
||||||
|
|
||||||
def anon_handle_taginfo(options, session, args):
|
def anon_handle_taginfo(options, session, args):
|
||||||
"[info] Print basic information about a tag"
|
"[info] Print basic information about a tag"
|
||||||
|
|
@ -5444,7 +5495,8 @@ def _build_image(options, task_opts, session, args, img_type):
|
||||||
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
||||||
if task_opts.wait or (task_opts.wait is None and not _running_in_bg()):
|
if task_opts.wait or (task_opts.wait is None and not _running_in_bg()):
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=options.quiet)
|
return watch_tasks(session, [task_id], quiet=options.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -5513,7 +5565,8 @@ def _build_image_oz(options, task_opts, session, args):
|
||||||
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
||||||
if task_opts.wait or (task_opts.wait is None and not _running_in_bg()):
|
if task_opts.wait or (task_opts.wait is None and not _running_in_bg()):
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=options.quiet)
|
return watch_tasks(session, [task_id], quiet=options.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -5590,7 +5643,8 @@ def handle_win_build(options, session, args):
|
||||||
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
||||||
if build_opts.wait or (build_opts.wait is None and not _running_in_bg()):
|
if build_opts.wait or (build_opts.wait is None and not _running_in_bg()):
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=build_opts.quiet)
|
return watch_tasks(session, [task_id], quiet=build_opts.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
@ -5851,7 +5905,7 @@ def handle_set_pkg_owner_global(options, session, args):
|
||||||
% (entry['package_name'], entry['tag_name'], entry['owner_name'], user['name']))
|
% (entry['package_name'], entry['tag_name'], entry['owner_name'], user['name']))
|
||||||
session.packageListSetOwner(entry['tag_id'], entry['package_name'], user['id'])
|
session.packageListSetOwner(entry['tag_id'], entry['package_name'], user['id'])
|
||||||
|
|
||||||
def anon_handle_watch_task(options, session, args):
|
def anon_handle_watch_task(global_options, session, args):
|
||||||
"[monitor] Track progress of particular tasks"
|
"[monitor] Track progress of particular tasks"
|
||||||
usage = _("usage: %prog watch-task [options] <task id> [<task id>...]")
|
usage = _("usage: %prog watch-task [options] <task id> [<task id>...]")
|
||||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||||
|
|
@ -5890,9 +5944,10 @@ def anon_handle_watch_task(options, session, args):
|
||||||
if not tasks:
|
if not tasks:
|
||||||
parser.error(_("at least one task id must be specified"))
|
parser.error(_("at least one task id must be specified"))
|
||||||
|
|
||||||
return watch_tasks(session, tasks, quiet=options.quiet)
|
return watch_tasks(session, tasks, quiet=options.quiet,
|
||||||
|
poll_interval=global_options.poll_interval)
|
||||||
|
|
||||||
def anon_handle_watch_logs(options, session, args):
|
def anon_handle_watch_logs(global_options, session, args):
|
||||||
"[monitor] Watch logs in realtime"
|
"[monitor] Watch logs in realtime"
|
||||||
usage = _("usage: %prog watch-logs [options] <task id> [<task id>...]")
|
usage = _("usage: %prog watch-logs [options] <task id> [<task id>...]")
|
||||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||||
|
|
@ -5910,7 +5965,7 @@ def anon_handle_watch_logs(options, session, args):
|
||||||
if not tasks:
|
if not tasks:
|
||||||
parser.error(_("at least one task id must be specified"))
|
parser.error(_("at least one task id must be specified"))
|
||||||
|
|
||||||
watch_logs(session, tasks, options)
|
watch_logs(session, tasks, options, global_options.poll_interval)
|
||||||
|
|
||||||
def handle_make_task(opts, session, args):
|
def handle_make_task(opts, session, args):
|
||||||
"[admin] Create an arbitrary task"
|
"[admin] Create an arbitrary task"
|
||||||
|
|
@ -5937,7 +5992,8 @@ def handle_make_task(opts, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=opts.quiet)
|
return watch_tasks(session, [task_id], quiet=opts.quiet,
|
||||||
|
poll_interval=opts.poll_interval)
|
||||||
|
|
||||||
def handle_tag_build(opts, session, args):
|
def handle_tag_build(opts, session, args):
|
||||||
"[bind] Apply a tag to one or more builds"
|
"[bind] Apply a tag to one or more builds"
|
||||||
|
|
@ -5961,7 +6017,8 @@ def handle_tag_build(opts, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session,tasks,quiet=opts.quiet)
|
return watch_tasks(session, tasks, quiet=opts.quiet,
|
||||||
|
poll_interval=opts.poll_interval)
|
||||||
|
|
||||||
def handle_move_build(opts, session, args):
|
def handle_move_build(opts, session, args):
|
||||||
"[bind] 'Move' one or more builds between tags"
|
"[bind] 'Move' one or more builds between tags"
|
||||||
|
|
@ -6007,7 +6064,8 @@ def handle_move_build(opts, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, tasks, quiet=opts.quiet)
|
return watch_tasks(session, tasks, quiet=opts.quiet,
|
||||||
|
poll_interval=opts.poll_interval)
|
||||||
|
|
||||||
def handle_untag_build(options, session, args):
|
def handle_untag_build(options, session, args):
|
||||||
"[bind] Remove a tag from one or more builds"
|
"[bind] Remove a tag from one or more builds"
|
||||||
|
|
@ -6275,7 +6333,7 @@ def anon_handle_download_logs(options, session, args):
|
||||||
# with current code, failed task results should always be faults,
|
# with current code, failed task results should always be faults,
|
||||||
# but that could change in the future
|
# but that could change in the future
|
||||||
content = pprint.pformat(result)
|
content = pprint.pformat(result)
|
||||||
except (xmlrpclib.Fault, koji.GenericError):
|
except (six.moves.xmlrpc_client.Fault, koji.GenericError):
|
||||||
etype, e = sys.exc_info()[:2]
|
etype, e = sys.exc_info()[:2]
|
||||||
content = ''.join(traceback.format_exception_only(etype, e))
|
content = ''.join(traceback.format_exception_only(etype, e))
|
||||||
full_filename = os.path.normpath(os.path.join(task_log_dir, FAIL_LOG))
|
full_filename = os.path.normpath(os.path.join(task_log_dir, FAIL_LOG))
|
||||||
|
|
@ -6582,7 +6640,8 @@ def handle_regen_repo(options, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=options.quiet)
|
return watch_tasks(session, [task_id], quiet=options.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
|
|
||||||
def handle_dist_repo(options, session, args):
|
def handle_dist_repo(options, session, args):
|
||||||
"""Create a yum repo with distribution options"""
|
"""Create a yum repo with distribution options"""
|
||||||
|
|
@ -6700,7 +6759,8 @@ def handle_dist_repo(options, session, args):
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
session.logout()
|
session.logout()
|
||||||
return watch_tasks(session, [task_id], quiet=options.quiet)
|
return watch_tasks(session, [task_id], quiet=options.quiet,
|
||||||
|
poll_interval=options.poll_interval)
|
||||||
|
|
||||||
|
|
||||||
def anon_handle_search(options, session, args):
|
def anon_handle_search(options, session, args):
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,61 @@
|
||||||
|
# coding=utf-8
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import division
|
||||||
|
import optparse
|
||||||
|
import os
|
||||||
|
import random
|
||||||
|
import six
|
||||||
|
import socket
|
||||||
|
import string
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from six.moves import range
|
||||||
|
|
||||||
|
try:
|
||||||
|
import krbV
|
||||||
|
except ImportError: # pragma: no cover
|
||||||
|
krbV = None
|
||||||
|
|
||||||
|
import koji
|
||||||
|
|
||||||
|
# fix OptionParser for python 2.3 (optparse verion 1.4.1+)
|
||||||
|
# code taken from optparse version 1.5a2
|
||||||
|
OptionParser = optparse.OptionParser
|
||||||
|
if optparse.__version__ == "1.4.1+": # pragma: no cover
|
||||||
|
def _op_error(self, msg):
|
||||||
|
self.print_usage(sys.stderr)
|
||||||
|
msg = "%s: error: %s\n" % (self._get_prog_name(), msg)
|
||||||
|
if msg:
|
||||||
|
sys.stderr.write(msg)
|
||||||
|
sys.exit(2)
|
||||||
|
OptionParser.error = _op_error
|
||||||
|
|
||||||
|
greetings = ('hello', 'hi', 'yo', "what's up", "g'day", 'back to work',
|
||||||
|
'bonjour',
|
||||||
|
'hallo',
|
||||||
|
'ciao',
|
||||||
|
'hola',
|
||||||
|
u'olá',
|
||||||
|
u'dobrý den',
|
||||||
|
u'zdravstvuite',
|
||||||
|
u'góðan daginn',
|
||||||
|
'hej',
|
||||||
|
'tervehdys',
|
||||||
|
u'grüezi',
|
||||||
|
u'céad míle fáilte',
|
||||||
|
u'hylô',
|
||||||
|
u'bună ziua',
|
||||||
|
u'jó napot',
|
||||||
|
'dobre dan',
|
||||||
|
u'你好',
|
||||||
|
u'こんにちは',
|
||||||
|
u'नमस्कार',
|
||||||
|
u'안녕하세요')
|
||||||
|
|
||||||
|
ARGMAP = {'None': None,
|
||||||
|
'True': True,
|
||||||
|
'False': False}
|
||||||
|
|
||||||
def _(args):
|
def _(args):
|
||||||
"""Stub function for translation"""
|
"""Stub function for translation"""
|
||||||
return args
|
return args
|
||||||
|
|
@ -104,7 +162,7 @@ class TaskWatcher(object):
|
||||||
return ''
|
return ''
|
||||||
error = None
|
error = None
|
||||||
try:
|
try:
|
||||||
result = self.session.getTaskResult(self.id)
|
self.session.getTaskResult(self.id)
|
||||||
except (six.moves.xmlrpc_client.Fault,koji.GenericError) as e:
|
except (six.moves.xmlrpc_client.Fault,koji.GenericError) as e:
|
||||||
error = e
|
error = e
|
||||||
if error is None:
|
if error is None:
|
||||||
|
|
@ -200,7 +258,7 @@ def display_task_results(tasks):
|
||||||
# shouldn't happen
|
# shouldn't happen
|
||||||
print('%s has not completed' % task_label)
|
print('%s has not completed' % task_label)
|
||||||
|
|
||||||
def watch_tasks(session,tasklist,quiet=False):
|
def watch_tasks(session, tasklist, quiet=False, poll_interval=60):
|
||||||
global options
|
global options
|
||||||
if not tasklist:
|
if not tasklist:
|
||||||
return
|
return
|
||||||
|
|
@ -240,7 +298,7 @@ def watch_tasks(session,tasklist,quiet=False):
|
||||||
break
|
break
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
time.sleep(options.poll_interval)
|
time.sleep(poll_interval)
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
if tasks and not quiet:
|
if tasks and not quiet:
|
||||||
progname = os.path.basename(sys.argv[0]) or 'koji'
|
progname = os.path.basename(sys.argv[0]) or 'koji'
|
||||||
|
|
@ -253,8 +311,7 @@ Running Tasks:
|
||||||
raise
|
raise
|
||||||
return rv
|
return rv
|
||||||
|
|
||||||
def watch_logs(session, tasklist, opts):
|
def watch_logs(session, tasklist, opts, poll_interval):
|
||||||
global options
|
|
||||||
print("Watching logs (this may be safely interrupted)...")
|
print("Watching logs (this may be safely interrupted)...")
|
||||||
def _isDone(session, taskId):
|
def _isDone(session, taskId):
|
||||||
info = session.getTaskInfo(taskId)
|
info = session.getTaskInfo(taskId)
|
||||||
|
|
@ -306,7 +363,7 @@ def watch_logs(session, tasklist, opts):
|
||||||
if not tasklist:
|
if not tasklist:
|
||||||
break
|
break
|
||||||
|
|
||||||
time.sleep(options.poll_interval)
|
time.sleep(poll_interval)
|
||||||
|
|
||||||
|
|
||||||
def list_task_output_all_volumes(session, task_id):
|
def list_task_output_all_volumes(session, task_id):
|
||||||
|
|
@ -369,7 +426,7 @@ def _progress_callback(uploaded, total, piece, time, total_time):
|
||||||
def _running_in_bg():
|
def _running_in_bg():
|
||||||
try:
|
try:
|
||||||
return (not os.isatty(0)) or (os.getpgrp() != os.tcgetpgrp(0))
|
return (not os.isatty(0)) or (os.getpgrp() != os.tcgetpgrp(0))
|
||||||
except OSError as e:
|
except OSError:
|
||||||
return True
|
return True
|
||||||
def linked_upload(localfile, path, name=None):
|
def linked_upload(localfile, path, name=None):
|
||||||
"""Link a file into the (locally writable) workdir, bypassing upload"""
|
"""Link a file into the (locally writable) workdir, bypassing upload"""
|
||||||
|
|
@ -403,12 +460,12 @@ def has_krb_creds():
|
||||||
try:
|
try:
|
||||||
ctx = krbV.default_context()
|
ctx = krbV.default_context()
|
||||||
ccache = ctx.default_ccache()
|
ccache = ctx.default_ccache()
|
||||||
princ = ccache.principal()
|
ccache.principal()
|
||||||
return True
|
return True
|
||||||
except krbV.Krb5Error:
|
except krbV.Krb5Error:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def activate_session(session):
|
def activate_session(session, options):
|
||||||
"""Test and login the session is applicable"""
|
"""Test and login the session is applicable"""
|
||||||
global options
|
global options
|
||||||
if options.authtype == "noauth" or options.noauth:
|
if options.authtype == "noauth" or options.noauth:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue