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

bin/omero entrypoint #229

Closed manics closed 4 years ago

manics commented 4 years ago

Closes https://github.com/ome/omero-py/pull/219

Converts bin/omero into an entrypoint (cross-platform, so *.bat files are no longer needed).

Testing: omero CLI should work as before.

There are probably loads of other cleanups that could be done such as removing the path detection (sys.path.append(vlb)) now that OMERODIR is required for anything server side, but I've tried to keep the changes minimal for now.

bin/omero was renamed to src/omero/main.py, it looks like a new file because I had to wrap most of the script in a main() function but it's mostly indentation and flake8 fixes.

Could do with someone testing this on Windows

joshmoore commented 4 years ago
================ 1171 passed, 154 skipped, 1 xfailed in 33.78s ================
4564___________________________________ summary ___________________________________
4565  py37-win: commands succeeded

So tests are certainly running on travis. It'd be good to review that bin/omero tests are skipped on Windows, though.

joshmoore commented 4 years ago

Changes (with ignore whitespace) all look good.

dominikl commented 4 years ago

Testing on Windows10 VM.

C:\Users\IEUser\omero-py>omero --help
Traceback (most recent call last):
  File "C:\Users\IEUser\AppData\Local\Programs\Python\Python38\Scripts\omero-script.py", line 11, in <module>
    load_entry_point('omero-py==5.7.2.dev0', 'console_scripts', 'omero')()
  File "c:\users\ieuser\appdata\local\programs\python\python38\lib\site-packages\omero\main.py", line 69, in main
    exe = readlink()
  File "c:\users\ieuser\appdata\local\programs\python\python38\lib\site-packages\omero\main.py", line 52, in readlink
    while stat.S_ISLNK(os.lstat(file)[stat.ST_MODE]):
FileNotFoundError: [WinError 2] The system cannot find the file specified: 'C:\\Users\\IEUser\\AppData\\Local\\Programs\\Python\\Python38\\Scripts\\omero'
manics commented 4 years ago

Looks like bin/omero was found and executed but it's now failing in readlink() during the path detection:

def readlink(file=sys.argv[0]):
    """
    Resolve symlinks and similar. This is useful to allow
    linking this file under /usr/bin/, for example.
    """
    import stat

    file = sys.argv[0]
    while stat.S_ISLNK(os.lstat(file)[stat.ST_MODE]):   #### Failing on this line
        target = os.readlink(file)
        if target[0] != "/":
            file = os.path.join(os.path.dirname(file), target)
        else:
            file = target

    file = os.path.abspath(file)
    return file
    exe = readlink()
    top = os.path.join(exe, os.pardir, os.pardir)

    #
    # This list needs to be kept in line with omero.cli.CLI._env
    #
    top = os.path.normpath(top)
    var = os.path.join(top, "var")
    vlb = os.path.join(var, "lib")
    sys.path.append(vlb)

@joshmoore Is it safe to remove, on the assumption that OMERODIR will be set for anything requiring that path?

joshmoore commented 4 years ago

@joshmoore Is it safe to remove,

It's similar to OMERO_HOME in that it will be the removal of a little known feature, but a removal nonetheless.

manics commented 4 years ago

If I'm reading the code correctly, assuming exe = /path/to/venv/bin/omero:

What's the expected use of /path/to/venv/var/lib ?

joshmoore commented 4 years ago

Dim memory of a place to put libs for scripts?

manics commented 4 years ago

This is now working on Windows, I've tested it in a VM with omero login wss://idr.openmicroscopy.org/omero-ws

There are still loads of other warnings/errors since Windows isn't (yet) properly supported by omero-py.

dominikl commented 4 years ago

👍

C:\Users\IEUser\omero-py>omero login
Server: [localhost:4064]demo.openmicroscopy.org
Username: [IEUser]dlindner
Password:
Created session for dlindner@demo.openmicroscopy.org:4064. Idle timeout: 10 min. Current group: 2018-02
snoopycrimecop commented 4 years ago

Conflicting PR. Removed from build OMERO-python-superbuild-push#365. See the console output for more details. Possible conflicts:

--conflicts

snoopycrimecop commented 4 years ago

Conflicting PR. Removed from build OMERO-python-superbuild-push#366. See the console output for more details. Possible conflicts:

--conflicts Conflict resolved in build OMERO-python-superbuild-push#369. See the console output for more details.