#1280 put fix_pyver before printing command help
Merged 4 years ago by mikem. Opened 5 years ago by tkopecek.
tkopecek/koji issue1276  into  master

file modified
+12 -8
@@ -167,12 +167,11 @@ 

                     (sys.prefix, sys.version_info[0], sys.version_info[1])

      load_plugins(options, plugins_path)

  

-     if options.help_commands:

-         list_commands()

-         sys.exit(0)

      if not args:

-         list_commands()

-         sys.exit(0)

+         options.help_commands = True

+     if options.help_commands:

+         # hijack args to [return_code, message]

+         return options, '_list_commands', [0, '']

  

      aliases = {

          'cancel-task' : 'cancel',
@@ -199,9 +198,8 @@ 

      elif ('handle_' + cmd) in globals():

          cmd = 'handle_' + cmd

      else:

-         list_commands()

-         parser.error('Unknown command: %s' % args[0])

-         assert False  # pragma: no cover

+         # hijack args to [return_code, message]

+         return options, '_list_commands', [1, 'Unknown command: %s' % args[0]]

  

      return options, cmd, args[1:]

  
@@ -305,6 +303,12 @@ 

  

      session_opts = koji.grab_session_options(options)

      session = koji.ClientSession(options.server, session_opts)

+     if command == '_list_commands':

+         list_commands()

+         if args[0] != 0:

+             logger.error(args[1])

+         sys.exit(args[0])

+     # run handler

      rv = 0

      try:

          rv = locals()[command].__call__(options, session, args)

If pyver forces koji to reload under different interpreter, it could
happen, that different set of plugins is available. In such case help
printed under original interpreter can be misleading.

Fixes: https://pagure.io/koji/issue/1276

Metadata Update from @tkopecek:
- Pull-request tagged with: testing-ready

5 years ago

Metadata Update from @jcupova:
- Pull-request tagged with: testing-done

4 years ago

Commit 790bc25 fixes this pull-request

Pull-Request has been merged by mikem

4 years ago