#2733 Unify error messages
Merged a year ago by tkopecek. Opened a year ago by jcupova.
jcupova/koji issue2720  into  master

file modified
+84 -88
@@ -82,7 +82,7 @@ 

  

      dsttag = session.getTag(tag)

      if not dsttag:

-         error("Unknown tag: %s" % tag)

+         error("No such tag: %s" % tag)

  

      groups = dict([(p['name'], p['group_id']) for p in session.getTagGroups(tag, inherit=False)])

      group_id = groups.get(group, None)
@@ -108,7 +108,7 @@ 

  

      dsttag = session.getTag(tag)

      if not dsttag:

-         error("Unknown tag: %s" % tag)

+         error("No such tag: %s" % tag)

  

      groups = dict([(p['name'], p['group_id']) for p in session.getTagGroups(tag, inherit=False)])

      group_id = groups.get(group, None)
@@ -134,7 +134,7 @@ 

  

      dsttag = session.getTag(tag)

      if not dsttag:

-         error(_("Unknown tag: %s" % tag))

+         error(_("No such tag: %s") % tag)

  

      groups = dict([(p['name'], p['group_id']) for p in session.getTagGroups(tag, inherit=False)])

      group_id = groups.get(group, None)
@@ -341,7 +341,7 @@ 

      if not options.owner:

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

      if not session.getUser(options.owner):

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

+         error("No such user: %s" % options.owner)

      activate_session(session, goptions)

      tag = args[0]

      opts = {}
@@ -498,12 +498,12 @@ 

      else:

          build_target = session.getBuildTarget(target)

          if not build_target:

-             parser.error(_("Unknown build target: %s" % target))

+             parser.error(_("No such build target: %s") % target)

          dest_tag = session.getTag(build_target['dest_tag'])

          if not dest_tag:

-             parser.error(_("Unknown destination tag: %s" % build_target['dest_tag_name']))

+             parser.error(_("No such destination tag: %s") % build_target['dest_tag_name'])

          if dest_tag['locked'] and not build_opts.scratch:

-             parser.error(_("Destination tag %s is locked" % dest_tag['name']))

+             parser.error(_("Destination tag %s is locked") % dest_tag['name'])

      source = args[1]

      opts = {}

      if build_opts.arch_override:
@@ -558,10 +558,10 @@ 

      target = args[0]

      build_target = session.getBuildTarget(target)

      if not build_target:

-         parser.error(_("Unknown build target: %s" % target))

+         parser.error(_("No such build target: %s") % target)

      dest_tag = session.getTag(build_target['dest_tag'], strict=True)

      if dest_tag['locked']:

-         parser.error(_("Destination tag %s is locked" % dest_tag['name']))

+         parser.error(_("Destination tag %s is locked") % dest_tag['name'])

  

      # check that the destination tag is in the inheritance tree of the build tag

      # otherwise there is no way that a chain-build can work
@@ -674,12 +674,12 @@ 

      target = args[0]

      build_target = session.getBuildTarget(target)

      if not build_target:

-         parser.error(_("Unknown build target: %s" % target))

+         parser.error(_("No such build target: %s") % target)

      dest_tag = session.getTag(build_target['dest_tag'])

      if not dest_tag:

-         parser.error(_("Unknown destination tag: %s" % build_target['dest_tag_name']))

+         parser.error(_("No such destination tag: %s") % build_target['dest_tag_name'])

      if dest_tag['locked'] and not build_opts.scratch:

-         parser.error(_("Destination tag %s is locked" % dest_tag['name']))

+         parser.error(_("Destination tag %s is locked") % dest_tag['name'])

      if build_opts.inis:

          try:

              params = koji.util.parse_maven_param(build_opts.inis, scratch=build_opts.scratch,
@@ -695,7 +695,7 @@ 

          source = args[1]

          opts = koji.util.maven_opts(build_opts, scratch=build_opts.scratch)

      if '://' not in source:

-         parser.error(_("Invalid SCM URL: %s" % source))

+         parser.error(_("No such SCM URL: %s") % source)

      if build_opts.debug:

          opts.setdefault('maven_options', []).append('--debug')

      if build_opts.skip_tag:
@@ -811,10 +811,10 @@ 

      target = args[0]

      build_target = session.getBuildTarget(target)

      if not build_target:

-         parser.error(_("Unknown build target: %s") % target)

+         parser.error(_("No such build target: %s") % target)

      dest_tag = session.getTag(build_target['dest_tag'])

      if not dest_tag:

-         parser.error(_("Unknown destination tag: %s") % build_target['dest_tag_name'])

+         parser.error(_("No such destination tag: %s") % build_target['dest_tag_name'])

      if dest_tag['locked'] and not build_opts.scratch:

          parser.error(_("Destination tag %s is locked") % dest_tag['name'])

      opts = {}
@@ -984,7 +984,7 @@ 

              error(_("Please specify an arch"))

          tag = session.getTag(options.tag)

          if not tag:

-             parser.error(_("Invalid tag: %s" % options.tag))

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

          arch = options.arch

          config = session.getBuildConfig(tag['id'])

          if not config:
@@ -1003,7 +1003,7 @@ 

          arch = options.arch

          target = session.getBuildTarget(options.target)

          if not target:

-             parser.error(_("Invalid target: %s" % options.target))

+             parser.error(_("No such build target: %s") % options.target)

          opts['tag_name'] = target['build_tag_name']

          if options.latest:

              opts['repoid'] = 'latest'
@@ -1645,7 +1645,7 @@ 

              if x['active']:

                  fmt += " [still active]"

          else:

-             raise koji.GenericError("unknown event: (%r, %r)" % (event_id, x))

+             raise koji.GenericError("No such event: (%r, %r)" % (event_id, x))

          time_str = time.asctime(time.localtime(ts))

          return "%s: %s" % (time_str, fmt % x)

      for nvr, binfo in builds:
@@ -2214,7 +2214,7 @@ 

          image_info = {'arch': suboptions.type_info}

          suboptions.type_info = image_info

      else:

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

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

  

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

      if not buildinfo:
@@ -2273,7 +2273,7 @@ 

      for n in names:

          user = session.getUser(n)

          if user is None:

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

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

          users.append(user)

      kwargs = {}

      if options.new:
@@ -2296,7 +2296,7 @@ 

      for n in names:

          user = session.getUser(n)

          if user is None:

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

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

          users.append(user)

      for user in users:

          session.revokePermission(user['name'], perm)
@@ -2315,7 +2315,7 @@ 

      cg = args[1]

      uinfo = session.getUser(user)

      if uinfo is None:

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

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

      kwargs = {}

      if options.new:

          kwargs['create'] = True
@@ -2334,7 +2334,7 @@ 

      cg = args[1]

      uinfo = session.getUser(user)

      if uinfo is None:

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

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

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

  

  
@@ -2512,7 +2512,7 @@ 

      # check if tag exist(s|ed)

      taginfo = session.getTag(tag, event=event_id)

      if not taginfo:

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

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

  

      if options.rpms:

          rpms, builds = session.listTaggedRPMS(tag, **opts)
@@ -2858,7 +2858,7 @@ 

      if options.channel:

          channel = session.getChannel(options.channel)

          if not channel:

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

+             parser.error(_('No such channel: %s') % options.channel)

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

      if options.ready is not None:

          opts['ready'] = options.ready
@@ -2958,12 +2958,12 @@ 

      if options.owner:

          user = session.getUser(options.owner)

          if user is None:

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

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

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

      if options.tag:

          tag = session.getTag(options.tag)

          if tag is None:

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

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

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

      if options.package:

          opts['pkgID'] = options.package
@@ -3059,7 +3059,7 @@ 

          except ValueError:

              package = session.getPackageID(options.package)

              if package is None:

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

+                 parser.error(_("No such package: %s") % options.package)

              opts['packageID'] = package

      if options.owner:

          try:
@@ -3067,7 +3067,7 @@ 

          except ValueError:

              user = session.getUser(options.owner)

              if user is None:

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

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

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

      if options.volume:

          try:
@@ -3079,19 +3079,19 @@ 

                  if options.volume == volume['name']:

                      volumeID = volume['id']

              if volumeID is None:

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

+                 parser.error(_("No such volume: %s") % options.volume)

              opts['volumeID'] = volumeID

      if options.state:

          try:

              state = int(options.state)

              if state > 4 or state < 0:

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

+                 parser.error(_("Invalid state: %s") % options.state)

              opts['state'] = state

          except ValueError:

              try:

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

              except KeyError:

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

+                 parser.error(_("Invalid state: %s") % options.state)

      if options.before:

          opts['completeBefore'] = options.before

      if options.after:
@@ -3110,7 +3110,7 @@ 

              buildid = options.buildid

          data = [session.getBuild(buildid)]

          if data[0] is None:

-             parser.error(_("No build with ID '%s'" % buildid))

+             parser.error(_("No such build: '%s'") % buildid)

      else:

          # Check filter exists

          if any(opts):
@@ -3445,10 +3445,10 @@ 

      try:

          srctag = session.getBuildConfig(args[0], event=event.get('id'))

      except koji.GenericError:

-         parser.error(_("Unknown src-tag: %s" % args[0]))

+         parser.error(_("No such src-tag: %s") % args[0])

      dsttag = session.getTag(args[1])

      if not srctag:

-         parser.error(_("Unknown src-tag: %s" % args[0]))

+         parser.error(_("No such src-tag: %s") % args[0])

      if (srctag['locked'] and not options.force) \

              or (dsttag and dsttag['locked'] and not options.force):

          parser.error(_("Error: You are attempting to clone from or to a tag which is locked.\n"
@@ -3929,11 +3929,11 @@ 

      chkbuildtag = session.getTag(build_tag)

      chkdesttag = session.getTag(dest_tag)

      if not chkbuildtag:

-         error("Build tag does not exist: %s" % build_tag)

+         error("No such tag: %s" % build_tag)

      if not chkbuildtag.get("arches", None):

          error("Build tag has no arches: %s" % build_tag)

      if not chkdesttag:

-         error("Destination tag does not exist: %s" % dest_tag)

+         error("No such destination tag: %s" % dest_tag)

  

      session.createBuildTarget(name, build_tag, dest_tag)

  
@@ -3957,7 +3957,7 @@ 

  

      targetInfo = session.getBuildTarget(args[0])

      if targetInfo is None:

-         raise koji.GenericError("No build target with the name or id '%s'" % args[0])

+         raise koji.GenericError("No such build target: %s" % args[0])

  

      targetInfo['orig_name'] = targetInfo['name']

  
@@ -3973,7 +3973,7 @@ 

      if options.dest_tag:

          chkdesttag = session.getTag(options.dest_tag)

          if not chkdesttag:

-             error("Destination tag does not exist: %s" % options.dest_tag)

+             error("No such destination tag: %s" % options.dest_tag)

          targetInfo['dest_tag_name'] = options.dest_tag

  

      session.editBuildTarget(targetInfo['orig_name'], targetInfo['name'],
@@ -3996,7 +3996,7 @@ 

      target = args[0]

      target_info = session.getBuildTarget(target)

      if not target_info:

-         error("Build target %s does not exist" % target)

+         error("No such build target: %s" % target)

  

      session.deleteBuildTarget(target_info['id'])

  
@@ -4017,7 +4017,7 @@ 

      tag = args[0]

      tag_info = session.getTag(tag)

      if not tag_info:

-         error("Tag %s does not exist" % tag)

+         error("No such tag: %s" % tag)

  

      session.deleteTag(tag_info['id'])

  
@@ -4038,9 +4038,9 @@ 

      targets = session.getBuildTargets(options.name)

      if len(targets) == 0:

          if options.name:

-             parser.error(_('Target "%s" does not exist' % options.name))

+             parser.error(_('No such build target: %s') % options.name)

          else:

-             parser.error(_('No Targets were found'))

+             parser.error(_('No targets were found'))

  

      fmt = "%(name)-30s %(build_tag_name)-30s %(dest_tag_name)-30s"

      if not options.quiet:
@@ -4132,7 +4132,7 @@ 

      else:

          tag = session.getTag(args[0])

      if not tag:

-         parser.error(_("Unknown tag: %s" % args[0]))

+         parser.error(_("No such tag: %s") % args[0])

  

      opts = {}

      opts['reverse'] = options.reverse or False
@@ -4147,17 +4147,17 @@ 

          if match:

              tag1 = session.getTagID(match.group(1))

              if not tag1:

-                 parser.error(_("Unknown tag: %s" % match.group(1)))

+                 parser.error(_("No such tag: %s") % match.group(1))

              tag2 = session.getTagID(match.group(2))

              if not tag2:

-                 parser.error(_("Unknown tag: %s" % match.group(2)))

+                 parser.error(_("No such tag: %s") % match.group(2))

              opts['jumps'][str(tag1)] = tag2

  

      if options.stop:

          deprecated("--stop option is deprecated and will be removed in 1.26")

          tag1 = session.getTagID(options.stop)

          if not tag1:

-             parser.error(_("Unknown tag: %s" % options.stop))

+             parser.error(_("No such tag: %s") % options.stop)

          opts['stops'] = {str(tag1): 1}

  

      sys.stdout.write('     %s (%i)\n' % (tag['name'], tag['id']))
@@ -4183,12 +4183,12 @@ 

      if options.package:

          pkginfo = session.getPackage(options.package)

          if not pkginfo:

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

+             parser.error(_("No such package: %s") % options.package)

  

      if options.build:

          buildinfo = session.getBuild(options.build)

          if not buildinfo:

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

+             parser.error(_("No such build: %s") % options.build)

  

      if not args:

          # list everything if no pattern is supplied
@@ -4903,8 +4903,7 @@ 

              except ValueError:

                  info = None

              if info is None:

-                 print("No such tag: %s" % tag)

-                 sys.exit(1)

+                 parser.error(_('No such tag: %s') % tag)

          tags.append(info)

  

      for n, info in enumerate(tags):
@@ -5192,11 +5191,11 @@ 

  

      tag = session.getTag(args[0])

      if not tag:

-         parser.error(_("Invalid tag: %s" % args[0]))

+         parser.error(_("No such tag: %s") % args[0])

  

      parent = session.getTag(args[1])

      if not parent:

-         parser.error(_("Invalid tag: %s" % args[1]))

+         parser.error(_("No such tag: %s") % args[1])

  

      inheritanceData = session.getInheritanceData(tag['id'])

      priority = options.priority and int(options.priority) or 0
@@ -5249,14 +5248,14 @@ 

  

      tag = session.getTag(args[0])

      if not tag:

-         parser.error(_("Invalid tag: %s" % args[0]))

+         parser.error(_("No such tag: %s") % args[0])

  

      parent = None

      priority = None

      if len(args) > 1:

          parent = session.getTag(args[1])

          if not parent:

-             parser.error(_("Invalid tag: %s" % args[1]))

+             parser.error(_("No such tag: %s") % args[1])

          if len(args) > 2:

              priority = args[2]

  
@@ -5325,14 +5324,14 @@ 

  

      tag = session.getTag(args[0])

      if not tag:

-         parser.error(_("Invalid tag: %s" % args[0]))

+         parser.error(_("No such tag: %s") % args[0])

  

      parent = None

      priority = None

      if len(args) > 1:

          parent = session.getTag(args[1])

          if not parent:

-             parser.error(_("Invalid tag: %s" % args[1]))

+             parser.error(_("No such tag: %s") % args[1])

          if len(args) > 2:

              priority = args[2]

  
@@ -5897,11 +5896,10 @@ 

  

      tmp_target = session.getBuildTarget(task_opts.target)

      if not tmp_target:

-         raise koji.GenericError(_("Unknown build target: %s" % tmp_target))

+         raise koji.GenericError(_("No such build target: %s") % tmp_target)

      dest_tag = session.getTag(tmp_target['dest_tag'])

      if not dest_tag:

-         raise koji.GenericError(_("Unknown destination tag: %s" %

-                                   tmp_target['dest_tag_name']))

+         raise koji.GenericError(_("No such destination tag: %s") % tmp_target['dest_tag_name'])

  

      # Set the architecture

      task_opts.arch = koji.canonArch(task_opts.arch)
@@ -6010,7 +6008,7 @@ 

          section = 'image-build'

          config = koji.read_config_files([(task_options.config, True)])

          if not config.has_section(section):

-             parser.error(_("single section called [%s] is required" % section))

+             parser.error(_("single section called [%s] is required") % section)

          # pluck out the positional arguments first

          args = []

          for arg in ('name', 'version', 'target', 'install_tree'):
@@ -6085,11 +6083,10 @@ 

      target = args[2]

      tmp_target = session.getBuildTarget(target)

      if not tmp_target:

-         raise koji.GenericError(_("Unknown build target: %s" % target))

+         raise koji.GenericError(_("No such build target: %s") % target)

      dest_tag = session.getTag(tmp_target['dest_tag'])

      if not dest_tag:

-         raise koji.GenericError(_("Unknown destination tag: %s" %

-                                   tmp_target['dest_tag_name']))

+         raise koji.GenericError(_("No such destination tag: %s") % tmp_target['dest_tag_name'])

  

      # Set the architecture

      if img_type == 'livemedia':
@@ -6159,11 +6156,10 @@ 

      target = args[2]

      tmp_target = session.getBuildTarget(target)

      if not tmp_target:

-         raise koji.GenericError(_("Unknown build target: %s" % target))

+         raise koji.GenericError(_("No such build target: %s") % target)

      dest_tag = session.getTag(tmp_target['dest_tag'])

      if not dest_tag:

-         raise koji.GenericError(_("Unknown destination tag: %s" %

-                                   tmp_target['dest_tag_name']))

+         raise koji.GenericError(_("No such destination tag: %s") % tmp_target['dest_tag_name'])

  

      # Set the architectures

      arches = []
@@ -6252,12 +6248,12 @@ 

      else:

          build_target = session.getBuildTarget(target)

          if not build_target:

-             parser.error(_("Unknown build target: %s" % target))

+             parser.error(_("No such build target: %s") % target)

          dest_tag = session.getTag(build_target['dest_tag'])

          if not dest_tag:

-             parser.error(_("Unknown destination tag: %s" % build_target['dest_tag_name']))

+             parser.error(_("No such destination tag: %s") % build_target['dest_tag_name'])

          if dest_tag['locked'] and not build_opts.scratch:

-             parser.error(_("Destination tag %s is locked" % dest_tag['name']))

+             parser.error(_("Destination tag %s is locked") % dest_tag['name'])

      scmurl = args[1]

      vm_name = args[2]

      opts = {}
@@ -6652,7 +6648,7 @@ 

          for arg in args[2:]:

              pkg = session.getPackage(arg)

              if not pkg:

-                 print(_("Invalid package name %s, skipping." % arg))

+                 print(_("No such package: %s, skipping.") % arg)

                  continue

              tasklist = session.moveAllBuilds(args[0], args[1], arg, options.force)

              tasks.extend(tasklist)
@@ -6660,7 +6656,7 @@ 

          for arg in args[2:]:

              build = session.getBuild(arg)

              if not build:

-                 print(_("Invalid build %s, skipping." % arg))

+                 print(_("No such build: %s, skipping.") % arg)

                  continue

              if build not in builds:

                  builds.append(build)
@@ -6699,7 +6695,7 @@ 

      activate_session(session, goptions)

      tag = session.getTag(args[0])

      if not tag:

-         parser.error(_("Invalid tag: %s" % args[0]))

+         parser.error(_("No such tag: %s") % args[0])

      if options.all:

          builds = []

          for pkg in args[1:]:
@@ -6947,7 +6943,7 @@ 

          assert task_id == int(task_id), "Task id must be number: %r" % task_id

          task_info = session.getTaskInfo(task_id)

          if task_info is None:

-             error(_("No such task id: %i" % task_id))

+             error(_("No such task: %d" % task_id))

          files = list_task_output_all_volumes(session, task_id)

          logs = []  # list of tuples (filename, volume)

          for filename in files:
@@ -7031,7 +7027,7 @@ 

  

      base_task = session.getTaskInfo(base_task_id)

      if not base_task:

-         error(_('No such task: #%i') % base_task_id)

+         error(_('No such task: %d') % base_task_id)

  

      if suboptions.wait and base_task['state'] not in (

              koji.TASK_STATES['CLOSED'],
@@ -7128,13 +7124,13 @@ 

      if suboptions.target:

          target_info = session.getBuildTarget(tag)

          if not target_info:

-             parser.error(_("Invalid build target: %s") % tag)

+             parser.error(_("No such build target: %s") % tag)

          tag = target_info['build_tag_name']

          tag_id = target_info['build_tag']

      else:

          tag_info = session.getTag(tag)

          if not tag_info:

-             parser.error(_("Invalid tag: %s") % tag)

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

          targets = session.getBuildTargets(buildTagID=tag_info['id'])

          if not targets:

              warn("%(name)s is not a build tag for any target" % tag_info)
@@ -7217,13 +7213,13 @@ 

      if suboptions.target:

          info = session.getBuildTarget(tag)

          if not info:

-             parser.error(_("No matching build target: " + tag))

+             parser.error(_("No such build target: %s") % tag)

          tag = info['build_tag_name']

          info = session.getTag(tag, strict=True)

      else:

          info = session.getTag(tag)

          if not info:

-             parser.error(_("No matching tag: " + tag))

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

          tag = info['name']

          targets = session.getBuildTargets(buildTagID=info['id'])

          if not targets:
@@ -7332,7 +7328,7 @@ 

      keys = args[1:]

      taginfo = session.getTag(tag)

      if not taginfo:

-         parser.error(_('unknown tag %s') % tag)

+         parser.error(_('No such tag: %s') % tag)

      if len(task_opts.arch) == 0:

          arches = taginfo['arches'] or ''

          task_opts.arch = arches.split()
@@ -7405,7 +7401,7 @@ 

          parser.error(_("Please specify search pattern"))

      type = args[0]

      if type not in _search_types:

-         parser.error(_("Unknown search type: %s") % type)

+         parser.error(_("No such search type: %s") % type)

      pattern = args[1]

      matchType = 'glob'

      if options.regex:
@@ -7460,7 +7456,7 @@ 

          ensure_connection(session)

          user = session.getUser(options.user)

          if not user:

-             error("User %s does not exist" % options.user)

+             error("No such user: %s" % options.user)

          user_id = user['id']

      else:

          activate_session(session, goptions)
@@ -7544,7 +7540,7 @@ 

      if options.package:

          package_id = session.getPackageID(options.package)

          if package_id is None:

-             parser.error(_("Unknown package: %s") % options.package)

+             parser.error(_("No such package: %s") % options.package)

      else:

          package_id = None

  
@@ -7552,7 +7548,7 @@ 

          try:

              tag_id = session.getTagID(options.tag, strict=True)

          except koji.GenericError:

-             parser.error(_("Unknown tag: %s") % options.tag)

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

      else:

          tag_id = None

  
@@ -7616,7 +7612,7 @@ 

      elif options.package:

          package_id = session.getPackageID(options.package)

          if package_id is None:

-             parser.error(_("Unknown package: %s") % options.package)

+             parser.error(_("No such package: %s") % options.package)

      else:

          package_id = old['package_id']

  
@@ -7626,7 +7622,7 @@ 

          try:

              tag_id = session.getTagID(options.tag, strict=True)

          except koji.GenericError:

-             parser.error(_("Unknown tag: %s") % options.tag)

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

      else:

          tag_id = old['tag_id']

  
@@ -7671,7 +7667,7 @@ 

      if options.package:

          package_id = session.getPackageID(options.package)

          if package_id is None:

-             parser.error(_("Unknown package: %s") % options.package)

+             parser.error(_("No such package: %s") % options.package)

      else:

          package_id = None

  
@@ -7679,7 +7675,7 @@ 

          try:

              tag_id = session.getTagID(options.tag, strict=True)

          except koji.GenericError:

-             parser.error(_("Unknown tag: %s") % options.tag)

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

      else:

          tag_id = None

  

file modified
+72 -79
@@ -505,7 +505,7 @@ 

                  info['result'] = self.getResult()

              new_val = info[attr]

          else:

-             raise koji.GenericError('unknown callback type: %s' % cbtype)

+             raise koji.GenericError('No such callback type: %s' % cbtype)

          old_val = old_info[attr]

          if attr == 'state':

              # state is passed in as an integer, but we want to use the string
@@ -971,7 +971,7 @@ 

      pkg = lookup_package(pkginfo, strict=False)

      if not pkg:

          if not isinstance(pkginfo, str):

-             raise koji.GenericError("Invalid package: %s" % pkginfo)

+             raise koji.GenericError("No such package: %s" % pkginfo)

      if owner is not None:

          owner = get_user(owner, strict=True)['id']

      action = 'add'
@@ -1263,7 +1263,7 @@ 

          # lookup build id

          buildinfo = get_build(build)

          if not buildinfo:

-             raise koji.GenericError('invalid build: %s' % build)

+             raise koji.GenericError('No such build: %s' % build)

          joins.append('tag_listing ON tag.id = tag_listing.tag_id')

          clauses.append('tag_listing.active = true')

          clauses.append('tag_listing.build_id = %(buildID)i')
@@ -1271,7 +1271,7 @@ 

      elif package is not None:

          packageinfo = lookup_package(package)

          if not packageinfo:

-             raise koji.GenericError('invalid package: %s' % package)

+             raise koji.GenericError('No such package: %s' % package)

          fields.extend(

              ['users.id', 'users.name', 'tag_packages.blocked', 'tag_packages.extra_arches'])

          aliases.extend(['owner_id', 'owner_name', 'blocked', 'extra_arches'])
@@ -1463,7 +1463,7 @@ 

          elif isinstance(arch, (list, tuple)):

              clauses.append('rpminfo.arch IN %(arch)s')

          else:

-             raise koji.GenericError('invalid arch option: %s' % arch)

+             raise koji.GenericError('Invalid type for arch option: %s' % type(arch))

  

      fields, aliases = zip(*fields)

      query = QueryProcessor(tables=tables, joins=joins, clauses=clauses,
@@ -2941,7 +2941,7 @@ 

      """Record a non-versioned tag update"""

      utype_id = koji.TAG_UPDATE_TYPES.getnum(utype)

      if utype_id is None:

-         raise koji.GenericError("Invalid update type: %s" % utype)

+         raise koji.GenericError("No such update type: %s" % utype)

      if event_id is None:

          event_id = get_event()

      if user_id is None:
@@ -3010,7 +3010,7 @@ 

  

      target = lookup_build_target(buildTargetInfo)

      if not target:

-         raise koji.GenericError('invalid build target: %s' % buildTargetInfo)

+         raise koji.GenericError('No such build target: %s' % buildTargetInfo)

  

      buildTargetID = target['id']

  
@@ -3060,7 +3060,7 @@ 

      """Delete build target, no access checks"""

      target = lookup_build_target(buildTargetInfo)

      if not target:

-         raise koji.GenericError('invalid build target: %s' % buildTargetInfo)

+         raise koji.GenericError('No such build target: %s' % buildTargetInfo)

  

      targetID = target['id']

  
@@ -3095,7 +3095,7 @@ 

          elif isinstance(info, int):

              clauses.append('build_target.id = %(info)i')

          else:

-             raise koji.GenericError('invalid type for lookup: %s' % type(info))

+             raise koji.GenericError('Invalid type for lookup: %s' % type(info))

      if buildTagID is not None:

          clauses.append('build_tag = %(buildTagID)i')

      if destTagID is not None:
@@ -3114,7 +3114,7 @@ 

      if len(targets) == 1:

          return targets[0]

      elif strict:

-         raise koji.GenericError('No matching build target found: %s' % info)

+         raise koji.GenericError('No such build target: %s' % info)

      else:

          return None

  
@@ -3142,7 +3142,7 @@ 

      elif isinstance(info, str):

          q = """SELECT id,name FROM %s WHERE name=%%(info)s""" % table

      else:

-         raise koji.GenericError('invalid type for id lookup: %s' % type(info))

+         raise koji.GenericError('Invalid type for id lookup: %s' % type(info))

      ret = _singleRow(q, locals(), fields, strict=False)

      if ret is None:

          if strict:
@@ -3336,7 +3336,7 @@ 

      elif isinstance(tagInfo, str):

          clauses.append("tag.name = %(tagInfo)s")

      else:

-         raise koji.GenericError('invalid type for tagInfo: %s' % type(tagInfo))

+         raise koji.GenericError('Invalid type for tagInfo: %s' % type(tagInfo))

  

      data = {'tagInfo': tagInfo}

      fields, aliases = zip(*fields.items())
@@ -3345,7 +3345,7 @@ 

      result = query.executeOne()

      if not result:

          if strict:

-             raise koji.GenericError("Invalid tagInfo: %r" % tagInfo)

+             raise koji.GenericError("No such tagInfo: %r" % tagInfo)

          return None

      result['extra'] = get_tag_extra(result, event, blocked=blocked)

      return result
@@ -3364,7 +3364,7 @@ 

      result = {}

      for h in query.execute():

          if h['value'] is not None:

-             h['value'] = parse_json(h['value'], errstr="Invalid tag extra data: %s" % h['key'])

+             h['value'] = parse_json(h['value'], errstr="No such tag extra data: %s" % h['key'])

          if blocked:

              result[h['key']] = (h['blocked'], h['value'])

          else:
@@ -3613,7 +3613,7 @@ 

          elif isinstance(info, int):

              clauses.append('id = %(info)i')

          else:

-             raise koji.GenericError('invalid type for lookup: %s' % type(info))

+             raise koji.GenericError('Invalid type for lookup: %s' % type(info))

      if url:

          clauses.append('url = %(url)s')

  
@@ -3642,7 +3642,7 @@ 

          return repos[0]

      else:

          if strict:

-             raise koji.GenericError('invalid repo info: %s' % info)

+             raise koji.GenericError('No such repo: %s' % info)

          else:

              return None

  
@@ -3714,7 +3714,7 @@ 

      if merge_mode is None:

          merge_mode = 'koji'

      if merge_mode not in koji.REPO_MERGE_MODES:

-         raise koji.GenericError('Invalid merge mode: %s' % merge_mode)

+         raise koji.GenericError('No such merge mode: %s' % merge_mode)

  

      tag = get_tag(tag_info, strict=True)

      tag_id = tag['id']
@@ -3920,8 +3920,7 @@ 

          data = {'info': userInfo}

          clauses = ['krb_principal = %(info)s OR name = %(info)s']

      else:

-         raise koji.GenericError('invalid type for userInfo: %s'

-                                 % type(userInfo))

+         raise koji.GenericError('Invalid type for userInfo: %s' % type(userInfo))

      if isinstance(data, dict) and not data.get('info'):

          clauses = []

          uid = data.get('id')
@@ -3929,23 +3928,20 @@ 

              if isinstance(uid, int):

                  clauses.append('users.id = %(id)i')

              else:

-                 raise koji.GenericError('invalid type for userid: %s'

-                                         % type(uid))

+                 raise koji.GenericError('Invalid type for userid: %s' % type(uid))

          username = data.get('name')

          if username:

              if isinstance(username, str):

                  clauses.append('users.name = %(name)s')

              else:

-                 raise koji.GenericError('invalid type for username: %s'

-                                         % type(username))

+                 raise koji.GenericError('Invalid type for username: %s' % type(username))

          krb_principal = data.get('krb_principal')

          if krb_principal:

              if isinstance(krb_principal, str):

                  clauses.append('user_krb_principals.krb_principal'

                                 ' = %(krb_principal)s')

              else:

-                 raise koji.GenericError('invalid type for krb_principal: %s'

-                                         % type(krb_principal))

+                 raise koji.GenericError('Invalid type for krb_principal: %s' % type(krb_principal))

  

      query = QueryProcessor(tables=['users'], columns=fields,

                             joins=['LEFT JOIN user_krb_principals'
@@ -4063,8 +4059,7 @@ 

          joins = ['users ON users.id = user_krb_principals.user_id']

          clauses = ['name = %(info)s']

      else:

-         raise koji.GenericError('invalid type for user_info: %s'

-                                 % type(user_info))

+         raise koji.GenericError('Invalid type for user_info: %s' % type(user_info))

      query = QueryProcessor(tables=['user_krb_principals'],

                             columns=fields, joins=joins,

                             clauses=clauses, values=data,
@@ -4088,8 +4083,7 @@ 

      if krb_principal is None:

          raise koji.GenericError("No kerberos principal provided")

      if not isinstance(krb_principal, str):

-         raise koji.GenericError("invalid type for krb_principal: %s"

-                                 % type(krb_principal))

+         raise koji.GenericError("Invalid type for krb_principal: %s" % type(krb_principal))

      return get_user({'krb_principal': krb_principal}, strict=strict,

                      krb_princs=krb_princs)

  
@@ -4108,7 +4102,7 @@ 

      elif isinstance(X, dict):

          data = X

      else:

-         raise koji.GenericError("Invalid argument: %r" % X)

+         raise koji.GenericError("Invalid type for argument: %r" % type(X))

  

      if not ('name' in data and 'version' in data and 'release' in data):

          raise koji.GenericError('did not provide name, version, and release')
@@ -4125,7 +4119,7 @@ 

      # log_error("%r" % r )

      if not r:

          if strict:

-             raise koji.GenericError('No matching build found: %r' % X)

+             raise koji.GenericError('No such build: %r' % X)

          else:

              return None

      return r[0]
@@ -4211,7 +4205,7 @@ 

  

      if not result:

          if strict:

-             raise koji.GenericError('No matching build found: %s' % buildInfo)

+             raise koji.GenericError('No such build: %s' % buildInfo)

          else:

              return None

      if result['cg_id']:
@@ -4384,7 +4378,7 @@ 

      elif isinstance(rpminfo, dict):

          data = rpminfo.copy()

      else:

-         raise koji.GenericError("Invalid argument: %r" % rpminfo)

+         raise koji.GenericError("Invalid type for rpminfo: %r" % type(rpminfo))

      clauses = []

      if 'id' in data:

          clauses.append("rpminfo.id=%(id)s")
@@ -4495,7 +4489,7 @@ 

          elif isinstance(arches, str):

              clauses.append('rpminfo.arch = %(arches)s')

          else:

-             raise koji.GenericError('invalid type for "arches" parameter: %s' % type(arches))

+             raise koji.GenericError('Invalid type for "arches" parameter: %s' % type(arches))

  

      fields, aliases = zip(*fields)

      query = QueryProcessor(columns=fields, aliases=aliases,
@@ -5272,7 +5266,7 @@ 

      elif isinstance(hostInfo, str):

          clauses.append("host.name = %(hostInfo)s")

      else:

-         raise koji.GenericError('invalid type for hostInfo: %s' % type(hostInfo))

+         raise koji.GenericError('Invalid type for hostInfo: %s' % type(hostInfo))

  

      data = {'hostInfo': hostInfo}

      fields, aliases = zip(*fields.items())
@@ -5349,7 +5343,7 @@ 

      elif isinstance(channelInfo, str):

          query += """name = %(channelInfo)s"""

      else:

-         raise koji.GenericError('invalid type for channelInfo: %s' % type(channelInfo))

+         raise koji.GenericError('Invalid type for channelInfo: %s' % type(channelInfo))

  

      return _singleRow(query, locals(), fields, strict)

  
@@ -5722,9 +5716,8 @@ 

              return vol

          # otherwise

          if strict:

-             raise koji.GenericError("Policy returned invalid volume: %s"

-                                     % result)

-         logger.error('Volume policy returned unknown volume %s', result)

+             raise koji.GenericError("Policy returned no such volume: %s" % result)

+         logger.error('Volume policy returned no such volume %s', result)

      # fall back to default

      if default is not None:

          vol = lookup_name('volume', default)
@@ -5789,7 +5782,7 @@ 

          try:

              data['extra'] = json.dumps(data['extra'])

          except Exception:

-             raise koji.GenericError("Invalid build extra data: %(extra)r" % data)

+             raise koji.GenericError("No such build extra data: %(extra)r" % data)

      else:

          data['extra'] = None

  
@@ -5957,7 +5950,7 @@ 

      for relpath in [srpm] + rpms:

          fn = "%s/%s" % (uploadpath, relpath)

          if not os.path.exists(fn):

-             raise koji.GenericError("no such file: %s" % fn)

+             raise koji.GenericError("No such file: %s" % fn)

  

      rpms = check_noarch_rpms(uploadpath, rpms, logs=logs)

  
@@ -6048,7 +6041,7 @@ 

      Designed to be called from import_build.

      """

      if not os.path.exists(fn):

-         raise koji.GenericError("no such file: %s" % fn)

+         raise koji.GenericError("No such file: %s" % fn)

  

      # read rpm info

      hdr = koji.get_rpm_header(fn)
@@ -6078,7 +6071,7 @@ 

              if buildinfo is None:

                  # XXX - handle case where package is not a source rpm

                  #      and we still need to create a new build

-                 raise koji.GenericError('No matching build')

+                 raise koji.GenericError('No such build')

              state = koji.BUILD_STATES[buildinfo['state']]

              if state in ('FAILED', 'CANCELED', 'DELETED'):

                  nvr = "%(name)s-%(version)s-%(release)s" % buildinfo
@@ -6274,7 +6267,7 @@ 

  

          metaver = metadata['metadata_version']

          if metaver != 0:

-             raise koji.GenericError("Unknown metadata version: %r" % metaver)

+             raise koji.GenericError("No such metadata version: %r" % metaver)

  

          # TODO: basic metadata sanity check (use jsonschema?)

  
@@ -6322,7 +6315,7 @@ 

              # default to looking for uploaded file

              metadata = 'metadata.json'

          if not isinstance(metadata, str):

-             raise koji.GenericError("Invalid metadata value: %r" % metadata)

+             raise koji.GenericError("Invalid type for metadata value: %r" % type(metadata))

          if metadata.endswith('.json'):

              # handle uploaded metadata

              workdir = koji.pathinfo.work()
@@ -6608,7 +6601,7 @@ 

                  if match:

                      files.append(match)

              else:

-                 raise koji.GenericError("Unknown component type: %(type)s" % comp)

+                 raise koji.GenericError("No such component type: %(type)s" % comp)

          return rpms, files

  

      def match_rpm(self, comp):
@@ -6951,7 +6944,7 @@ 

      try:

          task_info = task.getInfo(request=True)

      except koji.GenericError:

-         raise koji.ImportError('invalid task: %s' % task_id)

+         raise koji.ImportError('No such task: %s' % task_id)

      task_params = koji.tasks.parse_task_params(task_info['method'], task_info['request'])

      if task_info['state'] != koji.TASK_STATES['CLOSED']:

          raise koji.ImportError('task %s did not complete successfully' % task_id)
@@ -7140,7 +7133,7 @@ 

      # No invalid or duplicate extensions

      for ext in extensions.split(' '):

          if not ext.replace('.', '').isalnum():

-             raise koji.GenericError('invalid %s file extension' % ext)

+             raise koji.GenericError('No such %s file extension' % ext)

          select = r"""SELECT id FROM archivetypes

                        WHERE extensions ~* E'(\\s|^)%s(\\s|$)'""" % ext

          results = _multiRow(select, {}, ('id',))
@@ -7265,7 +7258,7 @@ 

      if metadata_only:

          filepath = None

      elif not os.path.exists(filepath):

-         raise koji.GenericError('no such file: %s' % filepath)

+         raise koji.GenericError('No such file: %s' % filepath)

  

      archiveinfo = {'buildroot_id': buildroot_id}

      archiveinfo['build_id'] = buildinfo['id']
@@ -7725,7 +7718,7 @@ 

      else:

          for table in tables:

              if table not in table_fields:

-                 raise koji.GenericError("Unknown history table: %s" % table)

+                 raise koji.GenericError("No such history table: %s" % table)

      ret = {}

      for table in tables:

          fields = {}
@@ -8541,7 +8534,7 @@ 

      user = get_user(user, strict=True)

      ginfo = get_user(group)

      if not ginfo or ginfo['usertype'] != koji.USERTYPES['GROUP']:

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

+         raise koji.GenericError("Not a group: %s" % group)

      if user['id'] not in [u['id'] for u in get_group_members(group)]:

          raise koji.GenericError("No such user in group: %s" % group)

      data = {'user_id': user['id'], 'group_id': ginfo['id']}
@@ -8556,7 +8549,7 @@ 

      context.session.assertPerm('admin')

      ginfo = get_user(group)

      if not ginfo or ginfo['usertype'] != koji.USERTYPES['GROUP']:

-         raise koji.GenericError("Not a group: %s" % group)

+         raise koji.GenericError("No such group: %s" % group)

      group_id = ginfo['id']

      columns = ('id', 'name', 'usertype', 'array_agg(krb_principal)')

      aliases = ('id', 'name', 'usertype', 'krb_principals')
@@ -8580,7 +8573,7 @@ 

  def set_user_status(user, status):

      context.session.assertPerm('admin')

      if not koji.USER_STATUS.get(status):

-         raise koji.GenericError('invalid status: %s' % status)

+         raise koji.GenericError('No such status: %s' % status)

      if user['status'] == status:

          # nothing to do

          return
@@ -8589,7 +8582,7 @@ 

      rows = _dml(update, locals())

      # sanity check

      if rows == 0:

-         raise koji.GenericError('invalid user ID: %i' % user_id)

+         raise koji.GenericError('No such user ID: %i' % user_id)

  

  

  def list_cgs():
@@ -8673,7 +8666,7 @@ 

      cg = lookup_name('content_generator', cg, strict=True)

      if user is None:

          if not context.session.logged_in:

-             raise koji.AuthError("Not logged in")

+             raise koji.AuthError("Not logged-in")

          user = context.session.user_id

      user = get_user(user, strict=True)

      clauses = ['active = TRUE', 'user_id = %(user_id)s', 'cg_id = %(cg_id)s']
@@ -9144,7 +9137,7 @@ 

                  elif order in self.columns:

                      orderCol = order

                  else:

-                     raise Exception('invalid order: ' + order)

+                     raise Exception('Invalid order: ' + order)

                  order_exprs.append(orderCol + direction)

              return 'ORDER BY ' + ', '.join(order_exprs)

          else:
@@ -9320,7 +9313,7 @@ 

              if isinstance(data['package'], str):

                  return {'id': None, 'name': data['package']}

              else:

-                 raise koji.GenericError("Invalid package: %s" % data['package'])

+                 raise koji.GenericError("No such package: %s" % data['package'])

          return pkginfo

      if 'build' in data:

          binfo = get_build(data['build'], strict=True)
@@ -10420,7 +10413,7 @@ 

          q = """SELECT id, EXTRACT(EPOCH FROM time) FROM events"""

          if before is not None:

              if not isinstance(before, NUMERIC_TYPES):

-                 raise koji.GenericError('invalid type for before: %s' % type(before))

+                 raise koji.GenericError('Invalid type for before: %s' % type(before))

              # use the repr() conversion because it retains more precision than the

              # string conversion

              q += """ WHERE EXTRACT(EPOCH FROM time) < %(before)r"""
@@ -10571,7 +10564,7 @@ 

                  chksum = get_verify_class(verify)()

                  if tail is not None:

                      if tail < 0:

-                         raise koji.GenericError("invalid tail value: %r" % tail)

+                         raise koji.GenericError("Invalid tail value: %r" % tail)

                      offset = max(st.st_size - tail, 0)

                      os.lseek(fd, offset, 0)

                  length = 0
@@ -11080,7 +11073,7 @@ 

              build_info = get_build(buildID)

              if not build_info:

                  if strict:

-                     raise koji.GenericError("Build %s doesn't exist" % buildID)

+                     raise koji.GenericError("No such build: %s" % buildID)

                  return _applyQueryOpts([], queryOpts)

              srpms = self.listRPMs(buildID=build_info['id'], arches='src')

              if not srpms:
@@ -11093,7 +11086,7 @@ 

              if not filepath:

                  raise koji.GenericError('filepath must be specified with taskID')

              if filepath.startswith('/') or '../' in filepath:

-                 raise koji.GenericError('invalid filepath: %s' % filepath)

+                 raise koji.GenericError('Invalid filepath: %s' % filepath)

              srpm_path = joinpath(koji.pathinfo.work(),

                                   koji.pathinfo.taskrelpath(taskID),

                                   filepath)
@@ -11114,7 +11107,7 @@ 

              elif isinstance(before, int):

                  pass

              else:

-                 raise koji.GenericError('invalid type for before: %s' % type(before))

+                 raise koji.GenericError('Invalid type for before: %s' % type(before))

  

          if after:

              if isinstance(after, datetime.datetime):
@@ -11124,7 +11117,7 @@ 

              elif isinstance(after, int):

                  pass

              else:

-                 raise koji.GenericError('invalid type for after: %s' % type(after))

+                 raise koji.GenericError('Invalid type for after: %s' % type(after))

  

          results = []

  
@@ -11754,7 +11747,7 @@ 

              if not filepath:

                  raise koji.GenericError('filepath must be specified with taskID')

              if filepath.startswith('/') or '../' in filepath:

-                 raise koji.GenericError('invalid filepath: %s' % filepath)

+                 raise koji.GenericError('Invalid filepath: %s' % filepath)

              rpm_path = joinpath(koji.pathinfo.work(),

                                  koji.pathinfo.taskrelpath(taskID),

                                  filepath)
@@ -11795,7 +11788,7 @@ 

          r = query.executeOne()

          if not r:

              if strict:

-                 raise koji.GenericError('Invalid package name: %s' % name)

+                 raise koji.GenericError('No such package name: %s' % name)

              return None

          return r['id']

  
@@ -11976,14 +11969,14 @@ 

          """Enable logins by the specified user"""

          user = get_user(username)

          if not user:

-             raise koji.GenericError('unknown user: %s' % username)

+             raise koji.GenericError('No such user: %s' % username)

          set_user_status(user, koji.USER_STATUS['NORMAL'])

  

      def disableUser(self, username):

          """Disable logins by the specified user"""

          user = get_user(username)

          if not user:

-             raise koji.GenericError('unknown user: %s' % username)

+             raise koji.GenericError('No such user: %s' % username)

          set_user_status(user, koji.USER_STATUS['BLOCKED'])

  

      listCGs = staticmethod(list_cgs)
@@ -12877,7 +12870,7 @@ 

          owner or the notification or an admin, raise a GenericError."""

          currentUser = self.getLoggedInUser()

          if not currentUser:

-             raise koji.GenericError('not logged-in')

+             raise koji.GenericError('Not logged-in')

  

          orig_notif = self.getBuildNotification(id, strict=True)

          if not (orig_notif['user_id'] == currentUser['id'] or self.hasPerm('admin')):
@@ -12908,11 +12901,11 @@ 

          and the currently logged-in user is not an admin, raise a GenericError."""

          currentUser = self.getLoggedInUser()

          if not currentUser:

-             raise koji.GenericError('not logged in')

+             raise koji.GenericError('Not logged-in')

  

          notificationUser = self.getUser(user_id)

          if not notificationUser:

-             raise koji.GenericError('invalid user ID: %s' % user_id)

+             raise koji.GenericError('No such user ID: %s' % user_id)

  

          if not (notificationUser['id'] == currentUser['id'] or self.hasPerm('admin')):

              raise koji.GenericError('user %s cannot create notifications for user %s' %
@@ -12946,7 +12939,7 @@ 

          notification = self.getBuildNotification(id, strict=True)

          currentUser = self.getLoggedInUser()

          if not currentUser:

-             raise koji.GenericError('not logged-in')

+             raise koji.GenericError('Not logged-in')

  

          if not (notification['user_id'] == currentUser['id'] or

                  self.hasPerm('admin')):
@@ -12961,11 +12954,11 @@ 

          admin, raise a GenericError."""

          currentUser = self.getLoggedInUser()

          if not currentUser:

-             raise koji.GenericError('not logged in')

+             raise koji.GenericError('Not logged-in')

  

          notificationUser = self.getUser(user_id)

          if not notificationUser:

-             raise koji.GenericError('invalid user ID: %s' % user_id)

+             raise koji.GenericError('No such user ID: %s' % user_id)

  

          if not (notificationUser['id'] == currentUser['id'] or self.hasPerm('admin')):

              raise koji.GenericError('user %s cannot create notification blocks for user %s' %
@@ -12993,7 +12986,7 @@ 

          block = self.getBuildNotificationBlock(id, strict=True)

          currentUser = self.getLoggedInUser()

          if not currentUser:

-             raise koji.GenericError('not logged-in')

+             raise koji.GenericError('Not logged-in')

  

          if not (block['user_id'] == currentUser['id'] or

                  self.hasPerm('admin')):
@@ -13054,7 +13047,7 @@ 

              return _applyQueryOpts([], queryOpts)

          table = self._searchTables.get(type)

          if not table:

-             raise koji.GenericError('unknown search type: %s' % type)

+             raise koji.GenericError('No such search type: %s' % type)

  

          if matchType == 'glob':

              oper = 'ilike'
@@ -13396,7 +13389,7 @@ 

              if context.session.logged_in:

                  raise koji.AuthError("User %i is not a host" % context.session.user_id)

              else:

-                 raise koji.AuthError("Not logged in")

+                 raise koji.AuthError("Not logged-in")

          self.id = id

          self.same_host = (id == remote_id)

  
@@ -13742,7 +13735,7 @@ 

          for relpath in [srpm] + rpms:

              fn = "%s/%s" % (uploadpath, relpath)

              if not os.path.exists(fn):

-                 raise koji.GenericError("no such file: %s" % fn)

+                 raise koji.GenericError("No such file: %s" % fn)

  

          rpms = check_noarch_rpms(uploadpath, rpms, logs=logs)

  
@@ -14519,7 +14512,7 @@ 

                      pass

                  else:

                      if not ignore_unknown:

-                         logger.error("Unknown file for %(group_id)s:%(artifact_id)s:%(version)s",

+                         logger.error("No such file for %(group_id)s:%(artifact_id)s:%(version)s",

                                       maven_info)

                          if build_id:

                              build = get_build(build_id)
@@ -14530,7 +14523,7 @@ 

                              logger.error("Size mismatch, br: %i, db: %i",

                                           fileinfo['size'], tag_archive['size'])

                          raise koji.BuildrootError(

-                             'Unknown file in build environment: %s, size: %s' %

+                             'No such file in build environment: %s, size: %s' %

                              ('%s/%s' % (fileinfo['path'], fileinfo['filename']), fileinfo['size']))

  

          return br.updateArchiveList(archives, project)

@@ -155,7 +155,7 @@ 

              handle_add_group(options, session, arguments)

          self.assertExitCode(ex, 1)

          actual = stderr.getvalue()

-         expected = 'Unknown tag: tag\n'

+         expected = 'No such tag: tag\n'

          self.assertMultiLineEqual(actual, expected)

  

          # Finally, assert that things were called as we expected.

@@ -1,12 +1,12 @@ 

  from __future__ import absolute_import

  import koji

  import mock

- import unittest

  from six.moves import StringIO

  

  from koji_cli.commands import handle_add_notification

+ from . import utils

  

- class TestAddNotification(unittest.TestCase):

+ class TestAddNotification(utils.CliTestCase):

      def setUp(self):

          self.options = mock.MagicMock()

          self.options.quiet = True
@@ -114,3 +114,29 @@ 

              handle_add_notification(self.options, self.session, ['bogus'])

  

          self.session.createNotification.assert_not_called()

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_handle_add_notification_non_exist_tag(self, stderr):

+         tag = 'tag_a'

+         expected = "Usage: %s add-notification [options]\n" \

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

+                    "%s: error: No such tag: %s\n" % (self.progname, self.progname, tag)

+ 

+         self.session.getTagID.side_effect = koji.GenericError

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_notification(self.options, self.session, ['--tag', tag])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_handle_add_notification_non_exist_pkg(self, stderr):

+         pkg = 'pkg_a'

+         expected = "Usage: %s add-notification [options]\n" \

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

+                    "%s: error: No such package: %s\n" % (self.progname, self.progname, pkg)

+ 

+         self.session.getPackageID.return_value = None

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_notification(self.options, self.session, ['--package', pkg])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

@@ -1,11 +1,11 @@ 

  from __future__ import absolute_import

  

- import mock

  import os

- import six

  import sys

  import unittest

  

+ import mock

+ import six

  from mock import call

  

  from koji_cli.commands import handle_add_pkg
@@ -133,7 +133,7 @@ 

              handle_add_pkg(options, session, args)

          self.assertExitCode(ex, 1)

          actual = stderr.getvalue()

-         expected = 'User owner does not exist\n'

+         expected = 'No such user: %s\n' % owner

          self.assertMultiLineEqual(actual, expected)

          # Finally, assert that things were called as we expected.

          activate_session_mock.assert_not_called()
@@ -168,7 +168,7 @@ 

              handle_add_pkg(options, session, args)

          self.assertExitCode(ex, 1)

          actual = stdout.getvalue()

-         expected = 'No such tag: tag\n'

+         expected = 'No such tag: %s\n' % tag

          self.assertMultiLineEqual(actual, expected)

          # Finally, assert that things were called as we expected.

          activate_session_mock.assert_called_once_with(session, options)

@@ -0,0 +1,64 @@ 

+ from __future__ import absolute_import

+ 

+ from six.moves import StringIO

+ import mock

+ 

+ import koji

+ from koji_cli.commands import handle_add_tag_inheritance

+ from . import utils

+ 

+ 

+ class TestAddTagInheritance(utils.CliTestCase):

+     def setUp(self):

+         self.options = mock.MagicMock()

+         self.options.debug = False

+         self.session = mock.MagicMock()

+         self.session.getAPIVersion.return_value = koji.API_VERSION

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_add_tag_inheritance_without_option(self, stderr):

+         expected = "Usage: %s add-tag-inheritance [options] <tag> <parent-tag>\n" \

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

+                    "%s: error: This command takes exctly two argument: " \

+                    "a tag name or ID and that tag's new parent name " \

+                    "or ID\n" % (self.progname, self.progname)

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_tag_inheritance(self.options, self.session, [])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_add_tag_inheritance_non_exist_tag(self, stderr):

+         tag = 'test-tag'

+         parent_tag = 'parent-test-tag'

+         expected = "Usage: %s add-tag-inheritance [options] <tag> <parent-tag>\n" \

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

+                    "%s: error: No such tag: %s\n" % (self.progname, self.progname, tag)

+         self.session.getTag.return_value = None

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_tag_inheritance(self.options, self.session, [tag, parent_tag])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_add_tag_inheritance_non_exist_parent_tag(self, stderr):

+         side_effect_result = [{'arches': 'x86_64',

+                                'extra': {},

+                                'id': 1,

+                                'locked': False,

+                                'maven_include_all': False,

+                                'maven_support': False,

+                                'name': 'test-tag',

+                                'perm': None,

+                                'perm_id': None},

+                               None]

+         tag = 'test-tag'

+         parent_tag = 'parent-test-tag'

+         expected = "Usage: %s add-tag-inheritance [options] <tag> <parent-tag>\n" \

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

+                    "%s: error: No such tag: %s\n" % (self.progname, self.progname, parent_tag)

+         self.session.getTag.side_effect = side_effect_result

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_tag_inheritance(self.options, self.session, [tag, parent_tag])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

@@ -0,0 +1,85 @@ 

+ from __future__ import absolute_import

+ 

+ import mock

+ from six.moves import StringIO

+ 

+ import koji

+ from koji_cli.commands import handle_add_target

+ from . import utils

+ 

+ 

+ class TestAddTarget(utils.CliTestCase):

+     def setUp(self):

+         self.options = mock.MagicMock()

+         self.options.debug = False

+         self.session = mock.MagicMock()

+         self.session.getAPIVersion.return_value = koji.API_VERSION

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_add_target_without_option(self, stderr):

+         expected = "Usage: %s add-target <name> <build tag> <dest tag>\n" \

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

+                    "%s: error: Please specify a target name, a build tag, " \

+                    "and destination tag\n" % (self.progname, self.progname)

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_target(self.options, self.session, [])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_add_target_non_exist_tag(self, stderr):

+         target = 'test-target'

+         tag = 'test-tag'

+         dest_tag = 'test-dest-tag'

+         expected = "No such tag: %s\n" % tag

+         self.session.getTag.return_value = None

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_target(self.options, self.session, [target, tag, dest_tag])

+         self.assertExitCode(ex, 1)

+         self.assert_console_message(stderr, expected)

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_add_target_tag_without_arch(self, stderr):

+         tag_info = {'arches': None,

+                     'extra': {},

+                     'id': 1,

+                     'locked': False,

+                     'maven_include_all': False,

+                     'maven_support': False,

+                     'name': 'test-tag',

+                     'perm': None,

+                     'perm_id': None}

+         target = 'test-target'

+         tag = 'test-tag'

+         dest_tag = 'test-dest-tag'

+         expected = "Build tag has no arches: %s\n" % tag

+         self.session.getTag.return_value = tag_info

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_target(self.options, self.session, [target, tag, dest_tag])

+         self.assertExitCode(ex, 1)

+         self.assert_console_message(stderr, expected)

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_add_target_non_exist_dest_tag(self, stderr):

+         side_effect_result = [{'arches': 'x86_64',

+                                'extra': {},

+                                'id': 1,

+                                'locked': False,

+                                'maven_include_all': False,

+                                'maven_support': False,

+                                'name': 'test-tag',

+                                'perm': None,

+                                'perm_id': None

+                                },

+                               None,

+                               ]

+ 

+         target = 'test-target'

+         tag = 'test-tag'

+         dest_tag = 'test-dest-tag'

+         expected = "No such destination tag: %s\n" % dest_tag

+         self.session.getTag.side_effect = side_effect_result

+         with self.assertRaises(SystemExit) as ex:

+             handle_add_target(self.options, self.session, [target, tag, dest_tag])

+         self.assertExitCode(ex, 1)

+         self.assert_console_message(stderr, expected)

@@ -36,7 +36,7 @@ 

              handle_block_group(options, session, arguments)

          self.assertExitCode(ex, 1)

          actual = stderr.getvalue()

-         expected = 'Unknown tag: %s\n' % tag

+         expected = 'No such tag: %s\n' % tag

          self.assertMultiLineEqual(actual, expected)

  

          # Finally, assert that things were called as we expected.

@@ -0,0 +1,41 @@ 

+ from __future__ import absolute_import

+ import koji

+ import mock

+ from six.moves import StringIO

+ 

+ from koji_cli.commands import handle_block_notification

+ from . import utils

+ 

+ 

+ class TestBlockNotification(utils.CliTestCase):

+     def setUp(self):

+         self.options = mock.MagicMock()

+         self.options.debug = False

+         self.session = mock.MagicMock()

+         self.session.getAPIVersion.return_value = koji.API_VERSION

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_handle_block_notification_non_exist_tag(self, stderr):

+         tag = 'test-tag'

+         expected = "Usage: %s block-notification [options]\n" \

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

+                    "%s: error: No such tag: %s\n" % (self.progname, self.progname, tag)

+ 

+         self.session.getTagID.side_effect = koji.GenericError

+         with self.assertRaises(SystemExit) as ex:

+             handle_block_notification(self.options, self.session, ['--tag', tag])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

+ 

+     @mock.patch('sys.stderr', new_callable=StringIO)

+     def test_handle_block_notification_non_exist_pkg(self, stderr):

+         pkg = 'test-pkg'

+         expected = "Usage: %s block-notification [options]\n" \

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

+                    "%s: error: No such package: %s\n" % (self.progname, self.progname, pkg)

+ 

+         self.session.getPackageID.return_value = None

+         with self.assertRaises(SystemExit) as ex:

+             handle_block_notification(self.options, self.session, ['--package', pkg])

+         self.assertExitCode(ex, 2)

+         self.assert_console_message(stderr, expected)

@@ -1,9 +1,10 @@ 

  from __future__ import absolute_import

- import mock

+ 

  import os

- import six

  import sys

  

+ import mock

+ import six

  from mock import call

  

  from koji_cli.commands import handle_block_pkg
@@ -140,7 +141,7 @@ 

              handle_block_pkg(options, session, args)

          self.assertExitCode(ex, 1)

          actual = stderr.getvalue()

-         expected = 'No such tag: tag\n'

+         expected = 'No such tag: %s\n' % tag

          self.assertMultiLineEqual(actual, expected)

          # Finally, assert that things were called as we expected.

          activate_session_mock.assert_called_once_with(session, options)

file modified
+2 -2
@@ -357,7 +357,7 @@ 

              handle_build(self.options, self.session, args)

          self.assertExitCode(ex, 2)

          actual = stderr.getvalue()

-         expected = self.format_error_message( "Unknown build target: target")

+         expected = self.format_error_message( "No such build target: target")

          self.assertMultiLineEqual(actual, expected)

          # Finally, assert that things were called as we expected.

          activate_session_mock.assert_called_once_with(self.session, self.options)
@@ -401,7 +401,7 @@ 

              handle_build(self.options, self.session, args)

          self.assertExitCode(ex, 2)

          actual = stderr.getvalue()

-         expected = self.format_error_message("Unknown destination tag: dest_tag_name")

+         expected = self.format_error_message("No such destination tag: dest_tag_name")

          self.assertMultiLineEqual(actual, expected)

          # Finally, assert that things were called as we expected.

          activate_session_mock.assert_called_once_with(self.session, self.options)

@@ -202,7 +202,7 @@ 

          expected = """Usage: %s chain-build [options] <target> <URL> [<URL> [:] <URL> [:] <URL> ...]

  (Specify the --help global option for a list of other help options)

  

- %s: error: Unknown build target: target

+ %s: error: No such build target: target

  """ % (progname, progname)

          self.assertMultiLineEqual(actual, expected)

          # Finally, assert that things were called as we expected.

@@ -94,7 +94,7 @@ 

              self.options,

              self.session,

              args,

-             stderr=self.format_error_message("Unknown src-tag: src-tag"),

+             stderr=self.format_error_message("No such src-tag: src-tag"),

              activate_session=None)

          self.activate_session.assert_called_once()

          self.activate_session.getTag.has_called([call('src-tag'),

@@ -1,10 +1,11 @@ 

  from __future__ import absolute_import

  from __future__ import print_function

+ 

+ import unittest

  import copy

+ 

  import mock

  import six

- import unittest

- 

  

  from koji_cli.commands import handle_dist_repo

  from . import utils
@@ -26,7 +27,7 @@ 

          'arches': 'x86_64',

          'maven_include_all': False,

          'perm_id': None

-      }

+     }

  

      def setUp(self):

          self.task_id = 1001
@@ -91,10 +92,10 @@ 

          arguments = [self.tag_name, self.fake_key]

          self.__run_test_handle_dist_repo(arguments, True)

          self.watch_tasks.assert_called_with(

-                 self.session,

-                 [self.task_id],

-                 quiet=self.options.quiet,

-                 poll_interval=self.options.poll_interval, topurl=self.options.topurl)

+             self.session,

+             [self.task_id],

+             quiet=self.options.quiet,

+             poll_interval=self.options.poll_interval, topurl=self.options.topurl)

  

      def test_handle_dist_repo_nowait(self):

          arguments = [self.tag_name, self.fake_key, '--nowait']
@@ -120,7 +121,8 @@ 

                      '--allow-missing-signatures',

                      '--skip-missing-signatures'

                  ],

-                 'err_str': 'allow_missing_signatures and skip_missing_signatures are mutually exclusive'

+                 'err_str': 'allow_missing_signatures and skip_missing_signatures are mutually '

+                            'exclusive'

              }

          ]

  
@@ -137,7 +139,7 @@ 

  

          # Case 2. Tag Error

          self.session.getTag.return_value = {}

-         expected = self.format_error_message('unknown tag %s' % self.tag_name)

+         expected = self.format_error_message('No such tag: %s' % self.tag_name)

          self.assert_system_exit(

              handle_dist_repo,

              self.options,
@@ -218,7 +220,7 @@ 

                  stderr=expected)

  

          # normal case

-         self.session.uploadWrapper = lambda *args, **kwargs: print ('uploadWrapper ...')

+         self.session.uploadWrapper = lambda *args, **kwargs: print('uploadWrapper ...')

          self.session.getTag.return_value.update({'arches': 'x86_64, i686'})

          expected = 'uploadWrapper ...\n\n'

          arguments += ['--arch', 'x86_64', '--arch', 'i686']
@@ -234,11 +236,11 @@ 

          self.session.getRepo.return_value = {}

          expected = self.format_error_message("Can't find repo for tag: %s" % "test-repo1")