ome / omero-py

Python project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
20 stars 33 forks source link

CLI: Fix sort(lambda) under Python 3 #264

Closed joshmoore closed 3 years ago

joshmoore commented 3 years ago

Discovered while testing for https://forum.image.sc/t/omero-cli-exit-status/44110

Without this PR:

(z) /opt/omero-py $omero errors
Traceback (most recent call last):
  File "/usr/local/anaconda3/envs/z/bin/omero", line 33, in <module>
    sys.exit(load_entry_point('omero-py', 'console_scripts', 'omero')())
  File "/opt/omero-py/target/omero/main.py", line 125, in main
    rv = omero.cli.argv()
  File "/opt/omero-py/target/omero/cli.py", line 1784, in argv
    cli.invoke(args[1:])
  File "/opt/omero-py/target/omero/cli.py", line 1222, in invoke
    stop = self.onecmd(line, previous_args)
  File "/opt/omero-py/target/omero/cli.py", line 1299, in onecmd
    self.execute(line, previous_args)
  File "/opt/omero-py/target/omero/cli.py", line 1381, in execute
    args.func(args)
  File "/opt/omero-py/target/omero/plugins/basics.py", line 296, in __call__
    combined.sort(lambda a, b: cmp(a[1].rcode, b[1].rcode))
TypeError: sort() takes no positional arguments

With this PR:

(z) /opt/omero-py $omero errors
   52          hql   BAD_QUERY  'Bad query: %s'
   52       search   BAD_QUERY  'Bad query: %s'
   53          hql   NOT_ADMIN  'SecurityViolation: Current user is not an admin an...'
   53       search   NOT_ADMIN  'SecurityViolation: Current user is not an admin an...'
   67          hql    NO_QUIET  'Can't ask for query with --quiet option'
   67       search    NO_QUIET  'Can't ask for query with --quiet option'
  123        admin  NOT_WINDOWS 'Not Windows'
  200        admin       SETUP  'Error during service user set up:  (%s) %s'
  201        admin     RUNNING  '%s is already running. Use stop first'
  202        admin  NO_SERVICE  '%s service deleted.'
  300        admin  BAD_CONFIG  'Bad configuration: No IceGrid.Node.Data property'
  400        admin  WIN_CONFIG  '%s is not in this directory. Abortin...'
  666        admin    NO_WIN32  'Could not import win32service and/or win32evtlogut...'
imagesc-bot commented 3 years ago

This pull request has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/omero-cli-exit-status/44110/2

manics commented 3 years ago

Is it worth adding a basic test to check it runs?

joshmoore commented 3 years ago

Green. Propose for patch release.