PR#3077: Remove translation stub functions
Merges #3077 https://pagure.io/koji/pull-request/3077 Fixes: #3072 https://pagure.io/koji/issue/3072 Clean translation stubs
This commit is contained in:
commit
068ccedd0b
11 changed files with 1403 additions and 1556 deletions
63
cli/koji
63
cli/koji
|
|
@ -40,7 +40,7 @@ import koji
|
|||
import koji.plugin
|
||||
import koji.util
|
||||
from koji_cli.commands import * # noqa: F401, F403
|
||||
from koji_cli.lib import _, categories, get_epilog_str, greetings, warn
|
||||
from koji_cli.lib import categories, get_epilog_str, greetings, warn
|
||||
|
||||
|
||||
def register_plugin(plugin):
|
||||
|
|
@ -105,8 +105,8 @@ def get_options():
|
|||
|
||||
common_commands = ['build', 'help', 'download-build',
|
||||
'latest-build', 'search', 'list-targets']
|
||||
usage = _("%%prog [global-options] command [command-options-and-arguments]"
|
||||
"\n\nCommon commands: %s" % ', '.join(sorted(common_commands)))
|
||||
usage = "%%prog [global-options] command [command-options-and-arguments]\n\n" \
|
||||
"Common commands: %s" % ', '.join(sorted(common_commands))
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.disable_interspersed_args()
|
||||
progname = os.path.basename(sys.argv[0]) or 'koji'
|
||||
|
|
@ -116,38 +116,33 @@ def get_options():
|
|||
'origin_format_help': parser.origin_format_help(formatter),
|
||||
'epilog': get_epilog_str()}))
|
||||
parser.add_option("-p", "--profile", default=progname,
|
||||
help=_("specify a configuration profile. default: %s" % progname))
|
||||
help="specify a configuration profile. default: %s" % progname)
|
||||
parser.add_option("-c", "--config", dest="configFile",
|
||||
help=_("load profile's settings from another file"), metavar="FILE")
|
||||
parser.add_option("--keytab", help=_("specify a Kerberos keytab to use"), metavar="FILE")
|
||||
parser.add_option("--principal", help=_("specify a Kerberos principal to use"))
|
||||
parser.add_option("--cert", help=_("specify a SSL cert to use"), metavar="FILE")
|
||||
parser.add_option("--runas", help=_("run as the specified user (requires special privileges)"))
|
||||
parser.add_option("--user", help=_("specify user"))
|
||||
parser.add_option("--password", help=_("specify password"))
|
||||
parser.add_option("--noauth", action="store_true", default=False,
|
||||
help=_("do not authenticate"))
|
||||
help="load profile's settings from another file", metavar="FILE")
|
||||
parser.add_option("--keytab", help="specify a Kerberos keytab to use", metavar="FILE")
|
||||
parser.add_option("--principal", help="specify a Kerberos principal to use")
|
||||
parser.add_option("--cert", help="specify a SSL cert to use", metavar="FILE")
|
||||
parser.add_option("--runas", help="run as the specified user (requires special privileges)")
|
||||
parser.add_option("--user", help="specify user")
|
||||
parser.add_option("--password", help="specify password")
|
||||
parser.add_option("--noauth", action="store_true", default=False, help="do not authenticate")
|
||||
parser.add_option("--force-auth", action="store_true", # default (False) comes from the config
|
||||
help=_("authenticate even for read-only operations"))
|
||||
parser.add_option("--authtype", help=_("force use of a type of authentication, options: "
|
||||
"noauth, ssl, password, or kerberos"))
|
||||
parser.add_option("-d", "--debug", action="store_true",
|
||||
help=_("show debug output"))
|
||||
parser.add_option("--debug-xmlrpc", action="store_true",
|
||||
help=_("show xmlrpc debug output"))
|
||||
parser.add_option("-q", "--quiet", action="store_true", default=False,
|
||||
help=_("run quietly"))
|
||||
help="authenticate even for read-only operations")
|
||||
parser.add_option("--authtype", help="force use of a type of authentication, options: "
|
||||
"noauth, ssl, password, or kerberos")
|
||||
parser.add_option("-d", "--debug", action="store_true", help="show debug output")
|
||||
parser.add_option("--debug-xmlrpc", action="store_true", help="show xmlrpc debug output")
|
||||
parser.add_option("-q", "--quiet", action="store_true", default=False, help="run quietly")
|
||||
parser.add_option("--skip-main", action="store_true", default=False,
|
||||
help=_("don't actually run main"))
|
||||
parser.add_option("-s", "--server", help=_("url of XMLRPC server"))
|
||||
parser.add_option("--topdir", help=_("specify topdir"))
|
||||
parser.add_option("--weburl", help=_("url of the Koji web interface"))
|
||||
parser.add_option("--topurl", help=_("url for Koji file access"))
|
||||
help="don't actually run main")
|
||||
parser.add_option("-s", "--server", help="url of XMLRPC server")
|
||||
parser.add_option("--topdir", help="specify topdir")
|
||||
parser.add_option("--weburl", help="url of the Koji web interface")
|
||||
parser.add_option("--topurl", help="url for Koji file access")
|
||||
parser.add_option("--pkgurl", help=SUPPRESS_HELP)
|
||||
parser.add_option("--plugin-paths", metavar='PATHS',
|
||||
help=_("specify additional plugin paths (colon separated)"))
|
||||
parser.add_option("--help-commands", action="store_true", default=False,
|
||||
help=_("list commands"))
|
||||
help="specify additional plugin paths (colon separated)")
|
||||
parser.add_option("--help-commands", action="store_true", default=False, help="list commands")
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
# load local config
|
||||
|
|
@ -227,8 +222,8 @@ def get_options():
|
|||
|
||||
def handle_help(options, session, args):
|
||||
"[info] List available commands"
|
||||
usage = _("usage: %prog help <category> ...")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
usage = "usage: %prog help <category> ..."
|
||||
usage += "\n(Specify the --help global option for a list of other help options)"
|
||||
parser = OptionParser(usage=usage)
|
||||
# the --admin opt is for backwards compatibility. It is equivalent to: koji help admin
|
||||
parser.add_option("--admin", action="store_true", help=SUPPRESS_HELP)
|
||||
|
|
@ -290,9 +285,9 @@ def list_commands(categories_chosen=None):
|
|||
alias = alias.replace('_', '-')
|
||||
handlers.append((alias, value))
|
||||
handlers.sort()
|
||||
print(_("Available commands:"))
|
||||
print("Available commands:")
|
||||
for category in categories_chosen:
|
||||
print(_("\n%s:" % categories[category]))
|
||||
print("\n%s:" % categories[category])
|
||||
for alias, handler in handlers:
|
||||
desc = handler.__doc__ or ''
|
||||
if desc.startswith('[%s] ' % category):
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -21,6 +21,7 @@ from six.moves import range
|
|||
import koji
|
||||
# import parse_arches to current namespace for backward compatibility
|
||||
from koji import parse_arches
|
||||
from koji import _ # noqa: F401
|
||||
from koji.util import md5_constructor, to_list
|
||||
from koji.xmlrpcplus import xmlrpc_client
|
||||
|
||||
|
|
@ -43,8 +44,7 @@ def _check_time_option(option, opt, value):
|
|||
ts = time.mktime(dt.timetuple())
|
||||
return ts
|
||||
except Exception:
|
||||
raise optparse.OptionValueError(
|
||||
_("option %s: invalid time specification: %r") % (opt, value))
|
||||
raise optparse.OptionValueError("option %s: invalid time specification: %r" % (opt, value))
|
||||
|
||||
|
||||
class TimeOption(optparse.Option):
|
||||
|
|
@ -55,9 +55,8 @@ class TimeOption(optparse.Option):
|
|||
|
||||
@classmethod
|
||||
def get_help(self):
|
||||
return _("time is specified as timestamp or date/time in any "
|
||||
"format which can be parsed by dateutil.parser. e.g. "
|
||||
"\"2020-12-31 12:35\" or \"December 31st 12:35\"")
|
||||
return "time is specified as timestamp or date/time in any format which can be " \
|
||||
"parsed by dateutil.parser. e.g. \"2020-12-31 12:35\" or \"December 31st 12:35\""
|
||||
|
||||
|
||||
greetings = ('hello', 'hi', 'yo', "what's up", "g'day", 'back to work',
|
||||
|
|
@ -87,11 +86,6 @@ ARGMAP = {'None': None,
|
|||
'False': False}
|
||||
|
||||
|
||||
def _(args):
|
||||
"""Stub function for translation"""
|
||||
return args
|
||||
|
||||
|
||||
def arg_filter(arg):
|
||||
try:
|
||||
return int(arg)
|
||||
|
|
@ -130,11 +124,11 @@ Try "%(progname)s <command> --help" for help about the options of a particular c
|
|||
Try "%(progname)s help <category>" to get commands under a particular category
|
||||
Available categories are: %(categories)s
|
||||
''' % ({'progname': progname, 'categories': categories_ordered})
|
||||
return _(epilog_str)
|
||||
return epilog_str
|
||||
|
||||
|
||||
def get_usage_str(usage):
|
||||
return usage + _("\n(Specify the --help global option for a list of other help options)")
|
||||
return usage + "\n(Specify the --help global option for a list of other help options)"
|
||||
|
||||
|
||||
def ensure_connection(session, options=None):
|
||||
|
|
@ -145,14 +139,14 @@ def ensure_connection(session, options=None):
|
|||
try:
|
||||
ret = session.getAPIVersion()
|
||||
except requests.exceptions.ConnectionError as ex:
|
||||
warn(_("Error: Unable to connect to server"))
|
||||
warn("Error: Unable to connect to server")
|
||||
if options and getattr(options, 'debug', False):
|
||||
error(str(ex))
|
||||
else:
|
||||
error()
|
||||
if ret != koji.API_VERSION:
|
||||
warn(_("WARNING: The server is at API version %d and "
|
||||
"the client is at %d" % (ret, koji.API_VERSION)))
|
||||
warn("WARNING: The server is at API version %d and "
|
||||
"the client is at %d" % (ret, koji.API_VERSION))
|
||||
|
||||
|
||||
def print_task_headers():
|
||||
|
|
@ -565,9 +559,9 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None,
|
|||
koji.ensuredir(os.path.dirname(relpath))
|
||||
if not quiet:
|
||||
if size and num:
|
||||
print(_("Downloading [%d/%d]: %s") % (num, size, relpath))
|
||||
print("Downloading [%d/%d]: %s" % (num, size, relpath))
|
||||
else:
|
||||
print(_("Downloading: %s") % relpath)
|
||||
print("Downloading: %s" % relpath)
|
||||
|
||||
pos = 0
|
||||
headers = {}
|
||||
|
|
@ -578,10 +572,10 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None,
|
|||
if pos:
|
||||
if filesize == pos:
|
||||
if not quiet:
|
||||
print(_("File %s already downloaded, skipping" % relpath))
|
||||
print("File %s already downloaded, skipping" % relpath)
|
||||
return
|
||||
if not quiet:
|
||||
print(_("Appending to existing file %s" % relpath))
|
||||
print("Appending to existing file %s" % relpath)
|
||||
headers['Range'] = ('bytes=%d-' % pos)
|
||||
else:
|
||||
# rewrite
|
||||
|
|
@ -754,9 +748,9 @@ def activate_session(session, options):
|
|||
else:
|
||||
session.gssapi_login(proxyuser=runas)
|
||||
except socket.error as e:
|
||||
warn(_("Could not connect to Kerberos authentication service: %s") % e.args[1])
|
||||
warn("Could not connect to Kerberos authentication service: %s" % e.args[1])
|
||||
if not noauth and not session.logged_in:
|
||||
error(_("Unable to log in, no authentication methods available"))
|
||||
error("Unable to log in, no authentication methods available")
|
||||
# don't add "options" to ensure_connection it would create loop in case of --force-auth
|
||||
# when it calls activate_session
|
||||
ensure_connection(session)
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ Most simple command would look like this:
|
|||
@export_cli
|
||||
def anon_handle_echo(options, session, args):
|
||||
"[info] Print arguments"
|
||||
usage = _("usage: %prog echo <message>")
|
||||
usage = "usage: %prog echo <message>"
|
||||
parser = OptionParser(usage=usage)
|
||||
(opts, args) = parser.parse_args(args)
|
||||
print(args[0])
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ from six.moves import range, zip
|
|||
|
||||
from koji.tasks import parse_task_params
|
||||
from koji.xmlrpcplus import Fault, dumps, getparser, loads, xmlrpc_client
|
||||
from koji.util import deprecated
|
||||
from . import util
|
||||
from . import _version
|
||||
__version__ = _version.__version__
|
||||
|
|
@ -92,6 +93,7 @@ PROFILE_MODULES = {} # {module_name: module_instance}
|
|||
|
||||
def _(args):
|
||||
"""Stub function for translation"""
|
||||
deprecated('The stub function for translation is no longer used\n')
|
||||
return args # pragma: no cover
|
||||
|
||||
## Constants ##
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ from optparse import OptionParser
|
|||
import koji
|
||||
from koji.plugin import export_cli
|
||||
from koji_cli.lib import (
|
||||
_,
|
||||
activate_session,
|
||||
bytes_to_stdout,
|
||||
list_task_output_all_volumes,
|
||||
|
|
@ -18,38 +17,38 @@ from koji_cli.lib import (
|
|||
@export_cli
|
||||
def handle_runroot(options, session, args):
|
||||
"[admin] Run a command in a buildroot"
|
||||
usage = _("usage: %prog runroot [options] <tag> <arch> <command>")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
usage = "usage: %prog runroot [options] <tag> <arch> <command>"
|
||||
usage += "\n(Specify the --help global option for a list of other help options)"
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.disable_interspersed_args()
|
||||
parser.add_option("-p", "--package", action="append", default=[],
|
||||
help=_("make sure this package is in the chroot"))
|
||||
help="make sure this package is in the chroot")
|
||||
parser.add_option("-m", "--mount", action="append", default=[],
|
||||
help=_("mount this directory read-write in the chroot"))
|
||||
help="mount this directory read-write in the chroot")
|
||||
parser.add_option("--skip-setarch", action="store_true", default=False,
|
||||
help=_("bypass normal setarch in the chroot"))
|
||||
parser.add_option("-w", "--weight", type='int', help=_("set task weight"))
|
||||
parser.add_option("--channel-override", help=_("use a non-standard channel"))
|
||||
help="bypass normal setarch in the chroot")
|
||||
parser.add_option("-w", "--weight", type='int', help="set task weight")
|
||||
parser.add_option("--channel-override", help="use a non-standard channel")
|
||||
parser.add_option("--task-id", action="store_true", default=False,
|
||||
help=_("Print the ID of the runroot task"))
|
||||
help="Print the ID of the runroot task")
|
||||
parser.add_option("--use-shell", action="store_true", default=False,
|
||||
help=_("Run command through a shell, otherwise uses exec"))
|
||||
help="Run command through a shell, otherwise uses exec")
|
||||
parser.add_option("--new-chroot", action="store_true", default=None,
|
||||
help=_("Run command with the --new-chroot (systemd-nspawn) option to mock"))
|
||||
help="Run command with the --new-chroot (systemd-nspawn) option to mock")
|
||||
parser.add_option("--old-chroot", action="store_false", default=None, dest='new_chroot',
|
||||
help=_("Run command with the --old-chroot (systemd-nspawn) option to mock"))
|
||||
parser.add_option("--repo-id", type="int", help=_("ID of the repo to use"))
|
||||
help="Run command with the --old-chroot (systemd-nspawn) option to mock")
|
||||
parser.add_option("--repo-id", type="int", help="ID of the repo to use")
|
||||
parser.add_option("--nowait", action="store_false", dest="wait",
|
||||
default=True, help=_("Do not wait on task"))
|
||||
default=True, help="Do not wait on task")
|
||||
parser.add_option("--watch", action="store_true",
|
||||
help=_("Watch task instead of printing runroot.log"))
|
||||
help="Watch task instead of printing runroot.log")
|
||||
parser.add_option("--quiet", action="store_true", default=options.quiet,
|
||||
help=_("Do not print the task information"))
|
||||
help="Do not print the task information")
|
||||
|
||||
(opts, args) = parser.parse_args(args)
|
||||
|
||||
if len(args) < 3:
|
||||
parser.error(_("Incorrect number of arguments"))
|
||||
parser.error("Incorrect number of arguments")
|
||||
assert False # pragma: no cover
|
||||
|
||||
activate_session(session, options)
|
||||
|
|
|
|||
|
|
@ -4,38 +4,35 @@ from optparse import OptionParser
|
|||
|
||||
import koji
|
||||
from koji.plugin import export_cli
|
||||
from koji_cli.lib import _, activate_session, watch_tasks
|
||||
from koji_cli.lib import activate_session, watch_tasks
|
||||
|
||||
|
||||
@export_cli
|
||||
def handle_save_failed_tree(options, session, args):
|
||||
"Create tarball with whole buildtree"
|
||||
usage = _("usage: %prog save-failed-tree [options] ID")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
usage = "usage: %prog save-failed-tree [options] ID"
|
||||
usage += "\n(Specify the --help global option for a list of other help options)"
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option("-f", "--full", action="store_true", default=False,
|
||||
help=_("Download whole tree, if not specified, "
|
||||
"only builddir will be downloaded"))
|
||||
parser.add_option("-t", "--task", action="store_const", dest="mode",
|
||||
const="task", default="task",
|
||||
help=_("Treat ID as a task ID (the default)"))
|
||||
help="Download whole tree, if not specified, "
|
||||
"only builddir will be downloaded")
|
||||
parser.add_option("-t", "--task", action="store_const", dest="mode", const="task",
|
||||
default="task", help="Treat ID as a task ID (the default)")
|
||||
parser.add_option("-r", "--buildroot", action="store_const", dest="mode",
|
||||
const="buildroot",
|
||||
help=_("Treat ID as a buildroot ID"))
|
||||
const="buildroot", help="Treat ID as a buildroot ID")
|
||||
parser.add_option("--quiet", action="store_true", default=options.quiet,
|
||||
help=_("Do not print the task information"))
|
||||
parser.add_option("--nowait", action="store_true",
|
||||
help=_("Don't wait on build"))
|
||||
help="Do not print the task information")
|
||||
parser.add_option("--nowait", action="store_true", help="Don't wait on build")
|
||||
|
||||
(opts, args) = parser.parse_args(args)
|
||||
|
||||
if len(args) != 1:
|
||||
parser.error(_("List exactly one task or buildroot ID"))
|
||||
parser.error("List exactly one task or buildroot ID")
|
||||
|
||||
try:
|
||||
id_val = int(args[0])
|
||||
except ValueError:
|
||||
parser.error(_("ID must be an integer"))
|
||||
parser.error("ID must be an integer")
|
||||
|
||||
activate_session(session, options)
|
||||
|
||||
|
|
@ -44,27 +41,25 @@ def handle_save_failed_tree(options, session, args):
|
|||
else:
|
||||
brs = [b['id'] for b in session.listBuildroots(taskID=id_val)]
|
||||
if not brs:
|
||||
print(_("No buildroots for task %s") % id_val)
|
||||
print("No buildroots for task %s" % id_val)
|
||||
return 1
|
||||
br_id = max(brs)
|
||||
if len(brs) > 1:
|
||||
print(_("Multiple buildroots for task. Choosing last one (%s)") % br_id)
|
||||
print("Multiple buildroots for task. Choosing last one (%s)" % br_id)
|
||||
|
||||
try:
|
||||
task_id = session.saveFailedTree(br_id, opts.full)
|
||||
except koji.GenericError as e:
|
||||
m = str(e)
|
||||
if 'Invalid method' in m:
|
||||
print(_("* The save_failed_tree plugin appears to not be "
|
||||
"installed on the koji hub. Please contact the "
|
||||
"administrator."))
|
||||
print("* The save_failed_tree plugin appears to not be installed on the koji hub. "
|
||||
"Please contact the administrator.")
|
||||
return 1
|
||||
raise
|
||||
|
||||
if not opts.quiet:
|
||||
print(_("Created task %s for buildroot %s") % (task_id, br_id))
|
||||
print("Task info: %s/taskinfo?taskID=%s"
|
||||
% (options.weburl, task_id))
|
||||
print("Created task %s for buildroot %s" % (task_id, br_id))
|
||||
print("Task info: %s/taskinfo?taskID=%s" % (options.weburl, task_id))
|
||||
|
||||
if opts.nowait:
|
||||
return
|
||||
|
|
|
|||
|
|
@ -10,32 +10,22 @@ from argparse import ArgumentParser
|
|||
import koji
|
||||
from koji.plugin import export_cli
|
||||
from koji_cli.commands import anon_handle_wait_repo
|
||||
from koji_cli.lib import _, activate_session, arg_filter
|
||||
from koji_cli.lib import activate_session, arg_filter
|
||||
|
||||
|
||||
@export_cli
|
||||
def handle_add_sidetag(options, session, args):
|
||||
"Create sidetag"
|
||||
usage = _("%(prog)s add-sidetag [options] <basetag>")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
usage = "%(prog)s add-sidetag [options] <basetag>"
|
||||
usage += "\n(Specify the --help global option for a list of other help options)"
|
||||
parser = ArgumentParser(usage=usage)
|
||||
parser.add_argument("basetag", help="name of basetag")
|
||||
parser.add_argument(
|
||||
"-q",
|
||||
"--quiet",
|
||||
action="store_true",
|
||||
help=_("Do not print tag name"),
|
||||
default=options.quiet,
|
||||
)
|
||||
parser.add_argument(
|
||||
"-w", "--wait", action="store_true", help=_("Wait until repo is ready.")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--debuginfo", action="store_true", help=_("Buildroot repo will contain debuginfos")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--suffix", action="store", help=_("Suffix from hub-supported ones")
|
||||
)
|
||||
parser.add_argument("-q", "--quiet", action="store_true", help="Do not print tag name",
|
||||
default=options.quiet)
|
||||
parser.add_argument("-w", "--wait", action="store_true", help="Wait until repo is ready.")
|
||||
parser.add_argument("--debuginfo", action="store_true",
|
||||
help="Buildroot repo will contain debuginfos")
|
||||
parser.add_argument("--suffix", action="store", help="Suffix from hub-supported ones")
|
||||
|
||||
opts = parser.parse_args(args)
|
||||
|
||||
|
|
@ -47,10 +37,10 @@ def handle_add_sidetag(options, session, args):
|
|||
try:
|
||||
tag = session.createSideTag(opts.basetag, **kwargs)
|
||||
except koji.ActionNotAllowed:
|
||||
parser.error(_("Policy violation"))
|
||||
parser.error("Policy violation")
|
||||
except koji.ParameterError as ex:
|
||||
if 'suffix' in str(ex):
|
||||
parser.error(_("Hub is older and doesn't support --suffix, please run it without it"))
|
||||
parser.error("Hub is older and doesn't support --suffix, please run it without it")
|
||||
else:
|
||||
raise
|
||||
|
||||
|
|
@ -67,8 +57,8 @@ def handle_add_sidetag(options, session, args):
|
|||
@export_cli
|
||||
def handle_remove_sidetag(options, session, args):
|
||||
"Remove sidetag"
|
||||
usage = _("%(prog)s remove-sidetag [options] <sidetag> ...")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
usage = "%(prog)s remove-sidetag [options] <sidetag> ..."
|
||||
usage += "\n(Specify the --help global option for a list of other help options)"
|
||||
parser = ArgumentParser(usage=usage)
|
||||
parser.add_argument("sidetags", help="name of sidetag", nargs="+")
|
||||
opts = parser.parse_args(args)
|
||||
|
|
@ -84,17 +74,17 @@ def handle_remove_sidetag(options, session, args):
|
|||
@export_cli
|
||||
def handle_list_sidetags(options, session, args):
|
||||
"List sidetags"
|
||||
usage = _("%(prog)s list-sidetags [options]")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
usage = "%(prog)s list-sidetags [options]"
|
||||
usage += "\n(Specify the --help global option for a list of other help options)"
|
||||
parser = ArgumentParser(usage=usage)
|
||||
parser.add_argument("--basetag", action="store", help=_("Filter on basetag"))
|
||||
parser.add_argument("--user", action="store", help=_("Filter on user"))
|
||||
parser.add_argument("--mine", action="store_true", help=_("Filter on user"))
|
||||
parser.add_argument("--basetag", action="store", help="Filter on basetag")
|
||||
parser.add_argument("--user", action="store", help="Filter on user")
|
||||
parser.add_argument("--mine", action="store_true", help="Filter on user")
|
||||
|
||||
opts = parser.parse_args(args)
|
||||
|
||||
if opts.mine and opts.user:
|
||||
parser.error(_("Specify only one from --user --mine"))
|
||||
parser.error("Specify only one from --user --mine")
|
||||
|
||||
if opts.mine:
|
||||
activate_session(session, options)
|
||||
|
|
@ -109,17 +99,17 @@ def handle_list_sidetags(options, session, args):
|
|||
@export_cli
|
||||
def handle_edit_sidetag(options, session, args):
|
||||
"Edit sidetag"
|
||||
usage = _("%(prog)s edit-sidetag [options]")
|
||||
usage += _("\n(Specify the --help global option for a list of other help options)")
|
||||
usage = "%(prog)s edit-sidetag [options]"
|
||||
usage += "\n(Specify the --help global option for a list of other help options)"
|
||||
parser = ArgumentParser(usage=usage)
|
||||
parser.add_argument("sidetag", help="name of sidetag")
|
||||
parser.add_argument("--debuginfo", action="store_true", default=None,
|
||||
help=_("Generate debuginfo repository"))
|
||||
help="Generate debuginfo repository")
|
||||
parser.add_argument("--no-debuginfo", action="store_false", dest="debuginfo")
|
||||
parser.add_argument("--rpm-macro", action="append", default=[], metavar="key=value",
|
||||
dest="rpm_macros", help=_("Set tag-specific rpm macros"))
|
||||
dest="rpm_macros", help="Set tag-specific rpm macros")
|
||||
parser.add_argument("--remove-rpm-macro", action="append", default=[], metavar="key",
|
||||
dest="remove_rpm_macros", help=_("Remove rpm macros"))
|
||||
dest="remove_rpm_macros", help="Remove rpm macros")
|
||||
|
||||
opts = parser.parse_args(args)
|
||||
|
||||
|
|
|
|||
108
util/koji-gc
108
util/koji-gc
|
|
@ -26,88 +26,78 @@ import koji.policy
|
|||
from koji.util import LazyDict, LazyValue, to_list
|
||||
|
||||
|
||||
def _(args):
|
||||
"""Stub function for translation"""
|
||||
return args
|
||||
|
||||
|
||||
def get_options():
|
||||
"""process options from command line and config file"""
|
||||
|
||||
usage = _("%prog [options]")
|
||||
usage = "%prog [options]"
|
||||
parser = optparse.OptionParser(usage=usage)
|
||||
parser.add_option("-c", "--config-file", metavar="FILE",
|
||||
default='/etc/koji-gc/koji-gc.conf',
|
||||
help=_("use alternate configuration file"))
|
||||
parser.add_option("--keytab", help=_("specify a Kerberos keytab to use"))
|
||||
parser.add_option("--principal", help=_("specify a Kerberos principal to use"))
|
||||
parser.add_option("-c", "--config-file", metavar="FILE", default='/etc/koji-gc/koji-gc.conf',
|
||||
help="use alternate configuration file")
|
||||
parser.add_option("--keytab", help="specify a Kerberos keytab to use")
|
||||
parser.add_option("--principal", help="specify a Kerberos principal to use")
|
||||
parser.add_option("--runas", metavar="USER",
|
||||
help=_("run as the specified user (requires special privileges)"))
|
||||
parser.add_option("--user", help=_("specify user"))
|
||||
parser.add_option("--password", help=_("specify password"))
|
||||
parser.add_option("--noauth", action="store_true", default=False,
|
||||
help=_("do not authenticate"))
|
||||
help="run as the specified user (requires special privileges)")
|
||||
parser.add_option("--user", help="specify user")
|
||||
parser.add_option("--password", help="specify password")
|
||||
parser.add_option("--noauth", action="store_true", default=False, help="do not authenticate")
|
||||
parser.add_option("--network-hack", action="store_true", default=False,
|
||||
help=optparse.SUPPRESS_HELP) # no longer used
|
||||
parser.add_option("--cert", help=_("Client SSL certificate file for authentication"))
|
||||
parser.add_option("--serverca", help=_("CA cert file that issued the hub certificate"))
|
||||
parser.add_option("-n", "--test", action="store_true", default=False,
|
||||
help=_("test mode"))
|
||||
parser.add_option("--cert", help="Client SSL certificate file for authentication")
|
||||
parser.add_option("--serverca", help="CA cert file that issued the hub certificate")
|
||||
parser.add_option("-n", "--test", action="store_true", default=False, help="test mode")
|
||||
parser.add_option("-d", "--debug", action="store_true", default=False,
|
||||
help=_("show debug output"))
|
||||
help="show debug output")
|
||||
parser.add_option("--debug-xmlrpc", action="store_true", default=False,
|
||||
help=_("show xmlrpc debug output"))
|
||||
help="show xmlrpc debug output")
|
||||
parser.add_option("--smtp-host", metavar="HOST", default='localhost',
|
||||
help=_("specify smtp server for notifications"))
|
||||
help="specify smtp server for notifications")
|
||||
parser.add_option("--smtp-user", dest="smtp_user", metavar="USER",
|
||||
help=_("specify smtp username for notifications"))
|
||||
help="specify smtp username for notifications")
|
||||
parser.add_option("--smtp-pass", dest="smtp_pass", metavar="PASSWORD",
|
||||
help=optparse.SUPPRESS_HELP) # do not allow passwords on a command line
|
||||
parser.add_option("--no-mail", action='store_false', default=True, dest="mail",
|
||||
help=_("don't send notifications"))
|
||||
parser.add_option("--send-mail", action='store_true', dest="mail",
|
||||
help=_("send notifications"))
|
||||
help="don't send notifications")
|
||||
parser.add_option("--send-mail", action='store_true', dest="mail", help="send notifications")
|
||||
parser.add_option("--email-domain", default="fedoraproject.org",
|
||||
help=_("Email domain appended to Koji username for notifications"))
|
||||
help="Email domain appended to Koji username for notifications")
|
||||
parser.add_option("--from-addr", default="Koji Build System <buildsys@example.com>",
|
||||
help=_("From address for notifications"))
|
||||
parser.add_option("--cc-addr", help=_("CC address for notifications (multiple)"),
|
||||
help="From address for notifications")
|
||||
parser.add_option("--cc-addr", help="CC address for notifications (multiple)",
|
||||
action="append", metavar="EMAIL_ADDRESS")
|
||||
parser.add_option("--bcc-addr", help=_("BCC address for notifications (multiple)"),
|
||||
parser.add_option("--bcc-addr", help="BCC address for notifications (multiple)",
|
||||
action="append", metavar="EMAIL_ADDRESS")
|
||||
parser.add_option("--email-template", default="/etc/koji-gc/email.tpl",
|
||||
help=_("notification template"))
|
||||
parser.add_option("--action", help=_("action(s) to take"))
|
||||
help="notification template")
|
||||
parser.add_option("--action", help="action(s) to take")
|
||||
parser.add_option("--delay", metavar="INTERVAL", default='5 days',
|
||||
help="time before eligible builds are placed in trashcan")
|
||||
parser.add_option("--grace-period", default='4 weeks', metavar="INTERVAL",
|
||||
help="time that builds are held in trashcan")
|
||||
parser.add_option("--skip-main", action="store_true", default=False,
|
||||
help=_("don't actually run main"))
|
||||
help="don't actually run main")
|
||||
parser.add_option("--unprotected-keys", metavar="KEYS",
|
||||
help=_("allow builds signed with these keys to be deleted"))
|
||||
help="allow builds signed with these keys to be deleted")
|
||||
parser.add_option("--tag-filter", "--tag", metavar="PATTERN", action="append",
|
||||
help=_("Process only tags matching PATTERN when pruning"))
|
||||
help="Process only tags matching PATTERN when pruning")
|
||||
parser.add_option("--ignore-tags", metavar="PATTERN", action="append",
|
||||
help=_("Ignore tags matching PATTERN when pruning"))
|
||||
parser.add_option("--pkg-filter", "--pkg", "--package",
|
||||
metavar="PATTERN", action='append',
|
||||
help=_("Process only packages matching PATTERN"))
|
||||
help="Ignore tags matching PATTERN when pruning")
|
||||
parser.add_option("--pkg-filter", "--pkg", "--package", metavar="PATTERN", action='append',
|
||||
help="Process only packages matching PATTERN")
|
||||
parser.add_option("--bypass-locks", metavar="PATTERN", action="append",
|
||||
help=_("Bypass locks for tags matching PATTERN"))
|
||||
help="Bypass locks for tags matching PATTERN")
|
||||
parser.add_option("--purge", action="store_true", default=False,
|
||||
help=_("When pruning, attempt to delete the builds that are untagged"))
|
||||
help="When pruning, attempt to delete the builds that are untagged")
|
||||
parser.add_option("--trashcan-tag", default='trashcan', metavar="TAG",
|
||||
help=_("specify an alternate trashcan tag"))
|
||||
help="specify an alternate trashcan tag")
|
||||
parser.add_option("--weburl", default="http://localhost/koji", metavar="URL",
|
||||
help=_("url of koji web server (for use in notifications)"))
|
||||
parser.add_option("-s", "--server", help=_("url of koji XMLRPC server"))
|
||||
parser.add_option("--lock-file", help=_("koji-gc will wait while specified file exists. "
|
||||
"Default path is /run/user/<uid>/koji-gc.lock. "
|
||||
"For service usage /var/lock/koji-gc.lock is "
|
||||
"recommended."))
|
||||
help="url of koji web server (for use in notifications)")
|
||||
parser.add_option("-s", "--server", help="url of koji XMLRPC server")
|
||||
parser.add_option("--lock-file", help="koji-gc will wait while specified file exists. "
|
||||
"Default path is /run/user/<uid>/koji-gc.lock. "
|
||||
"For service usage /var/lock/koji-gc.lock is "
|
||||
"recommended.")
|
||||
parser.add_option("--exit-on-lock", action="store_true",
|
||||
help=_("quit if --lock-file exists, don't wait"))
|
||||
help="quit if --lock-file exists, don't wait")
|
||||
# parse once to get the config file
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
|
|
@ -181,7 +171,7 @@ def get_options():
|
|||
options.action = options.action.lower().replace(',', ' ').split()
|
||||
for x in options.action:
|
||||
if x not in actions:
|
||||
parser.error(_("Invalid action: %s") % x)
|
||||
parser.error("Invalid action: %s" % x)
|
||||
else:
|
||||
options.action = ('delete', 'prune', 'trash')
|
||||
|
||||
|
|
@ -202,7 +192,7 @@ def get_options():
|
|||
options.key_aliases[parts[0].upper()] = parts[1]
|
||||
except ValueError as e:
|
||||
print(e)
|
||||
parser.error(_("Invalid key alias data in config: %s") % config.get('main', 'key_aliases'))
|
||||
parser.error("Invalid key alias data in config: %s" % config.get('main', 'key_aliases'))
|
||||
|
||||
# parse time intervals
|
||||
for key in ('delay', 'grace_period'):
|
||||
|
|
@ -213,7 +203,7 @@ def get_options():
|
|||
if options.debug:
|
||||
print("%s: %s seconds" % (key, value))
|
||||
except ValueError:
|
||||
parser.error(_("Invalid time interval: %s") % value)
|
||||
parser.error("Invalid time interval: %s" % value)
|
||||
|
||||
# special handling for cert defaults
|
||||
cert_defaults = {
|
||||
|
|
@ -228,7 +218,7 @@ def get_options():
|
|||
|
||||
template = getattr(options, 'email_template', None)
|
||||
if not template or not os.access(template, os.F_OK):
|
||||
parser.error(_("No such file: %s") % template)
|
||||
parser.error("No such file: %s" % template)
|
||||
|
||||
return options, args
|
||||
|
||||
|
|
@ -375,10 +365,10 @@ def ensure_connection(session):
|
|||
try:
|
||||
ret = session.getAPIVersion()
|
||||
except requests.exceptions.ConnectionError:
|
||||
error(_("Error: Unable to connect to server"))
|
||||
error("Error: Unable to connect to server")
|
||||
if ret != koji.API_VERSION:
|
||||
warn(_("WARNING: The server is at API version %d and the client is at %d" %
|
||||
(ret, koji.API_VERSION)))
|
||||
warn("WARNING: The server is at API version %d and the client is at %d" %
|
||||
(ret, koji.API_VERSION))
|
||||
|
||||
|
||||
def activate_session(session):
|
||||
|
|
@ -397,7 +387,7 @@ def activate_session(session):
|
|||
session.gssapi_login(principal=options.principal, keytab=options.keytab,
|
||||
proxyuser=options.runas)
|
||||
if not options.noauth and not session.logged_in:
|
||||
error(_("Error: unable to log in, no authentication methods available"))
|
||||
error("Error: unable to log in, no authentication methods available")
|
||||
ensure_connection(session)
|
||||
if options.debug:
|
||||
print("successfully connected to hub")
|
||||
|
|
@ -457,7 +447,7 @@ Build: %%(name)s-%%(version)s-%%(release)s
|
|||
def main(args):
|
||||
activate_session(session)
|
||||
if not session.getTag(options.trashcan_tag, strict=False):
|
||||
error(_("Trashcan tag %s doesn't exist") % options.trashcan_tag)
|
||||
error("Trashcan tag %s doesn't exist" % options.trashcan_tag)
|
||||
for x in options.action:
|
||||
globals()['handle_' + x]()
|
||||
|
||||
|
|
|
|||
110
util/koji-shadow
110
util/koji-shadow
|
|
@ -47,11 +47,6 @@ socket.setdefaulttimeout(180) # XXX - too short?
|
|||
logfile = None
|
||||
|
||||
|
||||
def _(args):
|
||||
"""Stub function for translation"""
|
||||
return args
|
||||
|
||||
|
||||
def log(str):
|
||||
global logfile
|
||||
print("%s" % str)
|
||||
|
|
@ -67,82 +62,65 @@ class SubOption(object):
|
|||
def get_options():
|
||||
"""process options from command line and config file"""
|
||||
|
||||
usage = _("%prog [options]")
|
||||
usage = "%prog [options]"
|
||||
parser = optparse.OptionParser(usage=usage)
|
||||
parser.add_option("-c", "--config-file", metavar="FILE",
|
||||
help=_("use alternate configuration file"))
|
||||
parser.add_option("--keytab", help=_("specify a Kerberos keytab to use"))
|
||||
parser.add_option("--principal", help=_("specify a Kerberos principal to use"))
|
||||
help="use alternate configuration file")
|
||||
parser.add_option("--keytab", help="specify a Kerberos keytab to use")
|
||||
parser.add_option("--principal", help="specify a Kerberos principal to use")
|
||||
parser.add_option("--runas", metavar="USER",
|
||||
help=_("run as the specified user (requires special privileges)"))
|
||||
parser.add_option("--user", help=_("specify user"))
|
||||
parser.add_option("--password", help=_("specify password"))
|
||||
help="run as the specified user (requires special privileges)")
|
||||
parser.add_option("--user", help="specify user")
|
||||
parser.add_option("--password", help="specify password")
|
||||
parser.add_option("--noauth", action="store_true", default=False,
|
||||
help=_("do not authenticate"))
|
||||
parser.add_option("-n", "--test", action="store_true", default=False,
|
||||
help=_("test mode"))
|
||||
help="do not authenticate")
|
||||
parser.add_option("-n", "--test", action="store_true", default=False, help="test mode")
|
||||
parser.add_option("-d", "--debug", action="store_true", default=False,
|
||||
help=_("show debug output"))
|
||||
help="show debug output")
|
||||
parser.add_option("--first-one", action="store_true", default=False,
|
||||
help=_("stop after scanning first build -- debugging"))
|
||||
help="stop after scanning first build -- debugging")
|
||||
parser.add_option("--debug-xmlrpc", action="store_true", default=False,
|
||||
help=_("show xmlrpc debug output"))
|
||||
help="show xmlrpc debug output")
|
||||
parser.add_option("--skip-main", action="store_true", default=False,
|
||||
help=_("don't actually run main"))
|
||||
# parser.add_option("--tag-filter", metavar="PATTERN",
|
||||
# help=_("limit tags for pruning"))
|
||||
# parser.add_option("--pkg-filter", metavar="PATTERN",
|
||||
# help=_("limit packages for pruning"))
|
||||
parser.add_option("--max-jobs", type="int", default=0,
|
||||
help=_("limit number of tasks"))
|
||||
parser.add_option("--build",
|
||||
help=_("scan just this build"))
|
||||
parser.add_option("-s", "--server",
|
||||
help=_("url of local XMLRPC server"))
|
||||
parser.add_option("-r", "--remote",
|
||||
help=_("url of remote XMLRPC server"))
|
||||
help="don't actually run main")
|
||||
# parser.add_option("--tag-filter", metavar="PATTERN", help="limit tags for pruning")
|
||||
# parser.add_option("--pkg-filter", metavar="PATTERN", help="limit packages for pruning")
|
||||
parser.add_option("--max-jobs", type="int", default=0, help="limit number of tasks")
|
||||
parser.add_option("--build", help="scan just this build")
|
||||
parser.add_option("-s", "--server", help="url of local XMLRPC server")
|
||||
parser.add_option("-r", "--remote", help="url of remote XMLRPC server")
|
||||
parser.add_option("--prefer-new", action="store_true", default=False,
|
||||
help=_("if there is a newer build locally prefer it for deps"))
|
||||
help="if there is a newer build locally prefer it for deps")
|
||||
parser.add_option("--import-noarch-only", action="store_true", default=False,
|
||||
help=_("Only import missing noarch builds"))
|
||||
help="Only import missing noarch builds")
|
||||
parser.add_option("--import-noarch", action="store_true",
|
||||
help=_("import missing noarch builds rather than rebuilding"))
|
||||
help="import missing noarch builds rather than rebuilding")
|
||||
parser.add_option("--link-imports", action="store_true",
|
||||
help=_("use 'import --link' functionality"))
|
||||
parser.add_option("--remote-topurl",
|
||||
help=_("topurl for remote server"))
|
||||
help="use 'import --link' functionality")
|
||||
parser.add_option("--remote-topurl", help="topurl for remote server")
|
||||
parser.add_option("--workpath", default="/var/tmp/koji-shadow",
|
||||
help=_("location to store work files"))
|
||||
parser.add_option("--auth-cert",
|
||||
help=_("Certificate for authentication"))
|
||||
help="location to store work files")
|
||||
parser.add_option("--auth-cert", help="Certificate for authentication")
|
||||
parser.add_option("--auth-ca", # DEPRECATED and ignored
|
||||
help=optparse.SUPPRESS_HELP)
|
||||
parser.add_option("--serverca",
|
||||
help=_("Server CA certificate"))
|
||||
parser.add_option("--rules",
|
||||
help=_("rules"))
|
||||
parser.add_option("--rules-greylist",
|
||||
help=_("greylist rules"))
|
||||
parser.add_option("--rules-blacklist",
|
||||
help=_("blacklist rules"))
|
||||
parser.add_option("--rules-ignorelist",
|
||||
help=_("Rules: list of packages to ignore"))
|
||||
help="Server CA certificate")
|
||||
parser.add_option("--rules", help="rules")
|
||||
parser.add_option("--rules-greylist", help="greylist rules")
|
||||
parser.add_option("--rules-blacklist", help="blacklist rules")
|
||||
parser.add_option("--rules-ignorelist", help="Rules: list of packages to ignore")
|
||||
parser.add_option("--rules-excludelist",
|
||||
help=_("Rules: list of packages to are excluded using ExcludeArch or "
|
||||
"ExclusiveArch"))
|
||||
parser.add_option("--rules-includelist",
|
||||
help=_("Rules: list of packages to always include"))
|
||||
parser.add_option("--rules-protectlist",
|
||||
help=_("Rules: list of package names to never replace"))
|
||||
help="Rules: list of packages to are excluded using ExcludeArch or "
|
||||
"ExclusiveArch")
|
||||
parser.add_option("--rules-includelist", help="Rules: list of packages to always include")
|
||||
parser.add_option("--rules-protectlist", help="Rules: list of package names to never replace")
|
||||
parser.add_option("--tag-build", action="store_true", default=False,
|
||||
help=_("tag successful builds into the tag we are building, default is to "
|
||||
"not tag"))
|
||||
parser.add_option("--logfile",
|
||||
help=_("file where everything gets logged"))
|
||||
parser.add_option("--arches",
|
||||
help=_("arches to use when creating tags"))
|
||||
help="tag successful builds into the tag we are building, default is to "
|
||||
"not tag")
|
||||
parser.add_option("--logfile", help="file where everything gets logged")
|
||||
parser.add_option("--arches", help="arches to use when creating tags")
|
||||
parser.add_option("--priority", type="int", default=5,
|
||||
help=_("priority to set for submitted builds"))
|
||||
help="priority to set for submitted builds")
|
||||
|
||||
# parse once to get the config file
|
||||
(options, args) = parser.parse_args()
|
||||
|
|
@ -263,10 +241,10 @@ def ensure_connection(session):
|
|||
try:
|
||||
ret = session.getAPIVersion()
|
||||
except requests.exceptions.ConnectionError:
|
||||
error(_("Error: Unable to connect to server"))
|
||||
error("Error: Unable to connect to server")
|
||||
if ret != koji.API_VERSION:
|
||||
warn(_("WARNING: The server is at API version %d and the client is at "
|
||||
"%d" % (ret, koji.API_VERSION)))
|
||||
warn("WARNING: The server is at API version %d and the client is at "
|
||||
"%d" % (ret, koji.API_VERSION))
|
||||
|
||||
|
||||
def activate_session(session):
|
||||
|
|
@ -295,7 +273,7 @@ def activate_session(session):
|
|||
else:
|
||||
session.gssapi_login(proxyuser=options.runas)
|
||||
if not options.noauth and not session.logged_in:
|
||||
error(_("Error: unable to log in"))
|
||||
error("Error: unable to log in")
|
||||
ensure_connection(session)
|
||||
if options.debug:
|
||||
log("successfully connected to hub")
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import os
|
|||
import xmlrpc
|
||||
|
||||
import koji
|
||||
from koji import _
|
||||
|
||||
|
||||
def error(msg=None, code=1):
|
||||
|
|
@ -27,36 +26,33 @@ def warn(msg):
|
|||
|
||||
def get_options():
|
||||
"""process options from command line and config file"""
|
||||
parser = optparse.OptionParser(usage=_("%prog [options]"))
|
||||
parser.add_option("-c", "--config", metavar="FILE",
|
||||
help=_("use alternate config file"))
|
||||
parser.add_option("-s", "--server", help=_("url of koji XMLRPC server"))
|
||||
parser.add_option("--keytab", help=_("specify a Kerberos keytab to use"))
|
||||
parser.add_option("--principal", help=_("specify a Kerberos principal to use"))
|
||||
parser = optparse.OptionParser(usage="%prog [options]")
|
||||
parser.add_option("-c", "--config", metavar="FILE", help="use alternate config file")
|
||||
parser.add_option("-s", "--server", help="url of koji XMLRPC server")
|
||||
parser.add_option("--keytab", help="specify a Kerberos keytab to use")
|
||||
parser.add_option("--principal", help="specify a Kerberos principal to use")
|
||||
parser.add_option("--runas", metavar="USER",
|
||||
help=_("run as the specified user (requires special privileges)"))
|
||||
parser.add_option("--user", help=_("specify user"))
|
||||
parser.add_option("--password", help=_("specify password"))
|
||||
parser.add_option("--noauth", action="store_true", default=False,
|
||||
help=_("do not authenticate"))
|
||||
parser.add_option("--cert", help=_("Client SSL certificate file for authentication"))
|
||||
parser.add_option("--serverca", help=_("CA cert file that issued the hub certificate"))
|
||||
help="run as the specified user (requires special privileges)")
|
||||
parser.add_option("--user", help="specify user")
|
||||
parser.add_option("--password", help="specify password")
|
||||
parser.add_option("--noauth", action="store_true", default=False, help="do not authenticate")
|
||||
parser.add_option("--cert", help="Client SSL certificate file for authentication")
|
||||
parser.add_option("--serverca", help="CA cert file that issued the hub certificate")
|
||||
parser.add_option("-d", "--debug", action="store_true", default=False,
|
||||
help=_("show debug output"))
|
||||
help="show debug output")
|
||||
parser.add_option("--debug-xmlrpc", action="store_true", default=False,
|
||||
help=_("show xmlrpc debug output"))
|
||||
parser.add_option("-t", "--test", action="store_true",
|
||||
help=_("test mode, no tag is deleted"))
|
||||
help="show xmlrpc debug output")
|
||||
parser.add_option("-t", "--test", action="store_true", help="test mode, no tag is deleted")
|
||||
parser.add_option("--no-empty", action="store_false", dest="clean_empty", default=True,
|
||||
help=_("don't run emptiness check"))
|
||||
help="don't run emptiness check")
|
||||
parser.add_option("--empty-delay", action="store", metavar="DAYS", default=1, type=int,
|
||||
help=_("delete empty tags older than DAYS"))
|
||||
help="delete empty tags older than DAYS")
|
||||
parser.add_option("--no-old", action="store_false", dest="clean_old", default=True,
|
||||
help=_("don't run old check"))
|
||||
help="don't run old check")
|
||||
parser.add_option("--old-delay", action="store", metavar="DAYS", default=30, type=int,
|
||||
help=_("delete older tags than timestamp"))
|
||||
help="delete older tags than timestamp")
|
||||
parser.add_option("--ignore-tags", metavar="PATTERN", action="append",
|
||||
help=_("Ignore tags matching PATTERN when pruning"))
|
||||
help="Ignore tags matching PATTERN when pruning")
|
||||
# parse once to get the config file
|
||||
(options, args) = parser.parse_args()
|
||||
|
||||
|
|
@ -66,7 +62,7 @@ def get_options():
|
|||
cf = getattr(options, 'config', None)
|
||||
if cf:
|
||||
if not os.access(cf, os.F_OK):
|
||||
parser.error(_("No such file: %s") % cf)
|
||||
parser.error("No such file: %s" % cf)
|
||||
assert False # pragma: no cover
|
||||
else:
|
||||
cf = '/etc/koji-gc/koji-gc.conf'
|
||||
|
|
@ -125,10 +121,9 @@ def ensure_connection(session):
|
|||
try:
|
||||
ret = session.getAPIVersion()
|
||||
except xmlrpc.client.ProtocolError:
|
||||
error(_("Unable to connect to server"))
|
||||
error("Unable to connect to server")
|
||||
if ret != koji.API_VERSION:
|
||||
warn(_("The server is at API version %d and the client is at %d" %
|
||||
(ret, koji.API_VERSION)))
|
||||
warn("The server is at API version %d and the client is at %d" % (ret, koji.API_VERSION))
|
||||
|
||||
|
||||
def activate_session(session):
|
||||
|
|
@ -153,9 +148,9 @@ def activate_session(session):
|
|||
else:
|
||||
session.gssapi_login(proxyuser=options.runas)
|
||||
except Exception as e:
|
||||
error(_("GSSAPI authentication failed: %s (%s)") % (e.args[1], e.args[0]))
|
||||
error("GSSAPI authentication failed: %s (%s)" % (e.args[1], e.args[0]))
|
||||
if not options.noauth and not session.logged_in:
|
||||
error(_("unable to log in, no authentication methods available"))
|
||||
error("unable to log in, no authentication methods available")
|
||||
ensure_connection(session)
|
||||
if options.debug:
|
||||
print("successfully connected to hub")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue