#1785 unify return values for permission denied
Merged 2 years ago by tkopecek. Opened 2 years ago by tkopecek.
tkopecek/koji issue1784  into  master

file modified
+224 -493
@@ -41,7 +41,7 @@ 

          arg_filter, linked_upload, list_task_output_all_volumes, \

          print_task_headers, print_task_recurse, download_file, watch_logs, \

          error, warn, greetings, _list_tasks, unique_path, \

-         format_inheritance_flags

+         format_inheritance_flags, get_usage_str

  

  

  def _printable_unicode(s):
@@ -54,19 +54,16 @@ 

  def handle_add_group(goptions, session, args):

      "[admin] Add a group to a tag"

      usage = _("usage: %prog add-group <tag> <group>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Please specify a tag name and a group name"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

  

      activate_session(session, goptions)

      if not (session.hasPerm('admin') or session.hasPerm('tag')):

-         print("This action requires tag or admin privileges")

-         return 1

+         parser.error(_("This action requires tag or admin privileges"))

  

      dsttag = session.getTag(tag)

      if not dsttag:
@@ -85,19 +82,16 @@ 

  def handle_block_group(goptions, session, args):

      "[admin] Block group in tag"

      usage = _("usage: %prog block-group <tag> <group>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Please specify a tag name and a group name"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

  

      activate_session(session, goptions)

      if not (session.hasPerm('admin') or session.hasPerm('tag')):

-         print("This action requires tag or admin privileges")

-         return 1

+         parser.error(_("This action requires tag or admin privileges"))

  

      dsttag = session.getTag(tag)

      if not dsttag:
@@ -116,18 +110,16 @@ 

  def handle_remove_group(goptions, session, args):

      "[admin] Remove group from tag"

      usage = _("usage: %prog remove-group <tag> <group>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Please specify a tag name and a group name"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

  

      activate_session(session, goptions)

-     if not session.hasPerm('admin'):

-         error(_("This action requires admin privileges"))

+     if not (session.hasPerm('admin') or session.hasPerm('tag')):

+         parser.error(_("This action requires tag or admin privileges"))

  

      dsttag = session.getTag(tag)

      if not dsttag:
@@ -143,9 +135,8 @@ 

  

  def handle_assign_task(goptions, session, args):

      "[admin] Assign a task to a host"

-     usage = _('usage: %prog assign-task task_id hostname')

-     usage += _('\n(Specify the --help global option for a list of other help options)')

-     parser = OptionParser(usage=usage)

+     usage = _('usage: %prog assign-task <task_id> <hostname>')

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option('-f', '--force', action='store_true', default=False,

                            help=_('force to assign a non-free task'))

      (options, args) = parser.parse_args(args)
@@ -158,11 +149,11 @@ 

  

      taskinfo = session.getTaskInfo(task_id, request=False)

      if taskinfo is None:

-         raise koji.GenericError("No such task: %s" % task_id)

+         raise koji.GenericError(_("No such task: %s") % task_id)

  

      hostinfo = session.getHost(hostname)

      if hostinfo is None:

-         raise koji.GenericError("No such host: %s" % hostname)

+         raise koji.GenericError(_("No such host: %s") % hostname)

  

      force = False

      if options.force:
@@ -170,8 +161,7 @@ 

  

      activate_session(session, goptions)

      if not session.hasPerm('admin'):

-         print("This action requires admin privileges")

-         return 1

+         parser.error(_("This action requires admin privileges"))

  

      ret = session.assignTask(task_id, hostname, force)

      if ret:
@@ -182,14 +172,12 @@ 

  

  def handle_add_host(goptions, session, args):

      "[admin] Add a host"

-     usage = _("usage: %prog add-host [options] hostname arch [arch2 ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-host [options] <hostname> <arch> [<arch> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--krb-principal", help=_("set a non-default kerberos principal for the host"))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify a hostname and at least one arch"))

-         assert False  # pragma: no cover

      host = args[0]

      activate_session(session, goptions)

      id = session.getHost(host)
@@ -207,9 +195,8 @@ 

  

  def handle_edit_host(options, session, args):

      "[admin] Edit a host"

-     usage = _("usage: %prog edit-host hostname ... [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog edit-host <hostname> [<hostname> ...] [options]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--arches", help=_("Space or comma-separated list of supported architectures"))

      parser.add_option("--capacity", type="float", help=_("Capacity of this host"))

      parser.add_option("--description", metavar="DESC", help=_("Description of this host"))
@@ -252,15 +239,13 @@ 

  

  def handle_add_host_to_channel(goptions, session, args):

      "[admin] Add a host to a channel"

-     usage = _("usage: %prog add-host-to-channel [options] hostname channel")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-host-to-channel [options] <hostname> <channel>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--list", action="store_true", help=SUPPRESS_HELP)

      parser.add_option("--new", action="store_true", help=_("Create channel if needed"))

      (options, args) = parser.parse_args(args)

      if not options.list and len(args) != 2:

          parser.error(_("Please specify a hostname and a channel"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      if options.list:

          for channel in session.listChannels():
@@ -285,13 +270,11 @@ 

  

  def handle_remove_host_from_channel(goptions, session, args):

      "[admin] Remove a host from a channel"

-     usage = _("usage: %prog remove-host-from-channel [options] hostname channel")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog remove-host-from-channel [options] <hostname> <channel>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Please specify a hostname and a channel"))

-         assert False  # pragma: no cover

      host = args[0]

      activate_session(session, goptions)

      hostinfo = session.getHost(host)
@@ -310,14 +293,12 @@ 

  

  def handle_remove_channel(goptions, session, args):

      "[admin] Remove a channel entirely"

-     usage = _("usage: %prog remove-channel [options] channel")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog remove-channel [options] <channel>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--force", action="store_true", help=_("force removal, if possible"))

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      cinfo = session.getChannel(args[0])

      if not cinfo:
@@ -328,13 +309,11 @@ 

  

  def handle_rename_channel(goptions, session, args):

      "[admin] Rename a channel"

-     usage = _("usage: %prog rename-channel [options] old-name new-name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog rename-channel [options] <old-name> <new-name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      cinfo = session.getChannel(args[0])

      if not cinfo:
@@ -345,19 +324,16 @@ 

  

  def handle_add_pkg(goptions, session, args):

      "[admin] Add a package to the listing for tag"

-     usage = _("usage: %prog add-pkg [options] tag package [package2 ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-pkg [options] <tag> <package> [<package> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--force", action='store_true', help=_("Override blocks if necessary"))

      parser.add_option("--owner", help=_("Specify owner"))

      parser.add_option("--extra-arches", help=_("Specify extra arches"))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify a tag and at least one package"))

-         assert False  # pragma: no cover

      if not options.owner:

          parser.error(_("Please specify an owner for the package(s)"))

-         assert False  # pragma: no cover

      if not session.getUser(options.owner):

          print("User %s does not exist" % options.owner)

          return 1
@@ -392,14 +368,12 @@ 

  

  def handle_block_pkg(goptions, session, args):

      "[admin] Block a package in the listing for tag"

-     usage = _("usage: %prog block-pkg [options] tag package [package2 ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog block-pkg [options] <tag> <package> [<package> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--force", action='store_true', default=False, help=_("Override blocks and owner if necessary"))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify a tag and at least one package"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      tag = args[0]

      # check if list of packages exists for that tag already
@@ -429,14 +403,12 @@ 

  

  def handle_remove_pkg(goptions, session, args):

      "[admin] Remove a package from the listing for tag"

-     usage = _("usage: %prog remove-pkg [options] tag package [package2 ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog remove-pkg [options] <tag> <package> [<package> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--force", action='store_true', help=_("Override blocks if necessary"))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify a tag and at least one package"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      tag = args[0]

      opts = {}
@@ -463,9 +435,8 @@ 

  

  def handle_build(options, session, args):

      "[build] Build a package from source"

-     usage = _("usage: %prog build [options] target <srpm path or scm url>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog build [options] <target> <srpm path or scm url>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--skip-tag", action="store_true",

                        help=_("Do not attempt to tag package"))

      parser.add_option("--scratch", action="store_true",
@@ -487,7 +458,6 @@ 

      (build_opts, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Exactly two arguments (a build target and a SCM URL or srpm file) are required"))

-         assert False  # pragma: no cover

      if build_opts.arch_override and not build_opts.scratch:

          parser.error(_("--arch_override is only allowed for --scratch builds"))

      activate_session(session, options)
@@ -544,9 +514,8 @@ 

  def handle_chain_build(options, session, args):

      # XXX - replace handle_build with this, once chain-building has gotten testing

      "[build] Build one or more packages from source"

-     usage = _("usage: %prog chain-build [options] target URL [URL2 [:] URL3 [:] URL4 ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog chain-build [options] <target> <URL> [<URL> [:] <URL> [:] <URL> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--nowait", action="store_true",

                        help=_("Don't wait on build"))

      parser.add_option("--quiet", action="store_true",
@@ -556,7 +525,6 @@ 

      (build_opts, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("At least two arguments (a build target and a SCM URL) are required"))

-         assert False  # pragma: no cover

      activate_session(session, options)

      target = args[0]

      build_target = session.getBuildTarget(target)
@@ -620,10 +588,9 @@ 

  

  def handle_maven_build(options, session, args):

      "[build] Build a Maven package from source"

-     usage = _("usage: %prog maven-build [options] target URL")

-     usage += _("\n       %prog maven-build --ini=CONFIG... [options] target")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog maven-build [options] <target> <URL>")

+     usage += _("\n       %prog maven-build --ini=CONFIG... [options] <target>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--patches", action="store", metavar="URL",

                        help=_("SCM URL of a directory containing patches to apply to the sources before building"))

      parser.add_option("-G", "--goal", action="append",
@@ -720,9 +687,8 @@ 

  

  def handle_wrapper_rpm(options, session, args):

      """[build] Build wrapper rpms for any archives associated with a build."""

-     usage = _("usage: %prog wrapper-rpm [options] target build-id|n-v-r URL")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog wrapper-rpm [options] <target> <build-id|n-v-r> <URL>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--create-build", action="store_true", help=_("Create a new build to contain wrapper rpms"))

      parser.add_option("--ini", action="append",

                        dest="inis", metavar="CONFIG", default=[],
@@ -788,9 +754,8 @@ 

  

  def handle_maven_chain(options, session, args):

      "[build] Run a set of Maven builds in dependency order"

-     usage = _("usage: %prog maven-chain [options] target config...")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog maven-chain [options] <target> <config> [<config> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--skip-tag", action="store_true",

                        help=_("Do not attempt to tag builds"))

      parser.add_option("--scratch", action="store_true",
@@ -806,7 +771,6 @@ 

      (build_opts, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Two arguments (a build target and a config file) are required"))

-         assert False  # pragma: no cover

      activate_session(session, options)

      target = args[0]

      build_target = session.getBuildTarget(target)
@@ -842,9 +806,8 @@ 

  

  def handle_resubmit(goptions, session, args):

      """[build] Retry a canceled or failed task, using the same parameter as the original task."""

-     usage = _("usage: %prog resubmit [options] taskID")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog resubmit [options] <task_id>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--nowait", action="store_true", help=_("Don't wait on task"))

      parser.add_option("--nowatch", action="store_true", dest="nowait",

              help=_("An alias for --nowait"))
@@ -853,7 +816,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("Please specify a single task ID"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      taskID = int(args[0])

      if not options.quiet:
@@ -872,16 +834,14 @@ 

  

  def handle_call(goptions, session, args):

      "Execute an arbitrary XML-RPC call"

-     usage = _("usage: %prog call [options] name [arg...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog call [options] <name> [<arg> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--python", action="store_true", help=_("Use python syntax for values"))

      parser.add_option("--kwargs", help=_("Specify keyword arguments as a dictionary (implies --python)"))

      parser.add_option("--json-output", action="store_true", help=_("Use JSON syntax for output"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("Please specify the name of the XML-RPC method"))

-         assert False  # pragma: no cover

      if options.kwargs:

          options.python = True

      if options.python and ast is None:
@@ -913,8 +873,7 @@ 

  def anon_handle_mock_config(goptions, session, args):

      "[info] Create a mock config"

      usage = _("usage: %prog mock-config [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("-a", "--arch", help=_("Specify the arch"))

      parser.add_option("-n", "--name", help=_("Specify the name for the buildroot"))

      parser.add_option("--tag", help=_("Create a mock config for a tag"))
@@ -1017,7 +976,6 @@ 

              opts['repoid'] = repo['id']

      else:

          parser.error(_("Please specify one of: --tag, --target, --task, --buildroot"))

-         assert False  # pragma: no cover

      if options.name:

          name = options.name

      else:
@@ -1042,9 +1000,8 @@ 

  

  def handle_disable_host(goptions, session, args):

      "[admin] Mark one or more hosts as disabled"

-     usage = _("usage: %prog disable-host [options] hostname ...")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog disable-host [options] <hostname> [<hostname> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--comment", help=_("Comment indicating why the host(s) are being disabled"))

      (options, args) = parser.parse_args(args)

  
@@ -1073,9 +1030,8 @@ 

  

  def handle_enable_host(goptions, session, args):

      "[admin] Mark one or more hosts as enabled"

-     usage = _("usage: %prog enable-host [options] hostname ...")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog enable-host [options] <hostname> [<hostname> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--comment", help=_("Comment indicating why the host(s) are being enabled"))

      (options, args) = parser.parse_args(args)

  
@@ -1105,8 +1061,7 @@ 

  def handle_restart_hosts(options, session, args):

      "[admin] Restart enabled hosts"

      usage = _("usage: %prog restart-hosts [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--wait", action="store_true",

                        help=_("Wait on the task, even if running in the background"))

      parser.add_option("--nowait", action="store_false", dest="wait",
@@ -1125,7 +1080,6 @@ 

  

      if len(args) > 0:

          parser.error(_("restart-hosts does not accept arguments"))

-         assert False  # pragma: no cover

  

      activate_session(session, options)

  
@@ -1165,9 +1119,8 @@ 

  

  def handle_import(goptions, session, args):

      "[admin] Import externally built RPMs into the database"

-     usage = _("usage: %prog import [options] package [package...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog import [options] <package> [<package> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--link", action="store_true", help=_("Attempt to hardlink instead of uploading"))

      parser.add_option("--test", action="store_true", help=_("Don't actually import"))

      parser.add_option("--create-build", action="store_true", help=_("Auto-create builds as needed"))
@@ -1175,7 +1128,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("At least one package must be specified"))

-         assert False  # pragma: no cover

      if options.src_epoch in ('None', 'none', '(none)'):

          options.src_epoch = None

      elif options.src_epoch:
@@ -1183,7 +1135,6 @@ 

              options.src_epoch = int(options.src_epoch)

          except (ValueError, TypeError):

              parser.error(_("Invalid value for epoch: %s") % options.src_epoch)

-             assert False  # pragma: no cover

      activate_session(session, goptions)

      to_import = {}

      for path in args:
@@ -1315,9 +1266,8 @@ 

  

  def handle_import_cg(goptions, session, args):

      "[admin] Import external builds with rich metadata"

-     usage = _("usage: %prog import-cg [options] metadata_file files_dir")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog import-cg [options] <metadata_file> <files_dir>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--noprogress", action="store_true",

                        help=_("Do not display progress of the upload"))

      parser.add_option("--link", action="store_true", help=_("Attempt to hardlink instead of uploading"))
@@ -1326,10 +1276,8 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify metadata files directory"))

-         assert False  # pragma: no cover

      if json is None:

          parser.error(_("Unable to find json module"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      metadata = json.load(open(args[0], 'r'))

      if 'output' not in metadata:
@@ -1373,13 +1321,11 @@ 

  def handle_import_comps(goptions, session, args):

      "Import group/package information from a comps file"

      usage = _("usage: %prog import-comps [options] <file> <tag>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--force", action="store_true", help=_("force import"))

      (local_options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      # check if the tag exists

      dsttag = session.getTag(args[1])
@@ -1467,9 +1413,8 @@ 

  

  def handle_import_sig(goptions, session, args):

      "[admin] Import signatures into the database"

-     usage = _("usage: %prog import-sig [options] package [package...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog import-sig [options] <package> [<package> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--with-unsigned", action="store_true",

                        help=_("Also import unsigned sig headers"))

      parser.add_option("--write", action="store_true",
@@ -1479,7 +1424,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("At least one package must be specified"))

-         assert False  # pragma: no cover

      for path in args:

          if not os.path.exists(path):

              parser.error(_("No such file: %s") % path)
@@ -1530,18 +1474,15 @@ 

  

  def handle_write_signed_rpm(goptions, session, args):

      "[admin] Write signed RPMs to disk"

-     usage = _("usage: %prog write-signed-rpm [options] <signature-key> n-v-r [n-v-r...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog write-signed-rpm [options] <signature-key> <n-v-r> [<n-v-r> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--all", action="store_true", help=_("Write out all RPMs signed with this key"))

      parser.add_option("--buildid", help=_("Specify a build id rather than an n-v-r"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("A signature key must be specified"))

-         assert False  # pragma: no cover

      if len(args) < 2 and not (options.all or options.buildid):

          parser.error(_("At least one RPM must be specified"))

-         assert False  # pragma: no cover

      key = args.pop(0)

      activate_session(session, goptions)

      if options.all:
@@ -1575,8 +1516,7 @@ 

  def handle_prune_signed_copies(options, session, args):

      "[admin] Prune signed copies"

      usage = _("usage: %prog prune-sigs [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("-n", "--test", action="store_true", help=_("Test mode"))

      parser.add_option("-v", "--verbose", action="store_true", help=_("Be more verbose"))

      parser.add_option("--days", type="int", default=5, help=_("Timeout before clearing"))
@@ -1643,7 +1583,6 @@ 

          binfo = session.getBuild(options.build)

          if not binfo:

              parser.error('No such build: %s' % options.build)

-             assert False  # pragma: no cover

          builds = [("%(name)s-%(version)s-%(release)s" % binfo, binfo)]

      total_files = 0

      total_space = 0
@@ -1923,13 +1862,12 @@ 

  

  def handle_set_build_volume(goptions, session, args):

      "[admin] Move a build to a different volume"

-     usage = _("usage: %prog set-build-volume volume n-v-r [n-v-r ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog set-build-volume <volume> <n-v-r> [<n-v-r> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("-v", "--verbose", action="store_true", help=_("Be verbose"))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

-         parser.error("You must provide a volume and at least one build")

+         parser.error(_("You must provide a volume and at least one build"))

      volinfo = session.getVolume(args[0])

      if not volinfo:

          print("No such volume: %s" % args[0])
@@ -1955,12 +1893,11 @@ 

  

  def handle_add_volume(goptions, session, args):

      "[admin] Add a new storage volume"

-     usage = _("usage: %prog add-volume volume-name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-volume <volume-name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

-         parser.error("Command requires exactly one volume-name.")

+         parser.error(_("Command requires exactly one volume-name."))

      name = args[0]

      volinfo = session.getVolume(name)

      if volinfo:
@@ -1974,8 +1911,7 @@ 

  def handle_list_volumes(options, session, args):

      "[info] List storage volumes"

      usage = _("usage: %prog list-volumes")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      for volinfo in session.listVolumes():

          print(volinfo['name'])
@@ -1984,14 +1920,12 @@ 

  def handle_list_permissions(goptions, session, args):

      "[info] List user permissions"

      usage = _("usage: %prog list-permissions [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--user", help=_("List permissions for the given user"))

      parser.add_option("--mine", action="store_true", help=_("List your permissions"))

      (options, args) = parser.parse_args(args)

      if len(args) > 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      if options.user:

          user = session.getUser(options.user)
@@ -2009,9 +1943,8 @@ 

  

  def handle_add_user(goptions, session, args):

      "[admin] Add a user"

-     usage = _("usage: %prog add-user username [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-user <username> [options]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--principal", help=_("The Kerberos principal for this user"))

      parser.add_option("--disable", help=_("Prohibit logins by this user"), action="store_true")

      (options, args) = parser.parse_args(args)
@@ -2031,9 +1964,8 @@ 

  

  def handle_enable_user(goptions, session, args):

      "[admin] Enable logins by a user"

-     usage = _("usage: %prog enable-user username")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog enable-user <username>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("You must specify the username of the user to enable"))
@@ -2046,9 +1978,8 @@ 

  

  def handle_disable_user(goptions, session, args):

      "[admin] Disable logins by a user"

-     usage = _("usage: %prog disable-user username")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog disable-user <username>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("You must specify the username of the user to disable"))
@@ -2061,9 +1992,8 @@ 

  

  def handle_edit_user(goptions, session, args):

      "[admin] Alter user information"

-     usage = _("usage: %prog edit-user name [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog edit-user <username> [options]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--rename", help=_("Rename the user"))

      parser.add_option("--edit-krb", action="append", default=[],

                        metavar="OLD=NEW",
@@ -2094,8 +2024,7 @@ 

  def handle_list_signed(goptions, session, args):

      "[admin] List signed copies of rpms"

      usage = _("usage: %prog list-signed [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--debug", action="store_true")

      parser.add_option("--key", help=_("Only list RPMs signed with this key"))

      parser.add_option("--build", help=_("Only list RPMs from this build"))
@@ -2165,9 +2094,8 @@ 

  

  def handle_import_archive(options, session, args):

      "[admin] Import an archive file and associate it with a build"

-     usage = _("usage: %prog import-archive build-id|n-v-r /path/to/archive...")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog import-archive <build-id|n-v-r> <archive_path> [<archive_path2 ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--noprogress", action="store_true",

                        help=_("Do not display progress of the upload"))

      parser.add_option("--create-build", action="store_true", help=_("Auto-create builds as needed"))
@@ -2181,30 +2109,24 @@ 

  

      if not len(args) > 1:

          parser.error(_("You must specify a build ID or N-V-R and an archive to import"))

-         assert False  # pragma: no cover

  

      activate_session(session, options)

  

      if not suboptions.type:

          parser.error(_("You must specify an archive type"))

-         assert False  # pragma: no cover

      if suboptions.type == 'maven':

          if not (session.hasPerm('maven-import') or session.hasPerm('admin')):

              parser.error(_("This action requires the maven-import privilege"))

-             assert False  # pragma: no cover

          if not suboptions.type_info:

              parser.error(_("--type-info must point to a .pom file when importing Maven archives"))

-             assert False  # pragma: no cover

          pom_info = koji.parse_pom(suboptions.type_info)

          maven_info = koji.pom_to_maven_info(pom_info)

          suboptions.type_info = maven_info

      elif suboptions.type == 'win':

          if not (session.hasPerm('win-import') or session.hasPerm('admin')):

              parser.error(_("This action requires the win-import privilege"))

-             assert False  # pragma: no cover

          if not suboptions.type_info:

              parser.error(_("--type-info must be specified"))

-             assert False  # pragma: no cover

          type_info = suboptions.type_info.split(':', 2)

          if len(type_info) < 2:

              parser.error(_("--type-info must be in relpath:platforms[:flags] format"))
@@ -2217,15 +2139,12 @@ 

      elif suboptions.type == 'image':

          if not (session.hasPerm('image-import') or session.hasPerm('admin')):

              parser.error(_("This action requires the image-import privilege"))

-             assert False  # pragma: no cover

          if not suboptions.type_info:

              parser.error(_("--type-info must be specified"))

-             assert False  # pragma: no cover

          image_info = {'arch': suboptions.type_info}

          suboptions.type_info = image_info

      else:

          parser.error(_("Unsupported archive type: %s" % suboptions.type))

-         assert False  # pragma: no cover

  

      buildinfo = session.getBuild(arg_filter(args[0]))

      if not buildinfo:
@@ -2271,13 +2190,11 @@ 

  def handle_grant_permission(goptions, session, args):

      "[admin] Grant a permission to a user"

      usage = _("usage: %prog grant-permission <permission> <user> [<user> ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--new", action="store_true", help=_("Create a new permission"))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify a permission and at least one user"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      perm = args[0]

      names = args[1:]
@@ -2286,7 +2203,6 @@ 

          user = session.getUser(n)

          if user is None:

              parser.error(_("No such user: %s" % n))

-             assert False  # pragma: no cover

          users.append(user)

      kwargs = {}

      if options.new:
@@ -2298,12 +2214,10 @@ 

  def handle_revoke_permission(goptions, session, args):

      "[admin] Revoke a permission from a user"

      usage = _("usage: %prog revoke-permission <permission> <user> [<user> ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify a permission and at least one user"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      perm = args[0]

      names = args[1:]
@@ -2312,7 +2226,6 @@ 

          user = session.getUser(n)

          if user is None:

              parser.error(_("No such user: %s" % n))

-             assert False  # pragma: no cover

          users.append(user)

      for user in users:

          session.revokePermission(user['name'], perm)
@@ -2321,20 +2234,17 @@ 

  def handle_grant_cg_access(goptions, session, args):

      "[admin] Add a user to a content generator"

      usage = _("usage: %prog grant-cg-access <user> <content generator>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--new", action="store_true", help=_("Create a new content generator"))

      (options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Please specify a user and content generator"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      user = args[0]

      cg = args[1]

      uinfo = session.getUser(user)

      if uinfo is None:

          parser.error(_("No such user: %s" % user))

-         assert False  # pragma: no cover

      kwargs = {}

      if options.new:

          kwargs['create'] = True
@@ -2344,27 +2254,23 @@ 

  def handle_revoke_cg_access(goptions, session, args):

      "[admin] Remove a user from a content generator"

      usage = _("usage: %prog revoke-cg-access <user> <content generator>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 2:

          parser.error(_("Please specify a user and content generator"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      user = args[0]

      cg = args[1]

      uinfo = session.getUser(user)

      if uinfo is None:

          parser.error(_("No such user: %s" % user))

-         assert False  # pragma: no cover

      session.revokeCGAccess(uinfo['name'], cg)

  

  

  def anon_handle_latest_build(goptions, session, args):

      "[info] Print the latest builds for a tag"

-     usage = _("usage: %prog latest-build [options] tag package [package...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog latest-build [options] <tag> <package> [<package> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--arch", help=_("List all of the latest packages for this arch"))

      parser.add_option("--all", action="store_true", help=_("List all of the latest packages for this tag"))

      parser.add_option("--quiet", action="store_true", default=goptions.quiet,
@@ -2374,18 +2280,15 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) == 0:

          parser.error(_("A tag name must be specified"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      if options.all:

          if len(args) > 1:

              parser.error(_("A package name may not be combined with --all"))

-             assert False  # pragma: no cover

          # Set None as the package argument

          args.append(None)

      else:

          if len(args) < 2:

              parser.error(_("A tag name and package name must be specified"))

-             assert False  # pragma: no cover

      pathinfo = koji.PathInfo()

  

      for pkg in args[1:]:
@@ -2438,12 +2341,10 @@ 

  def anon_handle_list_api(goptions, session, args):

      "[info] Print the list of XML-RPC APIs"

      usage = _("usage: %prog list-api [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      tmplist = [(x['name'], x) for x in session._listapi()]

      tmplist.sort()
@@ -2469,9 +2370,8 @@ 

  

  def anon_handle_list_tagged(goptions, session, args):

      "[info] List the builds or rpms in a tag"

-     usage = _("usage: %prog list-tagged [options] tag [package]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog list-tagged [options] <tag> [<package>]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--arch", action="append", default=[], help=_("List rpms for this arch"))

      parser.add_option("--rpms", action="store_true", help=_("Show rpms instead of builds"))

      parser.add_option("--inherit", action="store_true", help=_("Follow inheritance"))
@@ -2488,10 +2388,8 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) == 0:

          parser.error(_("A tag name must be specified"))

-         assert False  # pragma: no cover

      elif len(args) > 2:

          parser.error(_("Only one package name may be specified"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      pathinfo = koji.PathInfo()

      package = None
@@ -2580,16 +2478,14 @@ 

  

  def anon_handle_list_buildroot(goptions, session, args):

      "[info] List the rpms used in or built in a buildroot"

-     usage = _("usage: %prog list-buildroot [options] buildroot-id")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog list-buildroot [options] <buildroot-id>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--paths", action="store_true", help=_("Show the file paths"))

      parser.add_option("--built", action="store_true", help=_("Show the built rpms"))

      parser.add_option("--verbose", "-v", action="store_true", help=_("Show more information"))

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      buildrootID = int(args[0])

      opts = {}
@@ -2611,15 +2507,13 @@ 

  

  def anon_handle_list_untagged(goptions, session, args):

      "[info] List untagged builds"

-     usage = _("usage: %prog list-untagged [options] [package]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog list-untagged [options] [<package>]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--paths", action="store_true", help=_("Show the file paths"))

      parser.add_option("--show-references", action="store_true", help=_("Show build references"))

      (options, args) = parser.parse_args(args)

      if len(args) > 1:

          parser.error(_("Only one package name may be specified"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      package = None

      if len(args) > 0:
@@ -2675,9 +2569,8 @@ 

  

  def anon_handle_list_groups(goptions, session, args):

      "[info] Print the group listings"

-     usage = _("usage: %prog list-groups [options] <tag> [group]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog list-groups [options] <tag> [<group>]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--event", type='int', metavar="EVENT#", help=_("query at event"))

      parser.add_option("--ts", type='int', metavar="TIMESTAMP", help=_("query at last event before timestamp"))

      parser.add_option("--repo", type='int', metavar="REPO#", help=_("query at event for a repo"))
@@ -2685,7 +2578,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) < 1 or len(args) > 2:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      opts = {}

      if options.incl_blocked:

          opts['incl_blocked'] = True
@@ -2717,13 +2609,11 @@ 

  

  def handle_add_group_pkg(goptions, session, args):

      "[admin] Add a package to a group's package listing"

-     usage = _("usage: %prog add-group-pkg [options] <tag> <group> <pkg> [<pkg>...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-group-pkg [options] <tag> <group> <pkg> [<pkg> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 3:

          parser.error(_("You must specify a tag name, group name, and one or more package names"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

      activate_session(session, goptions)
@@ -2733,15 +2623,13 @@ 

  

  def handle_block_group_pkg(goptions, session, args):

      "[admin] Block a package from a group's package listing"

-     usage = _("usage: %prog block-group-pkg [options] <tag> <group> <pkg> [<pkg>...]")

+     usage = _("usage: %prog block-group-pkg [options] <tag> <group> <pkg> [<pkg> ...]")

      usage += '\n' + _("Note that blocking is propagated through the inheritance chain, so "

                        "it is not exactly the same as package removal.")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 3:

          parser.error(_("You must specify a tag name, group name, and one or more package names"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

      activate_session(session, goptions)
@@ -2751,13 +2639,11 @@ 

  

  def handle_unblock_group_pkg(goptions, session, args):

      "[admin] Unblock a package from a group's package listing"

-     usage = _("usage: %prog unblock-group-pkg [options] <tag> <group> <pkg> [<pkg>...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog unblock-group-pkg [options] <tag> <group> <pkg> [<pkg> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 3:

          parser.error(_("You must specify a tag name, group name, and one or more package names"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

      activate_session(session, goptions)
@@ -2768,12 +2654,10 @@ 

  def handle_add_group_req(goptions, session, args):

      "[admin] Add a group to a group's required list"

      usage = _("usage: %prog add-group-req [options] <tag> <target group> <required group>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 3:

          parser.error(_("You must specify a tag name and two group names"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

      req = args[2]
@@ -2784,12 +2668,10 @@ 

  def handle_block_group_req(goptions, session, args):

      "[admin] Block a group's requirement listing"

      usage = _("usage: %prog block-group-req [options] <tag> <group> <blocked req>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 3:

          parser.error(_("You must specify a tag name and two group names"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

      req = args[2]
@@ -2800,12 +2682,10 @@ 

  def handle_unblock_group_req(goptions, session, args):

      "[admin] Unblock a group's requirement listing"

      usage = _("usage: %prog unblock-group-req [options] <tag> <group> <requirement>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) != 3:

          parser.error(_("You must specify a tag name and two group names"))

-         assert False  # pragma: no cover

      tag = args[0]

      group = args[1]

      req = args[2]
@@ -2816,8 +2696,7 @@ 

  def anon_handle_list_channels(goptions, session, args):

      "[info] Print channels listing"

      usage = _("usage: %prog list-channels")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--simple", action="store_true", default=False,

                  help=_("Print just list of channels without additional info"))

      parser.add_option("--quiet", action="store_true", default=goptions.quiet,
@@ -2854,8 +2733,7 @@ 

  def anon_handle_list_hosts(goptions, session, args):

      "[info] Print the host listing"

      usage = _("usage: %prog list-hosts [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--arch", action="append", default=[], help=_("Specify an architecture"))

      parser.add_option("--channel", help=_("Specify a channel"))

      parser.add_option("--ready", action="store_true", help=_("Limit to ready hosts"))
@@ -2875,7 +2753,6 @@ 

          channel = session.getChannel(options.channel)

          if not channel:

              parser.error(_('Unknown channel: %s' % options.channel))

-             assert False  # pragma: no cover

          opts['channelID'] = channel['id']

      if options.ready is not None:

          opts['ready'] = options.ready
@@ -2931,8 +2808,7 @@ 

  def anon_handle_list_pkgs(goptions, session, args):

      "[info] Print the package listing for tag or for owner"

      usage = _("usage: %prog list-pkgs [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--owner", help=_("Specify owner"))

      parser.add_option("--tag", help=_("Specify tag"))

      parser.add_option("--package", help=_("Specify package"))
@@ -2947,20 +2823,17 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      opts = {}

      if options.owner:

          user = session.getUser(options.owner)

          if user is None:

              parser.error(_("Invalid user"))

-             assert False  # pragma: no cover

          opts['userID'] = user['id']

      if options.tag:

          tag = session.getTag(options.tag)

          if tag is None:

              parser.error(_("Invalid tag"))

-             assert False  # pragma: no cover

          opts['tagID'] = tag['id']

      if options.package:

          opts['pkgID'] = options.package
@@ -3020,8 +2893,7 @@ 

  def anon_handle_list_builds(goptions, session, args):

      "[info] Print the build listing"

      usage = _("usage: %prog list-builds [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--package", help=_("List builds for this package"))

      parser.add_option("--buildid", help=_("List specific build from ID or nvr"))

      parser.add_option("--before",
@@ -3042,7 +2914,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      opts = {}

      for key in ('type', 'prefix'):
@@ -3056,7 +2927,6 @@ 

              package = session.getPackageID(options.package)

              if package is None:

                  parser.error(_("Invalid package"))

-                 assert False  # pragma: no cover

              opts['packageID'] = package

      if options.owner:

          try:
@@ -3065,7 +2935,6 @@ 

              user = session.getUser(options.owner)

              if user is None:

                  parser.error(_("Invalid owner"))

-                 assert False  # pragma: no cover

              opts['userID'] = user['id']

      if options.volume:

          try:
@@ -3078,21 +2947,18 @@ 

                      volumeID = volume['id']

              if volumeID is None:

                  parser.error(_("Invalid volume"))

-                 assert False  # pragma: no cover

              opts['volumeID'] = volumeID

      if options.state:

          try:

              state = int(options.state)

              if state > 4 or state < 0:

                  parser.error(_("Invalid state"))

-                 assert False  # pragma: no cover

              opts['state'] = state

          except ValueError:

              try:

                  opts['state'] = koji.BUILD_STATES[options.state]

              except KeyError:

                  parser.error(_("Invalid state"))

-                 assert False  # pragma: no cover

      for opt in ('before', 'after'):

          val = getattr(options, opt)

          if not val:
@@ -3121,14 +2987,12 @@ 

          data = [session.getBuild(buildid)]

          if data is None:

              parser.error(_("Invalid build ID"))

-             assert False  # pragma: no cover

      else:

          # Check filter exists

          if any(opts):

              data = session.listBuilds(**opts)

          else:

              parser.error(_("Filter must be provided for list"))

-             assert False  # pragma: no cover

      if not options.sort_key:

          options.sort_key = ['nvr']

      data = sorted(data, key=lambda b: [b.get(k) for k in options.sort_key],
@@ -3148,13 +3012,11 @@ 

  def anon_handle_rpminfo(goptions, session, args):

      "[info] Print basic information about an RPM"

      usage = _("usage: %prog rpminfo [options] <n-v-r.a> [<n-v-r.a> ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--buildroots", action="store_true", help=_("show buildroots the rpm was used in"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("Please specify an RPM"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      for rpm in args:

          info = session.getRPM(rpm)
@@ -3217,13 +3079,11 @@ 

  def anon_handle_buildinfo(goptions, session, args):

      "[info] Print basic information about a build"

      usage = _("usage: %prog buildinfo [options] <n-v-r> [<n-v-r> ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--changelog", action="store_true", help=_("Show the changelog for the build"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("Please specify a build"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      for build in args:

          if build.isdigit():
@@ -3310,12 +3170,10 @@ 

  def anon_handle_hostinfo(goptions, session, args):

      "[info] Print basic information about a host"

      usage = _("usage: %prog hostinfo [options] <hostname> [<hostname> ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("Please specify a host"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      for host in args:

          if host.isdigit():
@@ -3370,8 +3228,7 @@ 

      "[admin] Duplicate the contents of one tag onto another tag"

      usage = _("usage: %prog clone-tag [options] <src-tag> <dst-tag>")

      usage += _("\nclone-tag will create the destination tag if it does not already exist")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option('--config', action='store_true',

              help=_("Copy config from the source to the dest tag"))

      parser.add_option('--groups', action='store_true',
@@ -3404,7 +3261,6 @@ 

  

      if len(args) != 2:

          parser.error(_("This command takes two arguments: <src-tag> <dst-tag>"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

  

      if not options.test and not (session.hasPerm('admin') or session.hasPerm('tag')):
@@ -3842,16 +3698,13 @@ 

  

  def handle_add_target(goptions, session, args):

      "[admin] Create a new build target"

-     usage = _("usage: %prog add-target name build-tag <dest-tag>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-target <name> <build tag> <dest tag>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

      if len(args) < 2:

          parser.error(_("Please specify a target name, a build tag, and destination tag"))

-         assert False  # pragma: no cover

      elif len(args) > 3:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      name = args[0]

      build_tag = args[1]

      if len(args) > 2:
@@ -3861,8 +3714,7 @@ 

          dest_tag = name

      activate_session(session, goptions)

      if not (session.hasPerm('admin') or session.hasPerm('target')):

-         print("This action requires target or admin privileges")

-         return 1

+         parser.error(_("This action requires target or admin privileges"))

  

      chkbuildtag = session.getTag(build_tag)

      chkdesttag = session.getTag(dest_tag)
@@ -3881,9 +3733,8 @@ 

  

  def handle_edit_target(goptions, session, args):

      "[admin] Set the name, build_tag, and/or dest_tag of an existing build target to new values"

-     usage = _("usage: %prog edit-target [options] name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog edit-target [options] <name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--rename", help=_("Specify new name for target"))

      parser.add_option("--build-tag", help=_("Specify a different build tag"))

      parser.add_option("--dest-tag", help=_("Specify a different destination tag"))
@@ -3892,12 +3743,10 @@ 

  

      if len(args) != 1:

          parser.error(_("Please specify a build target"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

  

      if not (session.hasPerm('admin') or session.hasPerm('target')):

-         print("This action requires target or admin privileges")

-         return

+         parser.error(_("This action requires target or admin privileges"))

  

      targetInfo = session.getBuildTarget(args[0])

      if targetInfo == None:
@@ -3928,19 +3777,16 @@ 

  

  def handle_remove_target(goptions, session, args):

      "[admin] Remove a build target"

-     usage = _("usage: %prog remove-target [options] name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog remove-target [options] <name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

  

      if len(args) != 1:

          parser.error(_("Please specify a build target to remove"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

  

      if not (session.hasPerm('admin') or session.hasPerm('target')):

-         print("This action requires target or admin privileges")

-         return

+         parser.error(_("This action requires target or admin privileges"))

  

      target = args[0]

      target_info = session.getBuildTarget(target)
@@ -3953,19 +3799,16 @@ 

  

  def handle_remove_tag(goptions, session, args):

      "[admin] Remove a tag"

-     usage = _("usage: %prog remove-tag [options] name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog remove-tag [options] <name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

  

      if len(args) != 1:

          parser.error(_("Please specify a tag to remove"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

  

      if not (session.hasPerm('admin') or session.hasPerm('tag')):

-         print("This action requires tag or admin privileges")

-         return

+         parser.error(_("This action requires tag or admin privileges"))

  

      tag = args[0]

      tag_info = session.getTag(tag)
@@ -3979,15 +3822,13 @@ 

  def anon_handle_list_targets(goptions, session, args):

      "[info] List the build targets"

      usage = _("usage: %prog list-targets [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--name", help=_("Specify the build target name"))

      parser.add_option("--quiet", action="store_true", default=goptions.quiet,

                  help=_("Do not print the header information"))

      (options, args) = parser.parse_args(args)

      if len(args) != 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

  

      fmt = "%(name)-30s %(build_tag_name)-30s %(dest_tag_name)-30s"
@@ -4047,8 +3888,7 @@ 

  def anon_handle_list_tag_inheritance(goptions, session, args):

      "[info] Print the inheritance information for a tag"

      usage = _("usage: %prog list-tag-inheritance [options] <tag>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--reverse", action="store_true", help=_("Process tag's children instead of its parents"))

      parser.add_option("--stop", help=_("Stop processing inheritance at this tag"))

      parser.add_option("--jump", help=_("Jump from one tag to another when processing inheritance"))
@@ -4058,7 +3898,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("This command takes exctly one argument: a tag name or ID"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      event = koji.util.eventFromOpts(session, options)

      if event:
@@ -4103,8 +3942,7 @@ 

  def anon_handle_list_tags(goptions, session, args):

      "[info] Print the list of tags"

      usage = _("usage: %prog list-tags [options] [pattern]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--show-id", action="store_true", help=_("Show tag ids"))

      parser.add_option("--verbose", action="store_true", help=_("Show more information"))

      parser.add_option("--unlocked", action="store_true", help=_("Only show unlocked tags"))
@@ -4120,13 +3958,11 @@ 

          pkginfo = session.getPackage(options.package)

          if not pkginfo:

              parser.error(_("Invalid package %s" % options.package))

-             assert False  # pragma: no cover

  

      if options.build:

          buildinfo = session.getBuild(options.build)

          if not buildinfo:

              parser.error(_("Invalid build %s" % options.build))

-             assert False  # pragma: no cover

  

      tags = session.listTags(buildinfo.get('id',None), pkginfo.get('id',None))

      tags.sort(key=lambda x: x['name'])
@@ -4160,8 +3996,7 @@ 

  def anon_handle_list_tag_history(goptions, session, args):

      "[info] Print a history of tag operations"

      usage = _("usage: %prog list-tag-history [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--debug", action="store_true")

      parser.add_option("--build", help=_("Only show data for a specific build"))

      parser.add_option("--package", help=_("Only show data for a specific package"))
@@ -4170,7 +4005,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      kwargs = {}

      limited = False

      if options.package:
@@ -4457,8 +4291,7 @@ 

  def anon_handle_list_history(goptions, session, args):

      "[info] Display historical data"

      usage = _("usage: %prog list-history [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--debug", action="store_true")

      parser.add_option("--build", help=_("Only show data for a specific build"))

      parser.add_option("--package", help=_("Only show data for a specific package"))
@@ -4488,7 +4321,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      kwargs = {}

      limited = False

      for opt in ('before', 'after'):
@@ -4836,15 +4668,13 @@ 

  

  def anon_handle_taskinfo(goptions, session, args):

      """[info] Show information about a task"""

-     usage = _("usage: %prog taskinfo [options] taskID [taskID...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog taskinfo [options] <task_id> [<task_id> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("-r", "--recurse", action="store_true", help=_("Show children of this task as well"))

      parser.add_option("-v", "--verbose", action="store_true", help=_("Be verbose"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("You must specify at least one task ID"))

-         assert False  # pragma: no cover

  

      activate_session(session, goptions)

  
@@ -4856,15 +4686,13 @@ 

  def anon_handle_taginfo(goptions, session, args):

      "[info] Print basic information about a tag"

      usage = _("usage: %prog taginfo [options] <tag> [<tag> ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--event", type='int', metavar="EVENT#", help=_("query at event"))

      parser.add_option("--ts", type='int', metavar="TIMESTAMP", help=_("query at last event before timestamp"))

      parser.add_option("--repo", type='int', metavar="REPO#", help=_("query at event for a repo"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("Please specify a tag"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      event = koji.util.eventFromOpts(session, options)

      event_opts = {}
@@ -4949,9 +4777,8 @@ 

  

  def handle_add_tag(goptions, session, args):

      "[admin] Add a new tag to the database"

-     usage = _("usage: %prog add-tag [options] name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-tag [options] <name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--parent", help=_("Specify parent"))

      parser.add_option("--arches", help=_("Specify arches"))

      parser.add_option("--maven-support", action="store_true", help=_("Enable creation of Maven repos for this tag"))
@@ -4961,11 +4788,9 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("Please specify a name for the tag"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      if not (session.hasPerm('admin') or session.hasPerm('tag')):

-         print("This action requires tag or admin privileges")

-         return

+         parser.error(_("This action requires tag or admin privileges"))

      opts = {}

      if options.parent:

          opts['parent'] = options.parent
@@ -4987,9 +4812,8 @@ 

  

  def handle_edit_tag(goptions, session, args):

      "[admin] Alter tag information"

-     usage = _("usage: %prog edit-tag [options] name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog edit-tag [options] <name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--arches", help=_("Specify arches"))

      parser.add_option("--perm", help=_("Specify permission requirement"))

      parser.add_option("--no-perm", action="store_true", help=_("Remove permission requirement"))
@@ -5007,7 +4831,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("Please specify a name for the tag"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      tag = args[0]

      opts = {}
@@ -5047,8 +4870,7 @@ 

  def handle_lock_tag(goptions, session, args):

      "[admin] Lock a tag"

      usage = _("usage: %prog lock-tag [options] <tag> [<tag> ...] ")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--perm", help=_("Specify permission requirement"))

      parser.add_option("--glob", action="store_true", help=_("Treat args as glob patterns"))

      parser.add_option("--master", action="store_true", help=_("Lock the master lock"))
@@ -5056,7 +4878,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("Please specify a tag"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      pdata = session.getAllPerms()

      perm_ids = dict([(p['name'], p['id']) for p in pdata])
@@ -5098,14 +4919,12 @@ 

  def handle_unlock_tag(goptions, session, args):

      "[admin] Unlock a tag"

      usage = _("usage: %prog unlock-tag [options] <tag> [<tag> ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--glob", action="store_true", help=_("Treat args as glob patterns"))

      parser.add_option("-n", "--test", action="store_true", help=_("Test mode"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1:

          parser.error(_("Please specify a tag"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      if options.glob:

          selected = []
@@ -5122,7 +4941,6 @@ 

              tag = session.getTag(name)

              if tag is None:

                  parser.error(_("No such tag: %s") % name)

-                 assert False  # pragma: no cover

              selected.append(tag)

          selected = [session.getTag(name) for name in args]

      for tag in selected:
@@ -5142,9 +4960,8 @@ 

  

  def handle_add_tag_inheritance(goptions, session, args):

      """[admin] Add to a tag's inheritance"""

-     usage = _("usage: %prog add-tag-inheritance [options] tag parent-tag")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-tag-inheritance [options] <tag> <parent-tag>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--priority", help=_("Specify priority"))

      parser.add_option("--maxdepth", help=_("Specify max depth"))

      parser.add_option("--intransitive", action="store_true", help=_("Set intransitive"))
@@ -5156,7 +4973,6 @@ 

  

      if len(args) != 2:

          parser.error(_("This command takes exctly two argument: a tag name or ID and that tag's new parent name or ID"))

-         assert False  # pragma: no cover

  

      activate_session(session, goptions)

  
@@ -5199,9 +5015,8 @@ 

  

  def handle_edit_tag_inheritance(goptions, session, args):

      """[admin] Edit tag inheritance"""

-     usage = _("usage: %prog edit-tag-inheritance [options] tag <parent> <priority>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog edit-tag-inheritance [options] <tag> <parent> <priority>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--priority", help=_("Specify a new priority"))

      parser.add_option("--maxdepth", help=_("Specify max depth"))

      parser.add_option("--intransitive", action="store_true", help=_("Set intransitive"))
@@ -5211,11 +5026,9 @@ 

  

      if len(args) < 1:

          parser.error(_("This command takes at least one argument: a tag name or ID"))

-         assert False  # pragma: no cover

  

      if len(args) > 3:

          parser.error(_("This command takes at most three argument: a tag name or ID, a parent tag name or ID, and a priority"))

-         assert False  # pragma: no cover

  

      activate_session(session, goptions)

  
@@ -5287,18 +5100,15 @@ 

  

  def handle_remove_tag_inheritance(goptions, session, args):

      """[admin] Remove a tag inheritance link"""

-     usage = _("usage: %prog remove-tag-inheritance tag <parent> <priority>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog remove-tag-inheritance <tag> <parent> <priority>")

+     parser = OptionParser(usage=get_usage_str(usage))

      (options, args) = parser.parse_args(args)

  

      if len(args) < 1:

          parser.error(_("This command takes at least one argument: a tag name or ID"))

-         assert False  # pragma: no cover

  

      if len(args) > 3:

          parser.error(_("This command takes at most three argument: a tag name or ID, a parent tag name or ID, and a priority"))

-         assert False  # pragma: no cover

  

      activate_session(session, goptions)

  
@@ -5352,8 +5162,7 @@ 

  def anon_handle_show_groups(goptions, session, args):

      "[info] Show groups data for a tag"

      usage = _("usage: %prog show-groups [options] <tag>")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--comps", action="store_true", help=_("Print in comps format"))

      parser.add_option("-x", "--expand", action="store_true", default=False,

                        help=_("Expand groups in comps format"))
@@ -5362,7 +5171,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      if options.incl_blocked and (options.comps or options.spec):

          parser.error(_("--show-blocked doesn't make sense for comps/spec output"))

      activate_session(session, goptions)
@@ -5382,8 +5190,7 @@ 

  def anon_handle_list_external_repos(goptions, session, args):

      "[info] List external repos"

      usage = _("usage: %prog list-external-repos [options]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--url",  help=_("Select by url"))

      parser.add_option("--name",  help=_("Select by name"))

      parser.add_option("--id", type="int", help=_("Select by id"))
@@ -5399,7 +5206,6 @@ 

      (options, args) = parser.parse_args(args)

      if len(args) > 0:

          parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      activate_session(session, goptions)

      opts = {}

      event = koji.util.eventFromOpts(session, options)
@@ -5414,7 +5220,6 @@ 

          if opts['repo_info']:

              if options.inherit:

                  parser.error(_("Can't select by repo when using --inherit"))

-                 assert False  # pragma: no cover

          if options.inherit:

              del opts['repo_info']

              data = session.getExternalRepoList(**opts)
@@ -5485,9 +5290,8 @@ 

  

  def handle_add_external_repo(goptions, session, args):

      "[admin] Create an external repo and/or add one to a tag"

-     usage = _("usage: %prog add-external-repo [options] name [url]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog add-external-repo [options] <name> [<url>]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("-t", "--tag", action="append", metavar="TAG",

                        help=_("Also add repo to tag. Use tag::N to set priority"))

      parser.add_option("-p", "--priority", type='int',
@@ -5511,7 +5315,6 @@ 

          print("Created external repo %(id)i" % rinfo)

      else:

          parser.error(_("Incorrect number of arguments"))

-         assert False  # pragma: no cover

      if options.tag:

          for tagpri in options.tag:

              tag, priority = _parse_tagpri(tagpri)
@@ -5530,16 +5333,13 @@ 

  

  def handle_edit_external_repo(goptions, session, args):

      "[admin] Edit data for an external repo"

-     usage = _("usage: %prog edit-external-repo name")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog edit-external-repo <name>")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--url",  help=_("Change the url"))

      parser.add_option("--name",  help=_("Change the name"))

      (options, args) = parser.parse_args(args)

      if len(args) != 1:

          parser.error(_("Incorrect number of arguments"))

-         parser.error(_("This command takes no arguments"))

-         assert False  # pragma: no cover

      opts = {}

      if options.url:

          opts['url'] = options.url
@@ -5553,15 +5353,13 @@ 

  

  def handle_remove_external_repo(goptions, session, args):

      "[admin] Remove an external repo from a tag or tags, or remove entirely"

-     usage = _("usage: %prog remove-external-repo repo [tag ...]")

-     usage += _("\n(Specify the --help global option for a list of other help options)")

-     parser = OptionParser(usage=usage)

+     usage = _("usage: %prog remove-external-repo <repo> [<tag> ...]")

+     parser = OptionParser(usage=get_usage_str(usage))

      parser.add_option("--alltags", action="store_true", help=_("Remove from all tags"))

      parser.add_option("--force", action='store_true', help=_("Force action"))

      (options, args) = parser.parse_args(args)

      if len(args) < 1: