├── .bumpversion.cfg ├── .github └── workflows │ ├── codeql.yml │ └── workflow.yml ├── .gitignore ├── .mailmap ├── .readthedocs.yml ├── CHANGELOG.md ├── LICENSE.txt ├── README.rst ├── docs ├── Makefile ├── conf.py ├── index.rst ├── make.bat ├── omero.all.rst ├── omero.api.rst ├── omero.callbacks.rst ├── omero.cli.rst ├── omero.clients.rst ├── omero.columns.rst ├── omero.config.rst ├── omero.conversions.rst ├── omero.gateway.pytest_fixtures.rst ├── omero.gateway.rst ├── omero.gateway.scripts.dbhelpers.rst ├── omero.gateway.scripts.rst ├── omero.gateway.scripts.testdb_create.rst ├── omero.gateway.utils.rst ├── omero.grid.monitors.rst ├── omero.grid.rst ├── omero.hdfstorageV2.rst ├── omero.install.bzip2_tool.rst ├── omero.install.config_parser.rst ├── omero.install.jvmcfg.rst ├── omero.install.logs_library.rst ├── omero.install.perf_test.rst ├── omero.install.python_warning.rst ├── omero.install.rst ├── omero.install.versions.rst ├── omero.install.win_set_path.rst ├── omero.install.windows_warning.rst ├── omero.java.rst ├── omero.main.rst ├── omero.min.rst ├── omero.model.rst ├── omero.plugins.admin.rst ├── omero.plugins.basics.rst ├── omero.plugins.chgrp.rst ├── omero.plugins.chown.rst ├── omero.plugins.db.rst ├── omero.plugins.delete.rst ├── omero.plugins.download.rst ├── omero.plugins.export.rst ├── omero.plugins.fs.rst ├── omero.plugins.group.rst ├── omero.plugins.hql.rst ├── omero.plugins.import.rst ├── omero.plugins.ldap.rst ├── omero.plugins.node.rst ├── omero.plugins.obj.rst ├── omero.plugins.perf.rst ├── omero.plugins.prefs.rst ├── omero.plugins.rst ├── omero.plugins.script.rst ├── omero.plugins.search.rst ├── omero.plugins.sessions.rst ├── omero.plugins.submit.rst ├── omero.plugins.tag.rst ├── omero.plugins.user.rst ├── omero.processor.rst ├── omero.romio.rst ├── omero.rst ├── omero.rtypes.rst ├── omero.scripts.rst ├── omero.tables.rst ├── omero.testlib.cli.rst ├── omero.testlib.rst ├── omero.testlib.script.rst ├── omero.util.OmeroPopo.rst ├── omero.util.ROIDrawingUtils.rst ├── omero.util.ROI_utils.rst ├── omero.util.cleanse.rst ├── omero.util.concurrency.rst ├── omero.util.decorators.rst ├── omero.util.figureUtil.rst ├── omero.util.imageUtil.rst ├── omero.util.image_utils.rst ├── omero.util.import_candidates.rst ├── omero.util.importperf.rst ├── omero.util.metadata_mapannotations.rst ├── omero.util.metadata_utils.rst ├── omero.util.pixelstypetopython.rst ├── omero.util.populate_metadata.rst ├── omero.util.populate_roi.rst ├── omero.util.pydict_text_io.rst ├── omero.util.roi_handling_utils.rst ├── omero.util.rst ├── omero.util.script_utils.rst ├── omero.util.sessions.rst ├── omero.util.temp_files.rst ├── omero.util.text.rst ├── omero.util.tiles.rst └── omero.util.upgrade_check.rst ├── examples ├── createSession.py ├── load.omero ├── projection_1.py ├── submit.omero └── upload.omero ├── ice.config ├── manualtests ├── README.txt └── populate_roi_test.py ├── pytest.ini ├── setup.py ├── src ├── IceImport.py ├── omero │ ├── __init__.py │ ├── all.py │ ├── api │ │ └── __init__.py │ ├── callbacks.py │ ├── cli.py │ ├── clients.py │ ├── columns.py │ ├── config.py │ ├── conversions.py │ ├── fs │ │ └── __init__.py │ ├── gateway │ │ ├── __init__.py │ │ ├── pilfonts │ │ │ ├── B08.pbm │ │ │ ├── B08.pil │ │ │ ├── B10.pbm │ │ │ ├── B10.pil │ │ │ ├── B12.pbm │ │ │ ├── B12.pil │ │ │ ├── B14.pbm │ │ │ ├── B14.pil │ │ │ ├── B18.pbm │ │ │ ├── B18.pil │ │ │ ├── B20.pbm │ │ │ ├── B20.pil │ │ │ ├── B24.pbm │ │ │ ├── B24.pil │ │ │ ├── B32.pbm │ │ │ ├── B32.pil │ │ │ ├── B40.pbm │ │ │ ├── B40.pil │ │ │ ├── B48.pbm │ │ │ ├── B48.pil │ │ │ ├── B56.pbm │ │ │ ├── B56.pil │ │ │ ├── B64.pbm │ │ │ ├── B64.pil │ │ │ ├── FreeSans.ttf │ │ │ ├── FreeSansBold.ttf │ │ │ ├── FreeSansBoldOblique.ttf │ │ │ └── FreeSansOblique.ttf │ │ ├── pytest_fixtures.py │ │ ├── scripts │ │ │ ├── __init__.py │ │ │ ├── dbhelpers.py │ │ │ └── testdb_create.py │ │ └── utils.py │ ├── grid │ │ ├── __init__.py │ │ └── monitors │ │ │ └── __init__.py │ ├── hdfstorageV2.py │ ├── install │ │ ├── __init__.py │ │ ├── bzip2_tool.py │ │ ├── config_parser.py │ │ ├── jvmcfg.py │ │ ├── logs_library.py │ │ ├── perf_test.py │ │ ├── python_warning.py │ │ ├── versions.py │ │ ├── win_set_path.py │ │ └── windows_warning.py │ ├── java.py │ ├── main.py │ ├── min.py │ ├── model │ │ └── __init__.py │ ├── plugins │ │ ├── __init__.py │ │ ├── _duplicate_deprecated.py │ │ ├── _metadata_deprecated.py │ │ ├── _upload_deprecated.py │ │ ├── admin.py │ │ ├── basics.py │ │ ├── chgrp.py │ │ ├── chown.py │ │ ├── db.py │ │ ├── delete.py │ │ ├── download.py │ │ ├── export.py │ │ ├── fs.py │ │ ├── group.py │ │ ├── hql.py │ │ ├── import.py │ │ ├── ldap.py │ │ ├── node.py │ │ ├── obj.py │ │ ├── perf.py │ │ ├── prefs.py │ │ ├── script.py │ │ ├── search.py │ │ ├── sessions.py │ │ ├── submit.py │ │ ├── tag.py │ │ └── user.py │ ├── processor.py │ ├── romio │ │ └── __init__.py │ ├── rtypes.py │ ├── scripts.py │ ├── sys │ │ └── __init__.py │ ├── tables.py │ ├── testlib │ │ ├── __init__.py │ │ ├── cli.py │ │ └── script.py │ └── util │ │ ├── OmeroPopo.py │ │ ├── ROIDrawingUtils.py │ │ ├── ROI_utils.py │ │ ├── __init__.py │ │ ├── _process_defaultxml.py │ │ ├── cleanse.py │ │ ├── concurrency.py │ │ ├── decorators.py │ │ ├── figureUtil.py │ │ ├── imageUtil.py │ │ ├── image_utils.py │ │ ├── import_candidates.py │ │ ├── importperf.py │ │ ├── metadata_mapannotations.py │ │ ├── metadata_utils.py │ │ ├── pixelstypetopython.py │ │ ├── populate_metadata.py │ │ ├── populate_roi.py │ │ ├── pydict_text_io.py │ │ ├── roi_handling_utils.py │ │ ├── script_utils.py │ │ ├── sessions.py │ │ ├── temp_files.py │ │ ├── text.py │ │ ├── tiles.py │ │ └── upgrade_check.py ├── omero_ext │ ├── __init__.py │ ├── argparse.py │ ├── killableprocess.py │ ├── path.py │ ├── pyinotify.py │ ├── stubout.py │ ├── which.py │ └── winprocess.py ├── omero_model_DetailsI.py ├── omero_model_ElectricPotentialI.py ├── omero_model_FrequencyI.py ├── omero_model_LengthI.py ├── omero_model_PermissionsI.py ├── omero_model_PowerI.py ├── omero_model_PressureI.py ├── omero_model_TemperatureI.py ├── omero_model_TimeI.py ├── omero_model_UnitBase.py ├── omero_sys_ParametersI.py ├── omero_version.py ├── runProcessor.py └── runTables.py ├── test ├── __init__.py ├── conftest.py └── unit │ ├── __init__.py │ ├── clitest │ ├── bulk_import │ │ ├── test_bad │ │ │ └── bulk.yml │ │ ├── test_cols │ │ │ ├── 1.fake │ │ │ ├── bulk.tsv │ │ │ └── bulk.yml │ │ ├── test_dryrun │ │ │ ├── 1.fake │ │ │ ├── bulk.tsv │ │ │ └── bulk.yml │ │ ├── test_include │ │ │ ├── bulk.yml │ │ │ └── inner │ │ │ │ ├── bulk.tsv │ │ │ │ ├── bulk.yml │ │ │ │ └── foo.fake │ │ ├── test_javaargs │ │ │ ├── 1.fake │ │ │ ├── bulk.tsv │ │ │ └── bulk.yml │ │ ├── test_name │ │ │ ├── 1.fake │ │ │ ├── bulk.tsv │ │ │ └── bulk.yml │ │ ├── test_simple │ │ │ ├── 1.fake │ │ │ ├── bulk.tsv │ │ │ └── bulk.yml │ │ └── test_skip │ │ │ ├── 1.fake │ │ │ ├── all.yml │ │ │ ├── bulk.tsv │ │ │ ├── checksum.yml │ │ │ ├── minmax.yml │ │ │ ├── thumbnails.yml │ │ │ └── upgrade.yml │ ├── readers │ │ ├── no_fakes.txt │ │ └── only_fakes.txt │ ├── test_admin.py │ ├── test_admin_noomerodir.py │ ├── test_basics.py │ ├── test_chgrp.py │ ├── test_cli.py │ ├── test_db.py │ ├── test_download.py │ ├── test_export.py │ ├── test_fs.py │ ├── test_group.py │ ├── test_hql.py │ ├── test_import.py │ ├── test_ldap.py │ ├── test_obj.py │ ├── test_prefs.py │ ├── test_rcode.py │ ├── test_script.py │ ├── test_sess.py │ ├── test_sessions.py │ ├── test_tag.py │ └── test_user.py │ ├── fstest │ ├── __init__.py │ └── test_model.py │ ├── gatewaytest │ ├── test_argument_errors.py │ ├── test_build_query.py │ └── test_utils.py │ ├── old_templates.xml │ ├── scriptstest │ ├── test_parse.py │ ├── test_processor.py │ └── test_prototypes.py │ ├── tablestest │ ├── library.py │ ├── test_hdfstorage.py │ └── test_servants.py │ ├── test_clients.py │ ├── test_config.py │ ├── test_conversions.py │ ├── test_gateway.py │ ├── test_jvmcfg.json │ ├── test_jvmcfg.py │ ├── test_metadata_mapannotations.py │ ├── test_metadata_utils.py │ ├── test_model.py │ ├── test_parameters.py │ ├── test_path.py │ ├── test_permissions.py │ ├── test_python_only.py │ ├── test_rois.py │ ├── test_rtypes.py │ ├── test_tempfiles.py │ └── test_util.py └── tox.ini /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 5.20.1.dev0 3 | commit = True 4 | tag = True 5 | sign_tags = True 6 | parse = (?P\d+)\.(?P\d+)\.(?P\d+)(\.(?P[a-z]+)(?P\d+))? 7 | serialize = 8 | {major}.{minor}.{patch}.{release}{build} 9 | {major}.{minor}.{patch} 10 | 11 | [bumpversion:part:release] 12 | optional_value = prod 13 | first_value = dev 14 | values = 15 | dev 16 | prod 17 | 18 | [bumpversion:part:build] 19 | 20 | [bumpversion:file:src/omero_version.py] 21 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | name: "CodeQL Advanced" 2 | 3 | on: 4 | push: 5 | branches: [ "master" ] 6 | pull_request: 7 | branches: [ "master" ] 8 | schedule: 9 | - cron: '15 5 * * 1' 10 | 11 | jobs: 12 | analyze: 13 | name: Analyze (${{ matrix.language }}) 14 | runs-on: ubuntu-latest 15 | permissions: 16 | # required for all workflows 17 | security-events: write 18 | 19 | # required to fetch internal or private CodeQL packs 20 | packages: read 21 | 22 | # only required for workflows in private repositories 23 | actions: read 24 | contents: read 25 | 26 | strategy: 27 | fail-fast: false 28 | matrix: 29 | include: 30 | - language: python 31 | build-mode: none 32 | - language: actions 33 | build-mode: none 34 | steps: 35 | - name: Checkout repository 36 | uses: actions/checkout@v4 37 | 38 | # Initializes the CodeQL tools for scanning. 39 | - name: Initialize CodeQL 40 | uses: github/codeql-action/init@v3 41 | with: 42 | languages: ${{ matrix.language }} 43 | build-mode: ${{ matrix.build-mode }} 44 | 45 | - name: Perform CodeQL Analysis 46 | uses: github/codeql-action/analyze@v3 47 | with: 48 | category: "/language:${{matrix.language}}" 49 | -------------------------------------------------------------------------------- /.github/workflows/workflow.yml: -------------------------------------------------------------------------------- 1 | # https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions 2 | 3 | name: Build 4 | on: 5 | push: 6 | pull_request: 7 | 8 | jobs: 9 | 10 | test: 11 | name: Test 12 | strategy: 13 | # Keep running so we can see if other tests pass 14 | fail-fast: false 15 | matrix: 16 | python-version: 17 | - '3.9' 18 | - '3.10' 19 | - '3.11' 20 | - '3.12' 21 | os: 22 | - ubuntu-22.04 23 | - windows-2019 24 | include: 25 | - python-version: '3.10' 26 | os: macos-14 27 | runs-on: ${{ matrix.os }} 28 | steps: 29 | - name: Get tox target 30 | id: toxtarget 31 | run: | 32 | py=$(echo ${{ matrix.python-version }} | tr -d .) 33 | echo "py=$py" >> $GITHUB_OUTPUT 34 | shell: bash 35 | - uses: actions/checkout@v4 36 | - uses: actions/setup-python@v5 37 | with: 38 | python-version: ${{ matrix.python-version }} 39 | - name: Download the latest OMERO.server 40 | if: matrix.os == 'ubuntu-22.04' 41 | env: 42 | GH_TOKEN: ${{ github.token }} 43 | run: | 44 | gh release download -R ome/openmicroscopy --pattern "OMERO.server*zip" 45 | unzip OMERO.server*.zip && rm OMERO.server*.zip 46 | ln -s OMERO.server* OMERO.current 47 | echo "OMERODIR=${{ github.workspace }}/OMERO.current" >> $GITHUB_ENV 48 | - name: Install dependencies 49 | run: python -mpip install --upgrade wheel pytest tox virtualenv 50 | - name: Run tests 51 | run: tox -e py${{ steps.toxtarget.outputs.py }} 52 | 53 | # https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ 54 | publish-pypi: 55 | name: Pypi 56 | if: startsWith(github.ref, 'refs/tags') 57 | needs: 58 | # Only publish if other jobs passed 59 | - test 60 | runs-on: ubuntu-latest 61 | steps: 62 | - uses: actions/checkout@v4 63 | - uses: actions/setup-python@v5 64 | with: 65 | python-version: '3.9' 66 | - name: Build package 67 | run: | 68 | python -mpip install build 69 | python -m build 70 | - name: Publish to PyPI 71 | uses: pypa/gh-action-pypi-publish@release/v1 72 | with: 73 | password: ${{ secrets.PYPI_PASSWORD }} 74 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.egg 2 | *.pyc 3 | var 4 | build 5 | dist/ 6 | target/ 7 | .DS_Store 8 | .idea 9 | _build 10 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Andreas Knab 2 | Andrew Patterson 3 | Andrew Patterson 4 | Aleksandra Tarkowska 5 | Aleksandra Tarkowska 6 | Aleksandra Tarkowska 7 | Aleksandra Tarkowska 8 | Aleksandra Tarkowska 9 | Aleksandra Tarkowska 10 | Aleksandra Tarkowska 11 | Brian Loranger 12 | Carlos Neves 13 | Carlos Neves 14 | Carlos Neves 15 | Chris Allan 16 | Chris Allan 17 | Chris Allan 18 | Colin Blackburn 19 | Colin Blackburn 20 | Colin Blackburn 21 | Donald MacDonald 22 | Donald MacDonald 23 | Donald MacDonald 24 | Douglas Russell dpwrussell 25 | Emil Rozbicki 26 | Helen Flynn 27 | Harald Waxenegger 28 | Jean-Marie Burel jburel 29 | Jean-Marie Burel jean-marie burel 30 | Jean-Marie Burel 31 | Jeremy Muhlich 32 | Josh Moore 33 | Josh Moore 34 | Josh Moore 35 | Josh Moore 36 | Mark Carroll 37 | Muhanad Zahra 38 | Paul van Schayck pvc-local 39 | Roger Leigh 40 | Roger Leigh 41 | Roger Leigh 42 | Sébastien Besson 43 | Sébastien Simard ssimard 44 | Simon Li 45 | Simone Leo 46 | Will Moore William Moore 47 | Will Moore 48 | Will Moore 49 | Will Moore 50 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # Read the Docs configuration file for Sphinx projects 2 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 3 | 4 | # Required 5 | version: 2 6 | 7 | # Set the OS, Python version and other tools you might need 8 | build: 9 | os: ubuntu-22.04 10 | tools: 11 | python: "3.11" 12 | 13 | # Build documentation in the "docs/" directory with Sphinx 14 | sphinx: 15 | configuration: docs/conf.py 16 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | import os 14 | import sys 15 | sys.path.insert(0, '../src/omero') 16 | 17 | 18 | # -- Project information ----------------------------------------------------- 19 | 20 | project = u'OMERO.py' 21 | copyright = u"Open Microscopy Environment" # noqa: A001 22 | author = "Open Microscopy Environment" 23 | 24 | 25 | # -- General configuration --------------------------------------------------- 26 | 27 | # Add any Sphinx extension module names here, as strings. They can be 28 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 29 | # ones. 30 | extensions = [ 31 | "sphinx.ext.autodoc", 32 | "sphinx.ext.doctest", 33 | "sphinx.ext.intersphinx", 34 | "sphinx.ext.todo", 35 | "sphinx.ext.viewcode", 36 | "sphinx.ext.extlinks", 37 | ] 38 | 39 | master_doc = "index" 40 | 41 | # Add any paths that contain templates here, relative to this directory. 42 | templates_path = ['_templates'] 43 | 44 | # The language for content autogenerated by Sphinx. Refer to documentation 45 | # for a list of supported languages. 46 | # 47 | # This is also used if you do content translation via gettext catalogs. 48 | # Usually you set "language" from the command line for these cases. 49 | language = 'en' 50 | 51 | # List of patterns, relative to source directory, that match files and 52 | # directories to ignore when looking for source files. 53 | # This pattern also affects html_static_path and html_extra_path. 54 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 55 | source_suffix = ".rst" 56 | 57 | # Build docs without external dependencies 58 | autodoc_mock_imports = ["omero", "omero_ext", 59 | "Ice", "IceImport", "Glacier2", "pytest", 60 | "appdirs", "IcePy", "omero_version", 61 | "IceGrid", "mx", "matplotlib", 62 | "omero_model_FileAnnotationI", 63 | "omero_model_TimestampAnnotationI", 64 | "omero_model_BooleanAnnotationI", 65 | "omero_model_TagAnnotationI", 66 | "omero_model_CommentAnnotationI", 67 | "omero_model_LongAnnotationI", 68 | "omero_model_DoubleAnnotationI", 69 | "omero_model_TermAnnotationI", 70 | "omero_model_XmlAnnotationI", 71 | "omero_model_MapAnnotationI", 72 | "omero_sys_ParametersI", 73 | "numpy", "yaml", 74 | "Image", "ImageDraw", "ImageFont"] 75 | 76 | # -- Options for HTML output ------------------------------------------------- 77 | 78 | # The theme to use for HTML and HTML Help pages. See the documentation for 79 | # a list of builtin themes. 80 | # 81 | html_theme = 'alabaster' 82 | 83 | # Add any paths that contain custom static files (such as style sheets) here, 84 | # relative to this directory. They are copied after the builtin static files, 85 | # so a file named "default.css" will overwrite the builtin "default.css". 86 | html_static_path = ['_static'] 87 | 88 | 89 | # -- Extension configuration ------------------------------------------------- 90 | 91 | # -- Options for todo extension ---------------------------------------------- 92 | 93 | # If true, `todo` and `todoList` produce output, else they produce nothing. 94 | todo_include_todos = True -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. omero documentation master file, created by 2 | sphinx-quickstart on Fri Jun 10 12:13:07 2022. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | OMERO.py documentation 7 | ====================== 8 | 9 | .. toctree:: 10 | :maxdepth: 4 11 | :caption: Contents: 12 | 13 | omero 14 | 15 | 16 | Indices and tables 17 | ================== 18 | 19 | * :ref:`genindex` 20 | * :ref:`modindex` 21 | * :ref:`search` 22 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.https://www.sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs/omero.all.rst: -------------------------------------------------------------------------------- 1 | omero.all module 2 | ================ 3 | 4 | .. automodule:: all 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.api.rst: -------------------------------------------------------------------------------- 1 | omero.api package 2 | ================= 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: api 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/omero.callbacks.rst: -------------------------------------------------------------------------------- 1 | omero.callbacks module 2 | ====================== 3 | 4 | .. automodule:: callbacks 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.cli.rst: -------------------------------------------------------------------------------- 1 | omero.cli module 2 | ================ 3 | 4 | .. automodule:: cli 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.clients.rst: -------------------------------------------------------------------------------- 1 | omero.clients module 2 | ==================== 3 | 4 | .. automodule:: clients 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.columns.rst: -------------------------------------------------------------------------------- 1 | omero.columns module 2 | ==================== 3 | 4 | .. automodule:: columns 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.config.rst: -------------------------------------------------------------------------------- 1 | omero.config module 2 | =================== 3 | 4 | .. automodule:: config 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.conversions.rst: -------------------------------------------------------------------------------- 1 | omero.conversions module 2 | ======================== 3 | 4 | .. automodule:: conversions 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.gateway.pytest_fixtures.rst: -------------------------------------------------------------------------------- 1 | omero.gateway.pytest_fixtures module 2 | ==================================== 3 | 4 | .. automodule:: gateway.pytest_fixtures 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.gateway.rst: -------------------------------------------------------------------------------- 1 | omero.gateway package 2 | ===================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.gateway.scripts 11 | 12 | Submodules 13 | ---------- 14 | 15 | .. toctree:: 16 | :maxdepth: 4 17 | 18 | omero.gateway.pytest_fixtures 19 | omero.gateway.utils 20 | 21 | Module contents 22 | --------------- 23 | 24 | .. automodule:: gateway 25 | :members: 26 | :inherited-members: 27 | :private-members: 28 | :undoc-members: 29 | :show-inheritance: 30 | -------------------------------------------------------------------------------- /docs/omero.gateway.scripts.dbhelpers.rst: -------------------------------------------------------------------------------- 1 | omero.gateway.scripts.dbhelpers module 2 | ====================================== 3 | 4 | .. automodule:: gateway.scripts.dbhelpers 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.gateway.scripts.rst: -------------------------------------------------------------------------------- 1 | omero.gateway.scripts package 2 | ============================= 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.gateway.scripts.dbhelpers 11 | omero.gateway.scripts.testdb_create 12 | 13 | Module contents 14 | --------------- 15 | 16 | .. automodule:: gateway.scripts 17 | :members: 18 | :undoc-members: 19 | :show-inheritance: 20 | -------------------------------------------------------------------------------- /docs/omero.gateway.scripts.testdb_create.rst: -------------------------------------------------------------------------------- 1 | omero.gateway.scripts.testdb\_create module 2 | =========================================== 3 | 4 | .. automodule:: gateway.scripts.testdb_create 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.gateway.utils.rst: -------------------------------------------------------------------------------- 1 | omero.gateway.utils module 2 | ========================== 3 | 4 | .. automodule:: gateway.utils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.grid.monitors.rst: -------------------------------------------------------------------------------- 1 | omero.grid.monitors package 2 | =========================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: grid.monitors 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/omero.grid.rst: -------------------------------------------------------------------------------- 1 | omero.grid package 2 | ================== 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.grid.monitors 11 | 12 | Module contents 13 | --------------- 14 | 15 | .. automodule:: grid 16 | :members: 17 | :undoc-members: 18 | :show-inheritance: 19 | -------------------------------------------------------------------------------- /docs/omero.hdfstorageV2.rst: -------------------------------------------------------------------------------- 1 | omero.hdfstorageV2 module 2 | ========================= 3 | 4 | .. automodule:: hdfstorageV2 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.bzip2_tool.rst: -------------------------------------------------------------------------------- 1 | omero.install.bzip2_tool module 2 | =============================== 3 | 4 | .. automodule:: install.bzip2_tool 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.config_parser.rst: -------------------------------------------------------------------------------- 1 | omero.install.config_parser module 2 | ================================== 3 | 4 | .. automodule:: install.config_parser 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.jvmcfg.rst: -------------------------------------------------------------------------------- 1 | omero.install.jvmcfg module 2 | =========================== 3 | 4 | .. automodule:: install.jvmcfg 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.logs_library.rst: -------------------------------------------------------------------------------- 1 | omero.install.logs_library module 2 | ================================= 3 | 4 | .. automodule:: install.logs_library 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.perf_test.rst: -------------------------------------------------------------------------------- 1 | omero.install.perf_test module 2 | ============================== 3 | 4 | .. automodule:: install.perf_test 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.python_warning.rst: -------------------------------------------------------------------------------- 1 | omero.install.python_warning module 2 | =================================== 3 | 4 | .. automodule:: install.python_warning 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.rst: -------------------------------------------------------------------------------- 1 | omero.install package 2 | ===================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.install.bzip2_tool 11 | omero.install.config_parser 12 | omero.install.jvmcfg 13 | omero.install.logs_library 14 | omero.install.perf_test 15 | omero.install.python_warning 16 | omero.install.versions 17 | omero.install.win_set_path 18 | omero.install.windows_warning 19 | 20 | Module contents 21 | --------------- 22 | 23 | .. automodule:: install 24 | :members: 25 | :undoc-members: 26 | :show-inheritance: 27 | -------------------------------------------------------------------------------- /docs/omero.install.versions.rst: -------------------------------------------------------------------------------- 1 | omero.install.versions module 2 | ============================= 3 | 4 | .. automodule:: install.versions 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.win_set_path.rst: -------------------------------------------------------------------------------- 1 | omero.install.win_set_path module 2 | ================================= 3 | 4 | .. automodule:: install.win_set_path 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.install.windows_warning.rst: -------------------------------------------------------------------------------- 1 | omero.install.windows_warning module 2 | ==================================== 3 | 4 | .. automodule:: install.windows_warning 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.java.rst: -------------------------------------------------------------------------------- 1 | omero.java module 2 | ================= 3 | 4 | .. automodule:: java 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.main.rst: -------------------------------------------------------------------------------- 1 | omero.main module 2 | ================= 3 | 4 | .. automodule:: main 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.min.rst: -------------------------------------------------------------------------------- 1 | omero.min module 2 | ================ 3 | 4 | .. automodule:: min 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.model.rst: -------------------------------------------------------------------------------- 1 | omero.model package 2 | =================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: model 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/omero.plugins.admin.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.admin module 2 | ========================== 3 | 4 | .. automodule:: plugins.admin 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.basics.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.basics module 2 | =========================== 3 | 4 | .. automodule:: plugins.basics 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.chgrp.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.chgrp module 2 | ========================== 3 | 4 | .. automodule:: plugins.chgrp 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.chown.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.chown module 2 | ========================== 3 | 4 | .. automodule:: plugins.chown 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.db.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.db module 2 | ======================= 3 | 4 | .. automodule:: plugins.db 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.delete.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.delete module 2 | =========================== 3 | 4 | .. automodule:: plugins.delete 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.download.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.download module 2 | ============================= 3 | 4 | .. automodule:: plugins.download 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.export.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.export module 2 | =========================== 3 | 4 | .. automodule:: plugins.export 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.fs.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.fs module 2 | ======================= 3 | 4 | .. automodule:: plugins.fs 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.group.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.group module 2 | ========================== 3 | 4 | .. automodule:: plugins.group 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.hql.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.hql module 2 | ======================== 3 | 4 | .. automodule:: plugins.hql 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.import.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.import module 2 | =========================== 3 | 4 | .. automodule:: plugins.import 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.ldap.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.ldap module 2 | ========================= 3 | 4 | .. automodule:: plugins.ldap 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.node.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.node module 2 | ========================= 3 | 4 | .. automodule:: plugins.node 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.obj.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.obj module 2 | ======================== 3 | 4 | .. automodule:: plugins.obj 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.perf.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.perf module 2 | ========================= 3 | 4 | .. automodule:: plugins.perf 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.prefs.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.prefs module 2 | ========================== 3 | 4 | .. automodule:: plugins.prefs 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.rst: -------------------------------------------------------------------------------- 1 | omero.plugins package 2 | ===================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.plugins.admin 11 | omero.plugins.basics 12 | omero.plugins.chgrp 13 | omero.plugins.chown 14 | omero.plugins.db 15 | omero.plugins.delete 16 | omero.plugins.download 17 | omero.plugins.export 18 | omero.plugins.fs 19 | omero.plugins.group 20 | omero.plugins.hql 21 | omero.plugins.import 22 | omero.plugins.ldap 23 | omero.plugins.node 24 | omero.plugins.obj 25 | omero.plugins.perf 26 | omero.plugins.prefs 27 | omero.plugins.script 28 | omero.plugins.search 29 | omero.plugins.sessions 30 | omero.plugins.submit 31 | omero.plugins.tag 32 | omero.plugins.user 33 | 34 | Module contents 35 | --------------- 36 | 37 | .. automodule:: plugins 38 | :members: 39 | :undoc-members: 40 | :show-inheritance: 41 | -------------------------------------------------------------------------------- /docs/omero.plugins.script.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.script module 2 | =========================== 3 | 4 | .. automodule:: plugins.script 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.search.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.search module 2 | =========================== 3 | 4 | .. automodule:: plugins.search 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.sessions.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.sessions module 2 | ============================= 3 | 4 | .. automodule:: plugins.sessions 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.submit.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.submit module 2 | =========================== 3 | 4 | .. automodule:: plugins.submit 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.tag.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.tag module 2 | ======================== 3 | 4 | .. automodule:: plugins.tag 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.plugins.user.rst: -------------------------------------------------------------------------------- 1 | omero.plugins.user module 2 | ========================= 3 | 4 | .. automodule:: plugins.user 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.processor.rst: -------------------------------------------------------------------------------- 1 | omero.processor module 2 | ====================== 3 | 4 | .. automodule:: processor 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.romio.rst: -------------------------------------------------------------------------------- 1 | omero.romio package 2 | =================== 3 | 4 | Module contents 5 | --------------- 6 | 7 | .. automodule:: romio 8 | :members: 9 | :undoc-members: 10 | :show-inheritance: 11 | -------------------------------------------------------------------------------- /docs/omero.rst: -------------------------------------------------------------------------------- 1 | omero package 2 | ============= 3 | 4 | Subpackages 5 | ----------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.api 11 | omero.gateway 12 | omero.grid 13 | omero.install 14 | omero.model 15 | omero.plugins 16 | omero.romio 17 | omero.testlib 18 | omero.util 19 | 20 | Submodules 21 | ---------- 22 | 23 | .. toctree:: 24 | :maxdepth: 4 25 | 26 | omero.all 27 | omero.callbacks 28 | omero.cli 29 | omero.clients 30 | omero.columns 31 | omero.config 32 | omero.conversions 33 | omero.hdfstorageV2 34 | omero.java 35 | omero.main 36 | omero.min 37 | omero.processor 38 | omero.rtypes 39 | omero.scripts 40 | omero.tables 41 | -------------------------------------------------------------------------------- /docs/omero.rtypes.rst: -------------------------------------------------------------------------------- 1 | omero.rtypes module 2 | =================== 3 | 4 | .. automodule:: rtypes 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.scripts.rst: -------------------------------------------------------------------------------- 1 | omero.scripts module 2 | ==================== 3 | 4 | .. automodule:: scripts 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.tables.rst: -------------------------------------------------------------------------------- 1 | omero.tables module 2 | =================== 3 | 4 | .. automodule:: tables 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.testlib.cli.rst: -------------------------------------------------------------------------------- 1 | omero.testlib.cli module 2 | ======================== 3 | 4 | .. automodule:: testlib.cli 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.testlib.rst: -------------------------------------------------------------------------------- 1 | omero.testlib package 2 | ===================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.testlib.cli 11 | omero.testlib.script 12 | 13 | Module contents 14 | --------------- 15 | 16 | .. automodule:: testlib 17 | :members: 18 | :undoc-members: 19 | :show-inheritance: 20 | -------------------------------------------------------------------------------- /docs/omero.testlib.script.rst: -------------------------------------------------------------------------------- 1 | omero.testlib.script module 2 | =========================== 3 | 4 | .. automodule:: testlib.script 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.OmeroPopo.rst: -------------------------------------------------------------------------------- 1 | omero.util.OmeroPopo module 2 | =========================== 3 | 4 | .. automodule:: util.OmeroPopo 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.ROIDrawingUtils.rst: -------------------------------------------------------------------------------- 1 | omero.util.ROIDrawingUtils module 2 | ================================= 3 | 4 | .. automodule:: util.ROIDrawingUtils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.ROI_utils.rst: -------------------------------------------------------------------------------- 1 | omero.util.ROI_utils module 2 | =========================== 3 | 4 | .. automodule:: util.ROI_utils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.cleanse.rst: -------------------------------------------------------------------------------- 1 | omero.util.cleanse module 2 | ========================= 3 | 4 | .. automodule:: util.cleanse 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.concurrency.rst: -------------------------------------------------------------------------------- 1 | omero.util.concurrency module 2 | ============================= 3 | 4 | .. automodule:: util.concurrency 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.decorators.rst: -------------------------------------------------------------------------------- 1 | omero.util.decorators module 2 | ============================ 3 | 4 | .. automodule:: util.decorators 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.figureUtil.rst: -------------------------------------------------------------------------------- 1 | omero.util.figureUtil module 2 | ============================ 3 | 4 | .. automodule:: util.figureUtil 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.imageUtil.rst: -------------------------------------------------------------------------------- 1 | omero.util.imageUtil module 2 | =========================== 3 | 4 | .. automodule:: util.imageUtil 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.image_utils.rst: -------------------------------------------------------------------------------- 1 | omero.util.image_utils module 2 | ============================= 3 | 4 | .. automodule:: util.image_utils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.import_candidates.rst: -------------------------------------------------------------------------------- 1 | omero.util.import_candidates module 2 | =================================== 3 | 4 | .. automodule:: util.import_candidates 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.importperf.rst: -------------------------------------------------------------------------------- 1 | omero.util.importperf module 2 | ============================ 3 | 4 | .. automodule:: util.importperf 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.metadata_mapannotations.rst: -------------------------------------------------------------------------------- 1 | omero.util.metadata_mapannotations module 2 | ========================================= 3 | 4 | .. automodule:: util.metadata_mapannotations 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.metadata_utils.rst: -------------------------------------------------------------------------------- 1 | omero.util.metadata_utils module 2 | ================================ 3 | 4 | .. automodule:: util.metadata_utils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.pixelstypetopython.rst: -------------------------------------------------------------------------------- 1 | omero.util.pixelstypetopython module 2 | ==================================== 3 | 4 | .. automodule:: util.pixelstypetopython 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.populate_metadata.rst: -------------------------------------------------------------------------------- 1 | omero.util.populate_metadata module 2 | =================================== 3 | 4 | .. automodule:: util.populate_metadata 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.populate_roi.rst: -------------------------------------------------------------------------------- 1 | omero.util.populate_roi module 2 | ============================== 3 | 4 | .. automodule:: util.populate_roi 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.pydict_text_io.rst: -------------------------------------------------------------------------------- 1 | omero.util.pydict_text_io module 2 | ================================ 3 | 4 | .. automodule:: util.pydict_text_io 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.roi_handling_utils.rst: -------------------------------------------------------------------------------- 1 | omero.util.roi_handling_utils module 2 | ==================================== 3 | 4 | .. automodule:: util.roi_handling_utils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.rst: -------------------------------------------------------------------------------- 1 | omero.util package 2 | ================== 3 | 4 | Submodules 5 | ---------- 6 | 7 | .. toctree:: 8 | :maxdepth: 4 9 | 10 | omero.util.OmeroPopo 11 | omero.util.ROIDrawingUtils 12 | omero.util.ROI_utils 13 | omero.util.cleanse 14 | omero.util.concurrency 15 | omero.util.decorators 16 | omero.util.figureUtil 17 | omero.util.imageUtil 18 | omero.util.image_utils 19 | omero.util.import_candidates 20 | omero.util.importperf 21 | omero.util.metadata_mapannotations 22 | omero.util.metadata_utils 23 | omero.util.pixelstypetopython 24 | omero.util.populate_metadata 25 | omero.util.populate_roi 26 | omero.util.pydict_text_io 27 | omero.util.roi_handling_utils 28 | omero.util.script_utils 29 | omero.util.sessions 30 | omero.util.temp_files 31 | omero.util.text 32 | omero.util.tiles 33 | omero.util.upgrade_check 34 | 35 | Module contents 36 | --------------- 37 | 38 | .. automodule:: util 39 | :members: 40 | :undoc-members: 41 | :show-inheritance: 42 | -------------------------------------------------------------------------------- /docs/omero.util.script_utils.rst: -------------------------------------------------------------------------------- 1 | omero.util.script_utils module 2 | ============================== 3 | 4 | .. automodule:: util.script_utils 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.sessions.rst: -------------------------------------------------------------------------------- 1 | omero.util.sessions module 2 | ========================== 3 | 4 | .. automodule:: util.sessions 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.temp_files.rst: -------------------------------------------------------------------------------- 1 | omero.util.temp_files module 2 | ============================= 3 | 4 | .. automodule:: util.temp_files 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.text.rst: -------------------------------------------------------------------------------- 1 | omero.util.text module 2 | ====================== 3 | 4 | .. automodule:: util.text 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.tiles.rst: -------------------------------------------------------------------------------- 1 | omero.util.tiles module 2 | ======================= 3 | 4 | .. automodule:: util.tiles 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /docs/omero.util.upgrade_check.rst: -------------------------------------------------------------------------------- 1 | omero.util.upgrade_check module 2 | =============================== 3 | 4 | .. automodule:: util.upgrade_check 5 | :members: 6 | :undoc-members: 7 | :show-inheritance: 8 | -------------------------------------------------------------------------------- /examples/createSession.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ---------------------------------------------------------------------------- 5 | # Copyright (C) 2006-2008 University of Dundee. All rights reserved. 6 | # 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License along 18 | # with this program; if not, write to the Free Software Foundation, Inc., 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | # 21 | # ---------------------------------------------------------------------------- 22 | # 23 | import omero 24 | 25 | client = omero.client(["--Ice.Config=./ice.config"]) 26 | session = client.createSession("root", "omero") 27 | client.getSession().createRawPixelsStore() 28 | -------------------------------------------------------------------------------- /examples/load.omero: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env omero load 2 | 3 | prefs get 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/submit.omero: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env omero submit 2 | 3 | prefs get 4 | 5 | 6 | -------------------------------------------------------------------------------- /examples/upload.omero: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env omero load 2 | 3 | upload ./upload.omero 4 | 5 | 6 | -------------------------------------------------------------------------------- /ice.config: -------------------------------------------------------------------------------- 1 | # 2 | # OmeroBlitz configuration file for testing 3 | # ------------------------------------------ 4 | # 5 | 6 | omero.host=localhost 7 | 8 | omero.rootpass=omero 9 | -------------------------------------------------------------------------------- /manualtests/README.txt: -------------------------------------------------------------------------------- 1 | This directory contains unitest-based tests as well as 2 | regular Python tests that are used to test various 3 | functionality. However, they require too much setup or 4 | human guidance to be useful as integration tests. 5 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | markers = 3 | broken: mark the test as broken, i.e. it may be intermittent or failing without a fully understood cause 4 | ## Temporarily disabled due to 'SyntaxError: invalid escape sequence' 5 | ## which is just a deprecatioin warning without this configuration. 6 | ## filterwarnings = 7 | ## error::DeprecationWarning 8 | # Tests which will raise a deprecation warning should be updated 9 | # to use `pytest.deprecated_call(method, *args)` 10 | filterwarnings = 11 | ignore::DeprecationWarning 12 | -------------------------------------------------------------------------------- /src/IceImport.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2011 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | """ 10 | Load modules with automatic updating of Ice modules. 11 | """ 12 | 13 | import Ice 14 | update = getattr(Ice, "updateModules", None) 15 | 16 | 17 | def load(target): 18 | """ 19 | uses __import__ followed by Ice.updateModules if available. 20 | 21 | """ 22 | __import__(target) 23 | Ice.updateModules() 24 | -------------------------------------------------------------------------------- /src/omero/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Copyright 2007, 2008 Glencoe Software, Inc. All rights reserved. 5 | # Use is subject to license terms supplied in LICENSE.txt 6 | 7 | """ 8 | Primary OmeroPy types 9 | 10 | Classes: 11 | omero.client -- Main OmeroPy connector object 12 | """ 13 | from omero_version import omero_version 14 | from omero_version import ice_compatibility as compat 15 | import Ice 16 | import os 17 | _sys = __import__("sys") 18 | 19 | try: 20 | vers = Ice.stringVersion() 21 | vers = vers.split(".") 22 | compat = compat.split(".") 23 | if compat[0:2] != vers[0:2]: 24 | msg = """ 25 | 26 | ERROR: Ice version mismatch! 27 | 28 | Your OMERO code has been compiled using Ice version %s 29 | but you seem to have Ice version %s installed. If you need 30 | help understanding this issue, please send this error message 31 | to the OME community: 32 | 33 | https://www.openmicroscopy.org/support/ 34 | 35 | Debugging Info: 36 | -------------- 37 | VERSION=%s 38 | PYTHONPATH=%s 39 | """ % (".".join(compat), ".".join(vers), omero_version, 40 | os.path.pathsep.join(_sys.path)) 41 | raise Exception(msg) 42 | finally: 43 | del omero_version 44 | del compat 45 | del vers 46 | del Ice 47 | del os 48 | 49 | __import_style__ = None 50 | 51 | 52 | def client_wrapper(*args, **kwargs): 53 | """ 54 | Returns an instance of :class:`omero.gateway.BlitzGateway` created with all 55 | arguments passed to this method 56 | 57 | @return: See above 58 | """ 59 | import omero.gateway 60 | return omero.gateway.BlitzGateway(*args, **kwargs) 61 | 62 | 63 | def client(*args, **kwargs): 64 | import omero.clients 65 | return omero.clients.BaseClient(*args, **kwargs) 66 | 67 | 68 | class ClientError(Exception): 69 | """ 70 | Top of client exception hierarchy. 71 | """ 72 | pass 73 | 74 | 75 | class CmdError(ClientError): 76 | """ 77 | Thrown by omero.client.waitOnCmd() when 78 | failonerror is True and an omero.cmd.ERR 79 | is returned. The only argument 80 | """ 81 | 82 | def __init__(self, err, *args, **kwargs): 83 | ClientError.__init__(self, *args, **kwargs) 84 | self.err = err 85 | 86 | def __str__(self): 87 | sb = ClientError.__str__(self) 88 | sb += "\n" 89 | sb += str(self.err) 90 | return sb 91 | 92 | 93 | class UnloadedEntityException(ClientError): 94 | pass 95 | 96 | 97 | class UnloadedCollectionException(ClientError): 98 | pass 99 | 100 | 101 | def proxy_to_instance(proxy_string, default=None): 102 | """ 103 | Convert a proxy string to an instance. If no 104 | default is provided, the string must be of the 105 | form: 'Image:1' or 'ImageI:1'. With a default, 106 | a string consisting of just the ID is permissible 107 | but not required. 108 | """ 109 | import omero 110 | parts = proxy_string.split(":") 111 | if len(parts) == 1 and default is not None: 112 | proxy_string = "%s:%s" % (default, proxy_string) 113 | parts.insert(0, default) 114 | 115 | kls = parts[0] 116 | if not kls.endswith("I"): 117 | kls += "I" 118 | kls = getattr(omero.model, kls, None) 119 | if kls is None: 120 | raise ClientError(("Invalid proxy string: %s. " 121 | "Correct format is Class:ID") % proxy_string) 122 | return kls(proxy_string) 123 | -------------------------------------------------------------------------------- /src/omero/all.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # 5 | # Copyright 2010-2014 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | # This file is an import-only file providing a mechanism for other files to 10 | # import a range of modules in a controlled way. It could be made to pass 11 | # flake8 but given its simplicity it is being marked as noqa for now. 12 | # 13 | # flake8: noqa 14 | 15 | import Ice 16 | import IceImport 17 | import omero 18 | if omero.__import_style__ is None: 19 | omero.__import_style__ = "all" 20 | import omero.min 21 | import omero.callbacks 22 | import omero.ObjectFactoryRegistrar 23 | IceImport.load("omero_FS_ice") 24 | IceImport.load("omero_System_ice") 25 | IceImport.load("omero_Collections_ice") 26 | IceImport.load("omero_Repositories_ice") 27 | IceImport.load("omero_SharedResources_ice") 28 | IceImport.load("omero_Scripts_ice") 29 | IceImport.load("omero_Tables_ice") 30 | IceImport.load("omero_api_IAdmin_ice") 31 | IceImport.load("omero_api_IConfig_ice") 32 | IceImport.load("omero_api_IContainer_ice") 33 | IceImport.load("omero_api_ILdap_ice") 34 | IceImport.load("omero_api_IMetadata_ice") 35 | IceImport.load("omero_api_IPixels_ice") 36 | IceImport.load("omero_api_IProjection_ice") 37 | IceImport.load("omero_api_IQuery_ice") 38 | IceImport.load("omero_api_IRenderingSettings_ice") 39 | IceImport.load("omero_api_IRepositoryInfo_ice") 40 | IceImport.load("omero_api_IRoi_ice") 41 | IceImport.load("omero_api_IScript_ice") 42 | IceImport.load("omero_api_ISession_ice") 43 | IceImport.load("omero_api_IShare_ice") 44 | IceImport.load("omero_api_ITimeline_ice") 45 | IceImport.load("omero_api_ITypes_ice") 46 | IceImport.load("omero_api_IUpdate_ice") 47 | IceImport.load("omero_api_Exporter_ice") 48 | IceImport.load("omero_api_JobHandle_ice") 49 | IceImport.load("omero_api_MetadataStore_ice") 50 | IceImport.load("omero_api_RawFileStore_ice") 51 | IceImport.load("omero_api_RawPixelsStore_ice") 52 | IceImport.load("omero_api_RenderingEngine_ice") 53 | IceImport.load("omero_api_Search_ice") 54 | IceImport.load("omero_api_ThumbnailStore_ice") 55 | IceImport.load("omero_cmd_Admin_ice") 56 | IceImport.load("omero_cmd_API_ice") 57 | IceImport.load("omero_cmd_Basic_ice") 58 | IceImport.load("omero_cmd_FS_ice") 59 | IceImport.load("omero_cmd_Graphs_ice") 60 | IceImport.load("omero_cmd_Mail_ice") 61 | IceImport.load("omero_model_Units_ice") 62 | import omero_sys_ParametersI 63 | import omero_model_PermissionsI 64 | -------------------------------------------------------------------------------- /src/omero/api/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is an import-only file providing a mechanism for other files to 5 | # import a range of modules in a controlled way. It could be made to pass 6 | # flake8 but given its simplicity it is being marked as noqa for now. 7 | # 8 | # flake8: noqa 9 | 10 | import omero.clients 11 | -------------------------------------------------------------------------------- /src/omero/conversions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | Conversion utilities for changing between units. 24 | """ 25 | 26 | class Conversion(object): 27 | """ 28 | Base-functor like object which can be used for preparing complex 29 | equations for converting from one unit to another. Primarily these 30 | classes and static methods are used via code-generation. Sympy-generated 31 | strings are placed directly into code. If the proper imports are in place, 32 | then a top-level Conversion (usually of type Add or 33 | Mul is returned from the evaluation). 34 | """ 35 | 36 | def __init__(self, *conversions): 37 | self.conversions = conversions 38 | 39 | def __call__(self, original): 40 | raise NotImplemented() 41 | 42 | def join(self, sym): 43 | sb = sym.join([str(x) for x in self.conversions]) 44 | return "(%s)" % sb 45 | 46 | 47 | class Add(Conversion): 48 | """ 49 | Sums all the Conversion instances which 50 | are passed in to the constructor. 51 | """ 52 | 53 | def __call__(self, original): 54 | rv = 0.0 55 | for c in self.conversions: 56 | rv += c(original) 57 | return rv 58 | 59 | def __str__(self): 60 | return self.join(" + ") 61 | 62 | 63 | class Int(Conversion): 64 | """ 65 | Simple representation of a possibly 66 | very large integer. 67 | """ 68 | 69 | def __init__(self, i): 70 | if isinstance(i, int): 71 | self.i = i 72 | else: 73 | self.i = float(i) # Handles big strings 74 | 75 | def __call__(self, original): 76 | return self.i 77 | 78 | def __str__(self): 79 | return str(self.i) 80 | 81 | 82 | class Mul(Conversion): 83 | """ 84 | Multiplies all the Conversion instances which 85 | are passed in to the constructor. 86 | """ 87 | 88 | def __call__(self, original): 89 | rv = 1.0 90 | for c in self.conversions: 91 | rv *= c(original) 92 | return rv 93 | 94 | def __str__(self): 95 | return self.join(" * ") 96 | 97 | 98 | class Pow(Conversion): 99 | """ 100 | Raises the first argument (base) to 101 | the power of the second (exponent). 102 | """ 103 | 104 | def __init__(self, base, exp): 105 | self.base = base 106 | self.exp = exp 107 | 108 | def __call__(self, original): 109 | return self.base ** self.exp 110 | 111 | def __str__(self): 112 | return "(%s ** %s)" % (self.base, self.exp) 113 | 114 | 115 | class Rat(Conversion): 116 | """ 117 | Divides the first argument (numerator) 118 | by the second (denominator). 119 | """ 120 | 121 | def __init__(self, n, d): 122 | self.n = n 123 | self.d = d 124 | 125 | def unwrap(self, x, original): 126 | if isinstance(x, (int, float, str)): 127 | return float(x) 128 | else: 129 | return x(original) 130 | 131 | def __call__(self, original): 132 | n = self.unwrap(self.n, original) 133 | d = self.unwrap(self.d, original) 134 | return n / d 135 | 136 | def __str__(self): 137 | return "(%s / %s)" % (self.n, self.d) 138 | 139 | 140 | class Sym(Conversion): 141 | """ 142 | Represents the variable of the source 143 | unit and simply returns the original 144 | value passed to it. 145 | """ 146 | 147 | def __init__(self, s): 148 | self.s = s 149 | 150 | def __call__(self, original): 151 | return float(original) 152 | 153 | def __str__(self): 154 | return "x" 155 | -------------------------------------------------------------------------------- /src/omero/fs/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import IceImport 4 | IceImport.load("omero_FS_ice") 5 | 6 | # 7 | # Copied from: 8 | # blitz/src/ome/formats/importer/transfers/AbstractFileTransfer.java 9 | # 10 | TRANSFERS = { 11 | "ome.formats.importer.transfers.CopyFileTransfer": "cp", 12 | "ome.formats.importer.transfers.CopyMoveFileTransfer": "cp_rm", 13 | "ome.formats.importer.transfers.HardlinkFileTransfer": "ln", 14 | "ome.formats.importer.transfers.MoveFileTransfer": "ln_rm", 15 | "ome.formats.importer.transfers.SymlinkFileTransfer": "ln_s", 16 | "ome.formats.importer.transfers.UploadRmFileTransfer": "upload_rm", 17 | "ome.formats.importer.transfers.UploadFileTransfer": "", 18 | } 19 | -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B08.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B08.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B08.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B08.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B10.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B10.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B10.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B10.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B12.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B12.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B12.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B12.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B14.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B14.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B14.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B14.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B18.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B18.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B18.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B18.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B20.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B20.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B20.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B20.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B24.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B24.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B24.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B24.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B32.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B32.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B32.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B32.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B40.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B40.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B40.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B40.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B48.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B48.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B48.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B48.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B56.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B56.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B56.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B56.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B64.pbm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B64.pbm -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/B64.pil: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/B64.pil -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/FreeSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/FreeSans.ttf -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/FreeSansBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/FreeSansBold.ttf -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/FreeSansBoldOblique.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/FreeSansBoldOblique.ttf -------------------------------------------------------------------------------- /src/omero/gateway/pilfonts/FreeSansOblique.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/pilfonts/FreeSansOblique.ttf -------------------------------------------------------------------------------- /src/omero/gateway/pytest_fixtures.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2013 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | 8 | """ 9 | py.test fixtures for gatewaytest 10 | """ 11 | 12 | from omero.gateway.scripts.testdb_create import TestDBHelper, dbhelpers 13 | 14 | 15 | import pytest 16 | 17 | 18 | class GatewayWrapper (TestDBHelper): 19 | 20 | def __init__(self): 21 | super(GatewayWrapper, self).__init__() 22 | self.setUp(skipTestDB=False, skipTestImages=True) 23 | 24 | def createTestImg_generated(self): 25 | ds = self.getTestDataset() 26 | assert ds 27 | testimg = self.createTestImage(dataset=ds) 28 | return testimg 29 | 30 | 31 | @pytest.fixture(scope='class') 32 | def gatewaywrapper(request): 33 | """ 34 | Returns a test helper gateway object. 35 | """ 36 | g = GatewayWrapper() 37 | 38 | def fin(): 39 | g.tearDown() 40 | dbhelpers.cleanup() 41 | request.addfinalizer(fin) 42 | return g 43 | 44 | 45 | @pytest.fixture(scope='function') 46 | def author_testimg_generated(request, gatewaywrapper): 47 | """ 48 | logs in as Author and returns the test image, creating it first if needed. 49 | """ 50 | gatewaywrapper.loginAsAuthor() 51 | rv = gatewaywrapper.createTestImg_generated() 52 | return rv 53 | 54 | 55 | @pytest.fixture(scope='function') 56 | def author_testimg_tiny(request, gatewaywrapper): 57 | """ 58 | logs in as Author and returns the test image, creating it first if needed. 59 | """ 60 | gatewaywrapper.loginAsAuthor() 61 | rv = gatewaywrapper.getTinyTestImage(autocreate=True) 62 | return rv 63 | 64 | 65 | @pytest.fixture(scope='function') 66 | def author_testimg_tiny2(request, gatewaywrapper): 67 | """ 68 | logs in as Author and returns the test image, creating it first if needed. 69 | """ 70 | gatewaywrapper.loginAsAuthor() 71 | rv = gatewaywrapper.getTinyTestImage2(autocreate=True) 72 | return rv 73 | 74 | 75 | @pytest.fixture(scope='function') 76 | def author_testimg(request, gatewaywrapper): 77 | """ 78 | logs in as Author and returns the test image, creating it first if needed. 79 | """ 80 | gatewaywrapper.loginAsAuthor() 81 | rv = gatewaywrapper.getTestImage(autocreate=True) 82 | return rv 83 | 84 | 85 | @pytest.fixture(scope='function') 86 | def author_testimg_bad(request, gatewaywrapper): 87 | """ 88 | logs in as Author and returns the test image, creating it first if needed. 89 | """ 90 | gatewaywrapper.loginAsAuthor() 91 | rv = gatewaywrapper.getBadTestImage(autocreate=True) 92 | return rv 93 | 94 | 95 | @pytest.fixture(scope='function') 96 | def author_testimg_big(request, gatewaywrapper): 97 | """ 98 | logs in as Author and returns the test image, creating it first if needed. 99 | """ 100 | gatewaywrapper.loginAsAuthor() 101 | rv = gatewaywrapper.getBigTestImage(autocreate=True) 102 | return rv 103 | 104 | 105 | @pytest.fixture(scope='function') 106 | def author_testimg_32float(request, gatewaywrapper): 107 | """ 108 | logs in as Author and returns the float image, creating it first if needed. 109 | """ 110 | gatewaywrapper.loginAsAuthor() 111 | rv = gatewaywrapper.get32FloatTestImage(autocreate=True) 112 | return rv 113 | -------------------------------------------------------------------------------- /src/omero/gateway/scripts/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/gateway/scripts/__init__.py -------------------------------------------------------------------------------- /src/omero/grid/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2010 Glencoe Software, Inc. All rights reserved. 5 | # Use is subject to license terms supplied in LICENSE.txt 6 | # 7 | 8 | import IceImport 9 | IceImport.load("omero_FS_ice") 10 | IceImport.load("omero_Scripts_ice") 11 | IceImport.load("omero_SharedResources_ice") 12 | IceImport.load("omero_Tables_ice") 13 | -------------------------------------------------------------------------------- /src/omero/grid/monitors/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import IceImport 4 | IceImport.load("omero_FS_ice") 5 | -------------------------------------------------------------------------------- /src/omero/install/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/install/__init__.py -------------------------------------------------------------------------------- /src/omero/install/bzip2_tool.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2009 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | 8 | """ 9 | Function for enabling/disabling the bzip2.dll which 10 | comes with PyTables. 11 | """ 12 | 13 | import os 14 | import sys 15 | 16 | 17 | def bzip2_tool(disable=False): 18 | """ 19 | Renames the bzip2.dll library which comes with PyTables. 20 | """ 21 | 22 | import tables 23 | f = tables.__file__ 24 | p = os.path.dirname(f) 25 | p = os.path.abspath(p) 26 | b = os.path.join(p, "bzip2.dll") 27 | d = os.path.join(p, "bzip2_DISABLED.dll") 28 | if disable: 29 | _swap(b, d) 30 | else: 31 | _swap(d, b) 32 | 33 | 34 | def _swap(f, t): 35 | if not os.path.exists(f): 36 | print("%s doesn't exist" % f) 37 | sys.exit(0) 38 | os.rename(f, t) 39 | 40 | if __name__ == "__main__": 41 | try: 42 | if len(sys.argv) == 2: 43 | which = sys.argv[1] 44 | if which == "disable": 45 | which = True 46 | elif which == "enable": 47 | which = False 48 | else: 49 | print("Unknown command: ", which) 50 | sys.exit(2) 51 | bzip2_tool(disable=which) 52 | sys.exit(0) 53 | except Exception as e: 54 | print("bzip2_tool failed: ", e) 55 | sys.exit(1) 56 | 57 | print("Usage: %s disable|enable" % sys.argv[0]) 58 | sys.exit(2) 59 | -------------------------------------------------------------------------------- /src/omero/install/python_warning.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2016 University of Dundee. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | 8 | """ 9 | Python helper plugin 10 | """ 11 | 12 | import sys 13 | import platform 14 | import warnings 15 | 16 | warnings.warn( 17 | "This module is deprecated as of OMERO.py 5.6.0", DeprecationWarning) 18 | 19 | PYTHON_WARNING = ("Python version %s is not " 20 | "supported!" % platform.python_version()) 21 | 22 | 23 | def py27_only(): 24 | if sys.version_info < (2, 7) or sys.version_info >= (2, 8): 25 | return False 26 | return True 27 | -------------------------------------------------------------------------------- /src/omero/install/versions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2009 Glencoe Software, Inc. All rights reserved. 5 | # Use is subject to license terms supplied in LICENSE.txt 6 | # 7 | """ 8 | Version comparison functionality 9 | """ 10 | 11 | import re 12 | import logging 13 | 14 | # Regex copied from ome.api.IConfig.VERSION_REGEX 15 | REGEX = re.compile(r"^.*?[-]?(\\d+[.]\\d+([.]\\d+)?)[-]?.*?$") 16 | LOG = logging.getLogger("omero.version") 17 | 18 | 19 | def needs_upgrade(client_version, server_version, verbose=False): 20 | """ 21 | Tests whether the client version is behind the server version. 22 | For example:: 23 | 24 | import omero 25 | from omero_version import omero_version as client_version 26 | 27 | client = omero.client() 28 | session = client.createSession() 29 | config = session.getConfigService() 30 | server_version = config.getVersion() 31 | 32 | upgrade = needs_upgrade(client_version, server_version) 33 | if upgrade: 34 | # Inform client 35 | 36 | Alternatively, from the command-line:: 37 | 38 | ./versions.py --quiet 4.1.0 4.2.0-DEV || echo upgrade 39 | 40 | """ 41 | try: 42 | client_cleaned = REGEX.match(client_version).group(1) 43 | client_split = client_cleaned.split(".") 44 | 45 | server_cleaned = REGEX.match(server_version).group(1) 46 | server_split = server_cleaned.split(".") 47 | 48 | rv = (client_split < server_split) 49 | if verbose: 50 | LOG.info("Client=%20s (%-5s) v. Server=%20s (%-5s) Upgrade? %s", 51 | client_version, ".".join(client_split), 52 | server_version, ".".join(server_split), rv) 53 | return rv 54 | 55 | except: 56 | LOG.warn("Bad versions: client=%s server=%s", client_version, 57 | server_version, exc_info=1) 58 | return True 59 | 60 | if __name__ == "__main__": 61 | 62 | import sys 63 | args = list(sys.argv[1:]) 64 | 65 | if "--quiet" in args: 66 | args.remove("--quiet") 67 | logging.basicConfig(level=logging.WARN) 68 | else: 69 | logging.basicConfig(level=logging.DEBUG) 70 | 71 | if "--test" in args: 72 | print("="*10, "Test", "="*72) 73 | needs_upgrade("4.0", "4.1.1", True) 74 | needs_upgrade("4.1", "4.1.1", True) 75 | needs_upgrade("4.1.0", "4.1.1", True) 76 | needs_upgrade("4.1.0", "4.1.1-Dev", True) 77 | needs_upgrade("4.1.0-Dev", "4.1.1", True) 78 | needs_upgrade("4.1.1", "4.1.1", True) 79 | needs_upgrade("Beta-4.1", "4.1.1", True) 80 | needs_upgrade("Beta-4.1.0", "4.1.1", True) 81 | needs_upgrade("Beta-4.1.1", "4.1.1", True) 82 | needs_upgrade("4.1.1", "Beta-4.1.1", True) 83 | needs_upgrade("Beta-4.1.0", "Beta-4.1.1", True) 84 | needs_upgrade("4.1.1-Foo", "4.1.1", True) 85 | needs_upgrade("4.1.1-Foo", "4.1.1-Dev", True) 86 | needs_upgrade("4.1.1-Foo", "4.1.2-Dev", True) 87 | needs_upgrade("4.1.1-Foo", "4.2.0-Dev", True) 88 | needs_upgrade("4.1.1-Foo", "4.2", True) 89 | needs_upgrade("4.1.1-Foo", "5.0", True) 90 | needs_upgrade("v.4.1.1-Foo", "5.0", True) 91 | # Additions post git-describe 92 | needs_upgrade("v.4.1.1-Foo", "5.0", True) 93 | needs_upgrade("v4.1.1-Foo", "5.0", True) 94 | needs_upgrade("Beta-v4.1.1-Foo", "5.0", True) 95 | needs_upgrade("A1-4.1.1-Foo", "5.0", True) 96 | needs_upgrade("A1-v4.1.1-Foo", "5.0", True) 97 | else: 98 | try: 99 | rv = int(needs_upgrade(args[0], args[1], True)) 100 | except: 101 | rv = 2 102 | print(""" %s [--quiet] client_version server_version 103 | or: %s [--quiet] --test """ % (sys.argv[0], sys.argv[0])) 104 | sys.exit(rv) 105 | -------------------------------------------------------------------------------- /src/omero/install/win_set_path.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2009 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # Josh Moore 8 | 9 | """ 10 | Function for setting the working directory for an 11 | Omero installation on Windows, since relative paths 12 | are not supported. 13 | """ 14 | 15 | import sys 16 | from omero_ext.path import path 17 | import fileinput 18 | 19 | dummy = object() 20 | 21 | 22 | def win_set_path(new_name=dummy, old_name=r"c:\omero_dist", dir=path(".")): 23 | r""" 24 | Parses the Windows cfg and xml files and 25 | replaces the default "c:\omero_dist" with the 26 | given value. 27 | """ 28 | 29 | cfg = dir / "etc" / "Windows.cfg" 30 | xml = dir / "etc" / "grid" / "windefault.xml" 31 | 32 | if new_name == dummy: 33 | new_name = dir.abspath() 34 | if new_name is None or old_name is None: 35 | raise Exception("Arguments cannot be None") 36 | 37 | if new_name.find(" ") >= 0: 38 | raise Exception("Contains whitespace: '%s'" % new_name) 39 | 40 | new_name = path(new_name).abspath() 41 | old_name = path(old_name).abspath() 42 | 43 | print("Converting from %s to %s" % (old_name, new_name)) 44 | 45 | new_name2 = new_name.replace("\\", "\\\\") 46 | old_name2 = old_name.replace("\\", "\\\\") 47 | 48 | count = 0 49 | for line in fileinput.input([str(cfg), str(xml)], inplace=1): 50 | if line.find(old_name) >= 0: 51 | count += 1 52 | print(line.replace(old_name, new_name), end=' ') 53 | elif line.find(old_name2) >= 0: 54 | count += 1 55 | print(line.replace(old_name2, new_name2), end=' ') 56 | else: 57 | print(line, end=' ') 58 | 59 | fileinput.close() 60 | print("Changes made: %s" % count) 61 | return count 62 | 63 | if __name__ == "__main__": 64 | try: 65 | if "-h" in sys.argv or "--help" in sys.argv: 66 | pass 67 | elif len(sys.argv) == 1: 68 | win_set_path() 69 | sys.exit(0) 70 | elif len(sys.argv) == 2: 71 | win_set_path(new_name=sys.argv[1]) 72 | sys.exit(0) 73 | elif len(sys.argv) == 3: 74 | win_set_path(old_name=sys.argv[1], new_name=sys.argv[2]) 75 | sys.exit(0) 76 | except Exception as e: 77 | print("Failed to set path: ", e) 78 | sys.exit(1) 79 | 80 | print(r"""Usage: %s [oldname] newname 81 | 82 | Replaces the [oldname] entries in the Windows configuration files 83 | with [newname]. By default, [oldname] is set to "c:\omero_dist" 84 | """ % sys.argv[0]) 85 | sys.exit(2) 86 | -------------------------------------------------------------------------------- /src/omero/install/windows_warning.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2009-2016 University of Dundee. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | 8 | """ 9 | windows helper plugin 10 | 11 | """ 12 | 13 | from functools import wraps 14 | 15 | WINDOWS_WARNING = ("ERROR: OMERO.server support for Windows was removed" 16 | " in OMERO 5.3, see http://blog.openmicroscopy.org/" 17 | "tech-issues/future-plans/deployment/2016/03/22/" 18 | "windows-support/") 19 | 20 | 21 | def windows_warning(func): 22 | """ 23 | Support for Windows will be removed 24 | """ 25 | def win_warn(func): 26 | def wrapper(self, *args, **kwargs): 27 | if self._isWindows(): 28 | self.ctx.die(20, WINDOWS_WARNING) 29 | return func(self, *args, **kwargs) 30 | return wrapper 31 | return wraps(func)(win_warn(func)) 32 | -------------------------------------------------------------------------------- /src/omero/java.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2007 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | import os 10 | import shlex 11 | import platform 12 | import subprocess 13 | 14 | 15 | DEFAULT_DEBUG = "-Xrunjdwp:server=y,transport=dt_socket,address=8787,suspend=n" 16 | 17 | 18 | def check_java(command): 19 | try: 20 | p = subprocess.Popen( 21 | [command[0], "-version"], stdout=subprocess.PIPE, 22 | stderr=subprocess.PIPE) 23 | p.communicate() 24 | rc = p.wait() 25 | if rc == 0: 26 | return 27 | except: 28 | pass # Falls through to raise 29 | 30 | raise Exception("Java could not be found. (Executable=%s)" % command[0]) 31 | 32 | 33 | def makeVar(key, env): 34 | if key in list(os.environ.keys()): 35 | env[key] = os.environ[key] 36 | 37 | 38 | def cmd(args, 39 | java="java", 40 | xargs=None, 41 | chdir=None, 42 | debug=None, 43 | debug_string=DEFAULT_DEBUG): 44 | """ 45 | Defines the command to be used by run or popen. 46 | """ 47 | # Convert strings to an array for appending 48 | if isinstance(java, str): 49 | command = [java] 50 | else: 51 | command = list(java) 52 | 53 | if isinstance(xargs, str): 54 | xargs = shlex.split(xargs) 55 | 56 | # Add our logging configuration early 57 | # so that it can be overwritten by xargs 58 | command += ["-Dlog4j.configuration=%s" % os.path.join("etc", "log4j.xml")] 59 | 60 | # Preapre arguments 61 | if xargs is not None: 62 | command += xargs 63 | 64 | # Prepare debugging 65 | if debug is None: 66 | if "DEBUG" in list(os.environ.keys()): 67 | command += ["-Xdebug", debug_string] 68 | else: 69 | if debug: 70 | command += ["-Xdebug", debug_string] 71 | 72 | # Add JAVA_OPTS at the end. ticket:1439 73 | if "JAVA_OPTS" in list(os.environ.keys()): 74 | command += shlex.split(os.environ["JAVA_OPTS"]) 75 | 76 | # Do any mandatory configuration very late 77 | command += ["-Djava.awt.headless=true"] 78 | 79 | # Add the actual arguments now 80 | command += args 81 | 82 | return command 83 | 84 | 85 | def run(args, 86 | use_exec=False, 87 | java="java", 88 | xargs=None, 89 | chdir=None, 90 | debug=None, 91 | debug_string=DEFAULT_DEBUG, 92 | stdout=subprocess.PIPE, 93 | stderr=subprocess.PIPE): 94 | """ 95 | Execute a Java process, either via subprocess waiting for the process 96 | to finish and returning the output or if use_exec is True, via os.execvpe 97 | with the current environment. 98 | 99 | -X style arguments for the Java process can be set either via the xargs 100 | argument or if unset, the JAVA_OPTS environment variable will be checked. 101 | Note: shlex.split() is called on the JAVA_OPTS value and so bash-style 102 | escaping can be used to protect whitespaces. 103 | 104 | Debugging can more simply be turned on by passing True for the debug 105 | argument. If more control over the debugging configuration is needed, 106 | pass debug_string. 107 | """ 108 | command = cmd(args, java, xargs, chdir, debug, debug_string) 109 | check_java(command) 110 | if use_exec: 111 | env = os.environ 112 | if chdir: 113 | os.chdir(chdir) 114 | if platform.system() == "Windows": 115 | command = ["\"%s\"" % i for i in command] 116 | os.execvpe(command[0], command, env) 117 | else: 118 | os.execvpe(command[0], command, env) 119 | else: 120 | p = popen(args, java, xargs, chdir, debug, debug_string) 121 | output = p.communicate()[0] 122 | return output 123 | 124 | 125 | def popen(args, 126 | java="java", 127 | xargs=None, 128 | chdir=None, 129 | debug=None, 130 | debug_string=DEFAULT_DEBUG, 131 | stdout=subprocess.PIPE, 132 | stderr=subprocess.PIPE): 133 | """ 134 | Creates a subprocess.Popen object and returns it. Uses cmd() internally 135 | to create the Java command to be executed. This is the same logic as 136 | run(use_exec=False) but the Popen is returned rather than the stdout. 137 | """ 138 | command = cmd(args, java, xargs, chdir, debug, debug_string) 139 | check_java(command) 140 | if not chdir: 141 | chdir = os.getcwd() 142 | return subprocess.Popen(command, stdout=stdout, stderr=stderr, 143 | cwd=chdir, env=os.environ) 144 | -------------------------------------------------------------------------------- /src/omero/main.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # 4 | # :author: Josh Moore 5 | # 6 | # Copyright (c) 2007, Glencoe Software, Inc. 7 | # See LICENSE for details. 8 | # 9 | 10 | """ 11 | Python driver for OMERO 12 | """ 13 | 14 | import logging 15 | import os 16 | import sys 17 | 18 | import warnings 19 | warnings.filterwarnings("ignore", category=DeprecationWarning) 20 | # Assuming a CLI user never wants to see development details 21 | # such as code that has been deprecated. 22 | 23 | 24 | def not_root(): 25 | """ 26 | Check that the effective current user is not 0 27 | on systems supporting os.geteuid() 28 | """ 29 | try: 30 | euid = os.geteuid() 31 | if euid == 0: 32 | print( 33 | "FATAL: Running %s as root can corrupt your directory " 34 | "permissions." % sys.argv[0]) 35 | sys.exit(1) 36 | else: 37 | return euid 38 | except AttributeError: 39 | # This platform doesn't support effective uid 40 | # So nothing to worry about. 41 | return None 42 | 43 | 44 | def readlink(file=sys.argv[0]): 45 | """ 46 | Resolve symlinks and similar. This is useful to allow 47 | linking this file under /usr/bin/, for example. 48 | """ 49 | import stat 50 | 51 | file = sys.argv[0] 52 | if not os.path.exists(file) and sys.platform == 'win32': 53 | file += '.exe' 54 | while stat.S_ISLNK(os.lstat(file)[stat.ST_MODE]): 55 | target = os.readlink(file) 56 | if target[0] != "/": 57 | file = os.path.join(os.path.dirname(file), target) 58 | else: 59 | file = target 60 | 61 | file = os.path.abspath(file) 62 | return file 63 | 64 | 65 | def main(): 66 | not_root() 67 | 68 | if "OMERO_HOME" in os.environ: 69 | print("WARN: OMERO_HOME usage is ignored in omero-py") 70 | 71 | exe = readlink() 72 | top = os.path.join(exe, os.pardir, os.pardir) 73 | 74 | # 75 | # This list needs to be kept in line with omero.cli.CLI._env 76 | # 77 | top = os.path.normpath(top) 78 | var = os.path.join(top, "var") 79 | vlb = os.path.join(var, "lib") 80 | sys.path.append(vlb) 81 | 82 | # Testing shortcut. If the first argument is an 83 | # empty string, exit sucessfully. 84 | # 85 | if len(sys.argv) == 2 and sys.argv[1] == "": 86 | sys.exit(0) 87 | 88 | # 89 | # Primary activity: import omero.cli and launch 90 | # catching any Ctrl-Cs from the user 91 | # 92 | try: 93 | try: 94 | import omero.cli 95 | except ImportError as ie: 96 | OMERODIR = os.environ.get('OMERODIR', None) 97 | print("*"*80) 98 | print(""" 99 | ERROR: Could not import omero.cli! (%s) 100 | 101 | This means that your installation is incomplete. Contact 102 | the OME mailing lists for more information: 103 | 104 | https://www.openmicroscopy.org/support/ 105 | 106 | If you are building from source, please supply the build log 107 | as well as which version you are building from. If you 108 | downloaded a distribution, please provide which link you 109 | used. 110 | """ % ie) 111 | print("*"*80) 112 | print(""" 113 | Debugging Info: 114 | -------------- 115 | CWD=%s 116 | VERSION=%s 117 | OMERO_EXE=%s 118 | OMERODIR=%s 119 | PYTHONPATH=%s 120 | """ % (os.getcwd(), sys.version.replace("\n", " "), top, 121 | OMERODIR, sys.path)) 122 | sys.exit(2) 123 | 124 | logging.basicConfig(level=logging.WARN) 125 | rv = omero.cli.argv() 126 | sys.exit(rv) 127 | except KeyboardInterrupt: 128 | print("Cancelled") 129 | sys.exit(1) 130 | -------------------------------------------------------------------------------- /src/omero/min.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # 5 | # Copyright 2010-2014 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | # This file is an import-only file providing a mechanism for other files to 10 | # import a range of modules in a controlled way. It could be made to pass 11 | # flake8 but given its simplicity it is being marked as noqa for now. 12 | # 13 | # flake8: noqa 14 | 15 | import omero 16 | import IceImport 17 | if omero.__import_style__ is None: 18 | omero.__import_style__ = "min" 19 | 20 | # Internal types 21 | IceImport.load("omero_model_NamedValue_ice") 22 | 23 | # New Command API 24 | IceImport.load("omero_cmd_Admin_ice") 25 | IceImport.load("omero_cmd_API_ice") 26 | IceImport.load("omero_cmd_Basic_ice") 27 | IceImport.load("omero_cmd_FS_ice") 28 | IceImport.load("omero_cmd_Graphs_ice") 29 | IceImport.load("omero_cmd_Mail_ice") 30 | 31 | # Previous ServiceFactory API 32 | IceImport.load("omero_API_ice") 33 | IceImport.load("omero_ServicesF_ice") 34 | IceImport.load("omero_Constants_ice") 35 | 36 | IceImport.load("Glacier2_Router_ice") 37 | import omero.rtypes 38 | -------------------------------------------------------------------------------- /src/omero/model/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # This file is an import-only file providing a mechanism for other files to 5 | # import a range of modules in a controlled way. It could be made to pass 6 | # flake8 but given its simplicity it is being marked as noqa for now. 7 | # 8 | # flake8: noqa 9 | 10 | from omero import ObjectFactoryRegistrar 11 | 12 | import IceImport 13 | 14 | IceImport.load("omero_model_NamedValue_ice") 15 | -------------------------------------------------------------------------------- /src/omero/plugins/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/plugins/__init__.py -------------------------------------------------------------------------------- /src/omero/plugins/_duplicate_deprecated.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2016 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | Plugin for duplicating object graphs 24 | 25 | """ 26 | 27 | import sys 28 | import os 29 | import warnings 30 | 31 | from omero.cli import CLI, GraphControl 32 | 33 | HELP = """Duplicate OMERO data. 34 | 35 | Duplicate entire graphs of data based on the ID of the top-node. 36 | 37 | Note that no object that corresponds to a file on disk will be duplicated. 38 | In some circumstances a duplicate object may reference an original object that 39 | does have associated binary data but a duplicated image should not be expected 40 | to include any pixel data. 41 | 42 | Examples: 43 | 44 | # Duplicate a dataset 45 | omero duplicate Dataset:50 46 | # Do the same reporting all the new duplicate objects 47 | omero duplicate Dataset:50 --report 48 | 49 | # Do a dry run of a duplicate reporting the outcome 50 | # if the duplicate had been run 51 | omero duplicate Dataset:53 --dry-run 52 | # Do a dry run of a duplicate, reporting all the objects 53 | # that would have been duplicated 54 | omero duplicate Dataset:53 --dry-run --report 55 | 56 | """ 57 | 58 | 59 | DEPRECATION_MESSAGE = ( 60 | "This plugin is deprecated as of OMERO.py 5.8.0. Use the plugin" 61 | " available from https://pypi.org/project/omero-cli-duplicate/" 62 | " instead.") 63 | 64 | 65 | class DuplicateControl(GraphControl): 66 | 67 | def main_method(self, args): 68 | self.ctx.err(DEPRECATION_MESSAGE, DeprecationWarning) 69 | super(DuplicateControl, self).main_method(args) 70 | 71 | def cmd_type(self): 72 | import omero 73 | import omero.all 74 | return omero.cmd.Duplicate 75 | 76 | def print_detailed_report(self, req, rsp, status): 77 | import omero 78 | if isinstance(rsp, omero.cmd.DoAllRsp): 79 | for response in rsp.responses: 80 | if isinstance(response, omero.cmd.DuplicateResponse): 81 | self.print_duplicate_response(response) 82 | elif isinstance(rsp, omero.cmd.DuplicateResponse): 83 | self.print_duplicate_response(rsp) 84 | 85 | def print_duplicate_response(self, rsp): 86 | if rsp.duplicates: 87 | self.ctx.out("Duplicates") 88 | objIds = self._get_object_ids(rsp.duplicates) 89 | for k in objIds: 90 | self.ctx.out(" %s:%s" % (k, objIds[k])) 91 | 92 | try: 93 | if "OMERO_DEV_PLUGINS" in os.environ: 94 | warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning) 95 | register("duplicate", DuplicateControl, HELP) 96 | except NameError: 97 | if __name__ == "__main__": 98 | cli = CLI() 99 | cli.register("duplicate", DuplicateControl, HELP) 100 | cli.invoke(sys.argv[1:]) 101 | -------------------------------------------------------------------------------- /src/omero/plugins/_upload_deprecated.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2007-2016 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | 8 | """ 9 | upload plugin 10 | 11 | Plugin read by omero.cli.Cli during initialization. The method(s) 12 | defined here will be added to the Cli class for later use. 13 | """ 14 | 15 | import sys 16 | import re 17 | import os 18 | import warnings 19 | import mimetypes 20 | 21 | from omero.cli import BaseControl, CLI 22 | import omero_ext.path as path 23 | 24 | HELP = """Upload local files to the OMERO server""" 25 | RE = re.compile(r"\s*upload\s*") 26 | UNKNOWN = 'type/unknown' 27 | 28 | 29 | class UploadControl(BaseControl): 30 | 31 | def _complete(self, text, line, begidx, endidx): 32 | """ 33 | Returns a file after "upload" and otherwise delegates to the 34 | BaseControl 35 | """ 36 | m = RE.match(line) 37 | if m: 38 | return self._complete_file(RE.sub('', line)) 39 | else: 40 | return BaseControl._complete(self, text, line, begidx, endidx) 41 | 42 | def _configure(self, parser): 43 | parser.add_argument("file", nargs="+") 44 | parser.set_defaults(func=self.upload) 45 | parser.add_login_arguments() 46 | 47 | def upload(self, args): 48 | self.ctx.err( 49 | "This module is deprecated as of OMERO 5.5.0. Use the module" 50 | " available from https://pypi.org/project/omero-upload/" 51 | " instead.", DeprecationWarning) 52 | client = self.ctx.conn(args) 53 | objIds = [] 54 | for file in args.file: 55 | if not path.path(file).exists(): 56 | self.ctx.die(500, "File: %s does not exist" % file) 57 | for file in args.file: 58 | omero_format = UNKNOWN 59 | if(mimetypes.guess_type(file) != (None, None)): 60 | omero_format = mimetypes.guess_type(file)[0] 61 | obj = client.upload(file, type=omero_format) 62 | objIds.append(obj.id.val) 63 | self.ctx.set("last.upload.id", obj.id.val) 64 | 65 | objIds = self._order_and_range_ids(objIds) 66 | self.ctx.out("OriginalFile:%s" % objIds) 67 | 68 | try: 69 | if "OMERO_NO_DEPRECATED_PLUGINS" not in os.environ: 70 | warnings.warn( 71 | "This plugin is deprecated as of OMERO 5.5.0. Use the upload" 72 | " CLI plugin available from" 73 | " https://pypi.org/project/omero-upload/ instead.", 74 | DeprecationWarning) 75 | register("upload", UploadControl, HELP) 76 | except NameError: 77 | if __name__ == "__main__": 78 | cli = CLI() 79 | cli.register("upload", UploadControl, HELP) 80 | cli.invoke(sys.argv[1:]) 81 | -------------------------------------------------------------------------------- /src/omero/plugins/chgrp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2011-2015 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | """ 10 | chgrp plugin 11 | 12 | Plugin read by omero.cli.Cli during initialization. The method(s) 13 | defined here will be added to the Cli class for later use. 14 | """ 15 | 16 | from omero.cli import CLI, GraphControl, ExperimenterGroupArg 17 | import sys 18 | 19 | HELP = """Move data between groups 20 | 21 | Move entire graphs of data based on the ID of the top-node. 22 | 23 | Examples: 24 | 25 | # In each case move an image to group 101 26 | omero chgrp 101 Image:1 27 | omero chgrp Group:101 Image:2 28 | omero chgrp ExperimenterGroup:101 Image:3 29 | # In both cases move five images to the group named "My Lab" 30 | omero chgrp "My Lab" Image:51,52,53,54,56 31 | omero chgrp "My Lab" Image:51-54,56 32 | 33 | # Move a plate but leave all images in the original group 34 | omero chgrp 201 Plate:1 --exclude Image 35 | 36 | # Move all images contained under a project 37 | omero chgrp 101 Project/Dataset/Image:53 38 | # Move all images contained under two projects 39 | omero chgrp 101 Project/Image:201,202 40 | 41 | # Do a dry run of a move reporting the outcome if the move had been run 42 | omero chgrp 101 Dataset:53 --dry-run 43 | # Do a dry run of a move, reporting all the objects 44 | # that would have been moved 45 | omero chgrp 101 Dataset:53 --dry-run --report 46 | 47 | """ 48 | 49 | 50 | class ChgrpControl(GraphControl): 51 | 52 | def cmd_type(self): 53 | import omero 54 | import omero.all 55 | return omero.cmd.Chgrp2 56 | 57 | def _pre_objects(self, parser): 58 | parser.add_argument( 59 | "grp", nargs="?", type=ExperimenterGroupArg, 60 | help="""Group to move objects to""") 61 | 62 | def is_admin(self, client): 63 | # check if the user currently logged is an admin 64 | from omero.model.enums import AdminPrivilegeChgrp 65 | ec = self.ctx.get_event_context() 66 | return AdminPrivilegeChgrp in ec.adminPrivileges 67 | 68 | def _process_request(self, req, args, client): 69 | # Retrieve group id 70 | gid = args.grp.lookup(client) 71 | if gid is None: 72 | self.ctx.die(196, "Failed to find group: %s" % args.grp.orig) 73 | 74 | # Retrieve group 75 | import omero 76 | try: 77 | group = client.sf.getAdminService().getGroup(gid) 78 | except omero.ApiUsageException: 79 | self.ctx.die(196, "Failed to find group: %s" % args.grp.orig) 80 | 81 | # Check session owner is member of the target group 82 | uid = self.ctx.get_event_context().userId 83 | admin = self.is_admin(client) 84 | ids = [x.child.id.val for x in group.copyGroupExperimenterMap()] 85 | # check if the user is an admin 86 | if uid not in ids and not admin: 87 | self.ctx.die(197, "Current user is not member of group: %s" % 88 | group.id.val) 89 | 90 | # Set requests group 91 | if isinstance(req, omero.cmd.DoAll): 92 | for request in req.requests: 93 | if isinstance(request, omero.cmd.SkipHead): 94 | request.request.groupId = gid 95 | else: 96 | request.groupId = gid 97 | else: 98 | if isinstance(req, omero.cmd.SkipHead): 99 | req.request.groupId = gid 100 | else: 101 | req.groupId = gid 102 | 103 | super(ChgrpControl, self)._process_request(req, args, client) 104 | 105 | def print_detailed_report(self, req, rsp, status): 106 | import omero 107 | if isinstance(rsp, omero.cmd.DoAllRsp): 108 | for response in rsp.responses: 109 | if isinstance(response, omero.cmd.Chgrp2Response): 110 | self.print_chgrp_response(response) 111 | elif isinstance(rsp, omero.cmd.Chgrp2Response): 112 | self.print_chgrp_response(rsp) 113 | 114 | def print_chgrp_response(self, rsp): 115 | if rsp.includedObjects: 116 | self.ctx.out("Included objects") 117 | obj_ids = self._get_object_ids(rsp.includedObjects) 118 | for k in obj_ids: 119 | self.ctx.out(" %s:%s" % (k, obj_ids[k])) 120 | if rsp.deletedObjects: 121 | self.ctx.out("Deleted objects") 122 | obj_ids = self._get_object_ids(rsp.deletedObjects) 123 | for k in obj_ids: 124 | self.ctx.out(" %s:%s" % (k, obj_ids[k])) 125 | 126 | try: 127 | register("chgrp", ChgrpControl, HELP) 128 | except NameError: 129 | if __name__ == "__main__": 130 | cli = CLI() 131 | cli.register("chgrp", ChgrpControl, HELP) 132 | cli.invoke(sys.argv[1:]) 133 | -------------------------------------------------------------------------------- /src/omero/plugins/delete.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # Copyright 2009-2015 Glencoe Software, Inc. All rights reserved. 5 | # Use is subject to license terms supplied in LICENSE.txt 6 | # 7 | 8 | """ 9 | Startup plugin for command-line deletes 10 | """ 11 | 12 | import sys 13 | 14 | from omero.cli import CLI, GraphControl 15 | 16 | HELP = """Delete OMERO data. 17 | 18 | Remove entire graphs of data based on the ID of the top-node. 19 | 20 | By default linked tag, file and term annotations are not deleted. 21 | To delete linked annotations they must be explicitly included. 22 | 23 | Examples: 24 | 25 | # Delete an image but not its linked tag, file and term annotations 26 | omero delete Image:50 27 | # Delete an image including linked tag, file and term annotations 28 | omero delete Image:51 --include TagAnnotation,FileAnnotation,TermAnnotation 29 | # Delete an image including all linked annotations 30 | omero delete Image:52 --include Annotation 31 | 32 | # Delete three images and two datasets including their contents 33 | omero delete Image:101,102,103 Dataset:201,202 34 | # Delete five images and four datasets including their contents 35 | # Note that --force flag is required when deleting a range, if not 36 | # passed, a dry run is performed 37 | omero delete Image:106-110 Dataset:203-205,207 --force 38 | # Delete a project excluding contained datasets and linked annotations 39 | omero delete Project:101 --exclude Dataset,Annotation 40 | 41 | # Delete all images contained under a project 42 | omero delete Project/Dataset/Image:53 43 | # Delete all images contained under two projects 44 | omero delete Project/Image:201,202 45 | 46 | # Do a dry run of a delete reporting the outcome if the delete had been run 47 | omero delete Dataset:53 --dry-run 48 | # Do a dry run of a delete, reporting all the objects 49 | # that would have been deleted 50 | omero delete Dataset:53 --dry-run --report 51 | 52 | """ 53 | 54 | 55 | class DeleteControl(GraphControl): 56 | 57 | def cmd_type(self): 58 | import omero 59 | import omero.all 60 | return omero.cmd.Delete2 61 | 62 | def print_detailed_report(self, req, rsp, status): 63 | import omero 64 | if isinstance(rsp, omero.cmd.DoAllRsp): 65 | for response in rsp.responses: 66 | if isinstance(response, omero.cmd.Delete2Response): 67 | self.print_delete_response(response) 68 | elif isinstance(rsp, omero.cmd.Delete2Response): 69 | self.print_delete_response(rsp) 70 | 71 | def print_delete_response(self, rsp): 72 | if rsp.deletedObjects: 73 | self.ctx.out("Deleted objects") 74 | objIds = self._get_object_ids(rsp.deletedObjects) 75 | for k in objIds: 76 | self.ctx.out(" %s:%s" % (k, objIds[k])) 77 | 78 | def default_exclude(self): 79 | """ 80 | Don't delete these three types of Annotation by default 81 | """ 82 | return ["TagAnnotation", "TermAnnotation", "FileAnnotation"] 83 | 84 | 85 | try: 86 | register("delete", DeleteControl, HELP) 87 | except NameError: 88 | if __name__ == "__main__": 89 | cli = CLI() 90 | cli.register("delete", DeleteControl, HELP) 91 | cli.invoke(sys.argv[1:]) 92 | -------------------------------------------------------------------------------- /src/omero/plugins/perf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2008, 2016 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | 8 | """ 9 | Plugin for measuring the performance of an OMERO 10 | installation. 11 | 12 | Plugin read by omero.cli.Cli during initialization. The method(s) 13 | defined here will be added to the Cli class for later use. 14 | """ 15 | 16 | import sys 17 | from omero.cli import BaseControl, CLI 18 | from omero_ext.argparse import FileType 19 | import omero.install.perf_test as perf_test 20 | 21 | HELP = """Run perf_test files 22 | 23 | %s 24 | 25 | """ % perf_test.FILE_FORMAT 26 | 27 | 28 | class PerfControl(BaseControl): 29 | 30 | def _configure(self, parser): 31 | parser.add_argument( 32 | "-l", "--list", action="store_true", 33 | help="List available commands") 34 | parser.add_argument( 35 | "file", nargs="*", type=FileType('r'), default=None, 36 | help="Read from files or standard in") 37 | parser.set_defaults(func=self.__call__) 38 | parser.add_login_arguments() 39 | 40 | def __call__(self, args): 41 | if args.list: 42 | ops = [x[4:] for x in dir(perf_test.Item) if x.startswith("_op_")] 43 | ops.sort() 44 | for op in ops: 45 | print(op) 46 | else: 47 | if not args.file: 48 | self.ctx.die(167, "No files given. Use '-' for stdin.") 49 | client = self.ctx.conn(args) 50 | ctx = perf_test.Context(None, client=client) 51 | self.ctx.out("Saving performance results to %s" % ctx.dir) 52 | ctx.add_reporter(perf_test.CsvReporter(ctx.dir)) 53 | # ctx.add_reporter(perf_test.HdfReporter(ctx.dir)) 54 | # ctx.add_reporter(perf_test.PlotReporter()) 55 | handler = perf_test.PerfHandler(ctx) 56 | perf_test.handle(handler, args.file) 57 | 58 | try: 59 | register("perf", PerfControl, HELP) 60 | except NameError: 61 | if __name__ == "__main__": 62 | cli = CLI() 63 | cli.register("perf", PerfControl, HELP) 64 | cli.invoke(sys.argv[1:]) 65 | -------------------------------------------------------------------------------- /src/omero/plugins/submit.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2007 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | 8 | """ 9 | submit plugin 10 | 11 | Plugin read by omero.cli.Cli during initialization. The method(s) 12 | defined here will be added to the Cli class for later use. 13 | """ 14 | 15 | from omero.cli import BaseControl, CLI 16 | import sys 17 | 18 | prompt = "omero submit [%s]> " 19 | 20 | 21 | class Save(Exception): 22 | pass 23 | 24 | 25 | class Cancel(Exception): 26 | pass 27 | 28 | 29 | class SubmitCLI(CLI): 30 | 31 | def __init__(self): 32 | CLI.__init__(self) 33 | self.queue = [] 34 | self.prompt = prompt % str(0) 35 | 36 | def postcmd(self, stop, line): 37 | self.queue.append(line) 38 | self.prompt = prompt % str(len(self.queue)) 39 | return CLI.postcmd(self, stop, line) 40 | 41 | def do_save(self, arg): 42 | raise Save() 43 | 44 | def do_cancel(self, arg): 45 | raise Cancel() 46 | 47 | def post_process(self): 48 | print("Uploading") 49 | print(self.queue) 50 | 51 | HELP = """When run without arguments, submit shell is opened 52 | which takes commands without executing them. On save, 53 | the file is trasferred to the server, and executed.""" 54 | 55 | 56 | class SubmitControl(BaseControl): 57 | 58 | def _configure(self, parser): 59 | parser.add_argument("arg", nargs="*", help="single command with args") 60 | parser.set_defaults(func=self.__call__) 61 | 62 | def __call__(self, args): 63 | submit = SubmitCLI() 64 | arg = args.arg 65 | if arg and len(arg) > 0: 66 | submit.invoke(arg) 67 | submit.post_process() 68 | else: 69 | try: 70 | submit.invokeloop() 71 | except Save: 72 | submit.execute() 73 | except Cancel: 74 | l = len(submit.queue) 75 | if l > 0: 76 | print(l, " items queued. Really cancel? [Yn]") 77 | 78 | try: 79 | # register("submit", SubmitControl, HELP) 80 | pass 81 | except NameError: 82 | if __name__ == "__main__": 83 | cli = CLI() 84 | cli.register("submit", SubmitControl, HELP) 85 | cli.invoke(sys.argv[1:]) 86 | -------------------------------------------------------------------------------- /src/omero/romio/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero/romio/__init__.py -------------------------------------------------------------------------------- /src/omero/sys/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import IceImport 4 | IceImport.load("omero_System_ice") 5 | IceImport.load("omero_Collections_ice") 6 | IceImport.load("omero_sys_ParametersI") 7 | -------------------------------------------------------------------------------- /src/omero/testlib/script.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2016 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | import omero 23 | import logging 24 | from omero.testlib import ITest 25 | from omero.gateway import BlitzGateway 26 | 27 | 28 | class ScriptTest(ITest): 29 | 30 | def get_script(self, path): 31 | script_service = self.root.sf.getScriptService() 32 | script = _get_script(script_service, path) 33 | if script is None: 34 | return -1 35 | return script.getId().getValue() 36 | 37 | 38 | def run_script(client, script_id, args, key=None): 39 | script_service = client.sf.getScriptService() 40 | proc = script_service.runScript(script_id, args, None) 41 | try: 42 | cb = omero.scripts.ProcessCallbackI(client, proc) 43 | while not cb.block(1000): # ms. 44 | pass 45 | cb.close() 46 | results = proc.getResults(0) # ms 47 | finally: 48 | proc.close(False) 49 | 50 | if 'stdout' in results: 51 | orig_file = results['stdout'].getValue() 52 | v = "Script generated StdOut in file:", orig_file.getId().getValue() 53 | logging.debug(v) 54 | assert orig_file.id.val > 0 55 | if 'stderr' in results: 56 | orig_file = results['stderr'].getValue() 57 | v = "Script generated StdErr in file:", orig_file.getId().getValue() 58 | logging.debug(v) 59 | assert orig_file.getId().getValue() > 0 60 | if key and key in results: 61 | return results[key] 62 | 63 | 64 | def _get_script(script_service, script_path): 65 | """ Utility method, return the script or None """ 66 | scripts = script_service.getScripts() # returns list of OriginalFiles 67 | 68 | # make sure path starts with a slash. 69 | # ** If you are a Windows client - will need to convert all path separators 70 | # to "/" since server stores /path/to/script.py ** 71 | if not script_path.startswith("/"): 72 | script_path = "/" + script_path 73 | 74 | named_scripts = [ 75 | s for s in scripts if 76 | s.getPath().getValue() + s.getName().getValue() == script_path] 77 | 78 | if len(named_scripts) == 0: 79 | return None 80 | 81 | return named_scripts[0] 82 | 83 | 84 | def points_to_string(points): 85 | """ Returns legacy format supported by Insight """ 86 | points = ["%s,%s" % (p[0], p[1]) for p in points] 87 | csv = ", ".join(points) 88 | return "points[%s] points1[%s] points2[%s]" % (csv, csv, csv) 89 | 90 | 91 | def check_file_annotation(client, file_annotation, 92 | parent_type="Image", is_linked=True, 93 | file_name=None): 94 | """ 95 | Check validity of file annotation. If hasFileAnnotation, check the size, 96 | name and number of objects linked to the original file. 97 | """ 98 | assert file_annotation is not None 99 | orig_file = file_annotation.getValue().getFile() 100 | assert orig_file.getSize().getValue() > 0 101 | assert orig_file.getName().getValue() is not None 102 | id = file_annotation.getValue().getId().getValue() 103 | assert id > 0 104 | 105 | conn = BlitzGateway(client_obj=client) 106 | wrapper = conn.getObject("FileAnnotation", id) 107 | name = None 108 | if file_name is not None: 109 | name = wrapper.getFile().getName() 110 | 111 | links = sum(1 for i in wrapper.getParentLinks(parent_type)) 112 | conn.close() 113 | 114 | if is_linked: 115 | assert links == 1 116 | else: 117 | assert links == 0 118 | 119 | if file_name is not None: 120 | assert name == file_name 121 | -------------------------------------------------------------------------------- /src/omero/util/_process_defaultxml.py: -------------------------------------------------------------------------------- 1 | """ 2 | Convert the nodes and server-instances in default.xml to a multi-node 3 | configuration 4 | 5 | The configuration string should be in the form node1:s1,s2,... node2:s3 ... 6 | 7 | Examples 8 | 9 | Everything on a single node (default, the same as passing no config): 10 | master:Blitz-0,Indexer-0,DropBox,MonitorServer,FileServer,Storm,PixelData-0,Processor-0,Tables-0,TestDropBox 11 | 12 | Processor on a separate node: 13 | master:Blitz-0,Indexer-0,DropBox,MonitorServer,FileServer,Storm,PixelData-0,Tables-0,TestDropBox slave:Processor-0 14 | 15 | Two Processor and two PixelData on two separate nodes: 16 | master:Blitz-0,Indexer-0,DropBox,MonitorServer,FileServer,Storm,Tables-0,TestDropBox slave-1:Processor-0,PixelData-0 slave-2:Processor-1,PixelData-1 17 | """ 18 | 19 | 20 | import re 21 | import sys 22 | 23 | 24 | def _getnodes(nodedescs): 25 | nodes = {} 26 | for nd in nodedescs: 27 | s = '' 28 | node, descs = nd.split(':') 29 | descs = descs.split(',') 30 | for d in descs: 31 | try: 32 | t, i = d.split('-') 33 | except ValueError: 34 | t = d 35 | i = None 36 | s += ' \s*\]*\>(.*?\)' 50 | m = re.search(pattern, xml, re.DOTALL) 51 | assert m 52 | 53 | master = '\n \n' 54 | slaves = '' 55 | nodes = _getnodes(nodedescs.split()) 56 | for nodename in sorted(nodes.keys()): 57 | servers = nodes[nodename] 58 | if nodename == 'master': 59 | master = '%s%s' % (servers, master) 60 | else: 61 | slaves += ' \n%s \n' % (nodename, servers) 62 | 63 | if nodes: 64 | xmlout = xml[:m.start(1)] + master + slaves + xml[m.end(1):] 65 | else: 66 | xmlout = xml 67 | return xmlout 68 | -------------------------------------------------------------------------------- /src/omero/util/concurrency.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2009 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | """ 10 | OMERO Concurrency Utilities 11 | """ 12 | import atexit 13 | import logging 14 | import threading 15 | import omero.util 16 | import logging.handlers 17 | 18 | from threading import Event as _Event 19 | from threading import Timer as _Timer 20 | 21 | 22 | def get_event(name="Unknown"): 23 | """ 24 | Returns a threading.Event instance which is registered to be 25 | "set" (Event.set()) on system exit. 26 | """ 27 | event = AtExitEvent(name=name) 28 | atexit.register(event.setAtExit) 29 | return event 30 | 31 | 32 | class AtExitEvent(_Event): 33 | 34 | """ 35 | threading.Event extension which provides an additional method 36 | setAtExit() which sets "atexit" to true. 37 | 38 | This class was introduced in 4.2.1 to work around issue #3260 39 | in which logging from background threads produced error 40 | messages. 41 | """ 42 | 43 | def __init__(self, verbose=None, name="Unknown"): 44 | try: 45 | super(AtExitEvent, self).__init__(verbose) 46 | except TypeError: 47 | # in Python 3 there is no verbose argument 48 | super(AtExitEvent, self).__init__() 49 | self.__name = name 50 | self.__atexit = False 51 | 52 | name = property(lambda self: self.__name) 53 | atexit = property(lambda self: self.__atexit) 54 | 55 | def setAtExit(self): 56 | self.__atexit = True 57 | super(AtExitEvent, self).set() 58 | 59 | def __repr__(self): 60 | return "%s (%s)" % (super(AtExitEvent, self).__repr__(), self.__name) 61 | 62 | 63 | class Timer(_Timer): 64 | 65 | """Based on threading._Thread but allows for resetting the Timer. 66 | 67 | t = Timer(30.0, f, args=[], kwargs={}) 68 | t.start() 69 | t.cancel() # stop the timer's action if it's still waiting 70 | 71 | # or 72 | 73 | t.reset() 74 | 75 | After excecution, the status of the run can be checked via the 76 | "completed" and the "exception" Event instances. 77 | """ 78 | 79 | def __init__(self, interval, function, args=None, kwargs=None): 80 | if args is None: 81 | args = [] 82 | if kwargs is None: 83 | kwargs = {} 84 | _Timer.__init__(self, interval, function, args, kwargs) 85 | self.log = logging.getLogger(omero.util.make_logname(self)) 86 | self.completed = threading.Event() 87 | self.exception = threading.Event() 88 | self._reset = threading.Event() 89 | 90 | def reset(self): 91 | self.log.debug("Reset called") 92 | self._reset.set() # Set first, so that the loop will continue 93 | self.finished.set() # Forces waiting thread to fall through 94 | 95 | def run(self): 96 | while True: 97 | self.finished.wait(self.interval) 98 | if self._reset.isSet(): 99 | self.finished.clear() 100 | self._reset.clear() 101 | self.log.debug("Resetting") 102 | continue 103 | if not self.finished.isSet(): 104 | try: 105 | self.log.debug("Executing") 106 | self.function(*self.args, **self.kwargs) 107 | self.completed.set() 108 | self.finished.set() 109 | except: 110 | self.exception.set() 111 | self.finished.set() 112 | raise 113 | break 114 | -------------------------------------------------------------------------------- /src/omero/util/import_candidates.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright 2009 Glencoe Software, Inc. All rights reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | """ 10 | Utility method for calling the equivalent of "omero import -f". 11 | Results are parsed when using as_dictionary. 12 | 13 | """ 14 | 15 | import omero 16 | 17 | from omero.util.temp_files import create_path, remove_path 18 | from omero.cli import CLI 19 | 20 | 21 | def _to_list(path): 22 | """ 23 | Guarantees that a list of strings will be returned. 24 | Handles unicode caused by "%s" % path.path. 25 | """ 26 | if isinstance(path, str) or isinstance(path, str): 27 | path = [str(path)] 28 | return path 29 | else: 30 | path = [str(x) for x in path] 31 | return path 32 | 33 | 34 | def as_stdout(path, readers="", extra_args=None): 35 | """Returns the import candidates for the given path. 36 | 37 | you can pass more arguments to the `import` command through the 38 | extra_args argument in the form of a list. 39 | 40 | ..code :: 41 | 42 | >>> as_stdout("/my/dir/with_tifs", extra_args=["--depth", "6"]) 43 | 44 | """ 45 | if extra_args is None: 46 | extra_args = [] 47 | path = _to_list(path) 48 | readers = str(readers) 49 | cli = CLI() 50 | cli.loadplugins() 51 | if readers: 52 | cli.invoke(["import", "-l"] + [readers,] + extra_args + ["-f"] + path) 53 | else: 54 | cli.invoke(["import"] + extra_args + ["-f"] + path) 55 | if cli.rv != 0: 56 | raise omero.InternalException( 57 | None, None, "'import -f' exited with a rc=%s. " 58 | "See console for more information" % cli.rv) 59 | 60 | 61 | def as_dictionary(path, readers="", extra_args=None): 62 | """ 63 | Run as_stdout, parses the output and returns a dictionary of the form: 64 | 65 | ``` 66 | { 67 | some_file_in_group : 68 | [ 69 | some_file_in_group 70 | some_other_file_in_group 71 | ... 72 | last_file_in_group 73 | ], 74 | some_file_in_second_group : ... 75 | } 76 | ``` 77 | you can pass more arguments to the `import` command through the 78 | extra_args argument in the form of a list. 79 | 80 | ``` 81 | to_import = as_dictionary("/my/dir/with_tifs", extra_args=["--depth", "6"]) 82 | ``` 83 | 84 | will go through the directories with a depth level of 6 instead of 85 | the default 4. Arguments of interest might be: `debugging`, 86 | `report`, `logback`. Note that the command runs locally so options 87 | such as `--exclude` will not work as they need information from the server. 88 | """ 89 | t = create_path("candidates", "err") 90 | 91 | path = _to_list(path) 92 | path.insert(0, "---file=%s" % t) 93 | try: 94 | as_stdout(path, readers=readers, extra_args=extra_args) 95 | f = open(str(t), "r") 96 | output = f.readlines() 97 | f.close() 98 | finally: 99 | remove_path(t) 100 | 101 | gline = -1 102 | key = None 103 | groups = {} 104 | for line in output: 105 | line = line.strip() 106 | if len(line) == 0: 107 | continue 108 | if line.startswith("#"): 109 | gline = -1 110 | else: 111 | if gline == -1: 112 | gline = 1 113 | key = line 114 | groups[key] = [line] 115 | else: 116 | groups[key].append(line) 117 | 118 | return groups 119 | 120 | 121 | if __name__ == "__main__": 122 | import sys 123 | as_stdout(sys.argv[1:]) 124 | -------------------------------------------------------------------------------- /src/omero/util/pixelstypetopython.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # ------------------------------------------------------------------------------ 5 | # Copyright (C) 2006-2008 University of Dundee. All rights reserved. 6 | # 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License along 18 | # with this program; if not, write to the Free Software Foundation, Inc., 19 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | # 21 | # ------------------------------------------------------------------------------ 22 | # 23 | # The Pixels object in omero, has a member pixelsType, this can be 24 | # INT_8 = "int8"; 25 | # UINT_8 = "uint8"; 26 | # INT_16 = "int16"; 27 | # UINT_16 = "uint16"; 28 | # INT_32 = "int32"; 29 | # UINT_32 = "uint32"; 30 | # FLOAT = "float"; 31 | # DOUBLE = "double"; 32 | # we can convert these to the appropriate types in python. 33 | 34 | from omero.model.enums import PixelsTypeint8, PixelsTypeuint8, PixelsTypeint16 35 | from omero.model.enums import PixelsTypeuint16, PixelsTypeint32 36 | from omero.model.enums import PixelsTypeuint32, PixelsTypefloat 37 | from omero.model.enums import PixelsTypedouble 38 | 39 | INT_8 = PixelsTypeint8 40 | UINT_8 = PixelsTypeuint8 41 | INT_16 = PixelsTypeint16 42 | UINT_16 = PixelsTypeuint16 43 | INT_32 = PixelsTypeint32 44 | UINT_32 = PixelsTypeuint32 45 | FLOAT = PixelsTypefloat 46 | DOUBLE = PixelsTypedouble 47 | 48 | 49 | def toPython(pixelType): 50 | if(pixelType == INT_8): 51 | return 'b' 52 | if(pixelType == UINT_8): 53 | return 'B' 54 | if(pixelType == INT_16): 55 | return 'h' 56 | if(pixelType == UINT_16): 57 | return 'H' 58 | if(pixelType == INT_32): 59 | return 'i' 60 | if(pixelType == UINT_32): 61 | return 'I' 62 | if(pixelType == FLOAT): 63 | return 'f' 64 | if(pixelType == DOUBLE): 65 | return 'd' 66 | 67 | 68 | def toNumpy(pixelType): 69 | import numpy 70 | if(pixelType == INT_8): 71 | return numpy.int8 72 | if(pixelType == UINT_8): 73 | return numpy.uint8 74 | if(pixelType == INT_16): 75 | return numpy.int16 76 | if(pixelType == UINT_16): 77 | return numpy.uint16 78 | if(pixelType == INT_32): 79 | return numpy.int32 80 | if(pixelType == UINT_32): 81 | return numpy.uint32 82 | if(pixelType == FLOAT): 83 | return numpy.float 84 | if(pixelType == DOUBLE): 85 | return numpy.double 86 | 87 | 88 | def toArray(pixelType): 89 | if(pixelType == INT_8): 90 | return 'b' 91 | if(pixelType == UINT_8): 92 | return 'B' 93 | if(pixelType == INT_16): 94 | return 'i2' 95 | if(pixelType == UINT_16): 96 | return 'H2' 97 | if(pixelType == INT_32): 98 | return 'i4' 99 | if(pixelType == UINT_32): 100 | return 'I4' 101 | if(pixelType == FLOAT): 102 | return 'f' 103 | if(pixelType == DOUBLE): 104 | return 'd' 105 | 106 | 107 | def toPIL(pixelType): 108 | if(pixelType == INT_8): 109 | return 'L' 110 | if(pixelType == UINT_8): 111 | return 'L' 112 | if(pixelType == INT_16): 113 | return 'I;16' 114 | if(pixelType == UINT_16): 115 | return 'I;16' 116 | if(pixelType == INT_32): 117 | return 'I' 118 | if(pixelType == UINT_32): 119 | return 'I' 120 | if(pixelType == FLOAT): 121 | return 'F' 122 | if(pixelType == DOUBLE): 123 | return 'F' 124 | -------------------------------------------------------------------------------- /src/omero_ext/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/src/omero_ext/__init__.py -------------------------------------------------------------------------------- /src/omero_model_DetailsI.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Copyright 2007 Glencoe Software, Inc. All rights reserved. 5 | # Use is subject to license terms supplied in LICENSE.txt 6 | # 7 | import Ice 8 | import IceImport 9 | IceImport.load("omero_model_Details_ice") 10 | _omero = Ice.openModule("omero") 11 | _omero_model = Ice.openModule("omero.model") 12 | __name__ = "omero.model" 13 | 14 | 15 | class DetailsI(_omero_model.Details): 16 | 17 | def __init__(self, client=None): 18 | super(DetailsI, self).__init__() 19 | self.__client = client 20 | self.__session = None 21 | if client: 22 | self.__session = client.getSession(False) 23 | 24 | def getClient(self): 25 | return self.__client 26 | 27 | def getSession(self): 28 | return self.__session 29 | 30 | def getEventContext(self): 31 | return self._event 32 | 33 | def getCallContext(self): 34 | return self._call 35 | 36 | def getOwner(self): 37 | return self._owner 38 | 39 | def setOwner(self, value): 40 | self._owner = value 41 | pass 42 | 43 | def getGroup(self): 44 | return self._group 45 | 46 | def setGroup(self, value): 47 | self._group = value 48 | pass 49 | 50 | def getCreationEvent(self): 51 | return self._creationEvent 52 | 53 | def setCreationEvent(self, value): 54 | self._creationEvent = value 55 | pass 56 | 57 | def getUpdateEvent(self): 58 | return self._updateEvent 59 | 60 | def setUpdateEvent(self, value): 61 | self._updateEvent = value 62 | pass 63 | 64 | def getPermissions(self): 65 | return self._permissions 66 | 67 | def setPermissions(self, value): 68 | self._permissions = value 69 | pass 70 | 71 | def getExternalInfo(self): 72 | return self._externalInfo 73 | 74 | def setExternalInfo(self, value): 75 | self._externalInfo = value 76 | pass 77 | 78 | def ice_postUnmarshal(self): 79 | """ 80 | Provides additional initialization once all data loaded 81 | Required due to __getattr__ implementation. 82 | """ 83 | pass # Currently unused 84 | 85 | def ice_preMarshal(self): 86 | """ 87 | Provides additional validation before data is sent 88 | Required due to __getattr__ implementation. 89 | """ 90 | pass # Currently unused 91 | 92 | def __getattr__(self, attr): 93 | if attr == "owner": 94 | return self.getOwner() 95 | elif attr == "group": 96 | return self.getGroup() 97 | elif attr == "creationEvent": 98 | return self.getCreationEvent() 99 | elif attr == "updateEvent": 100 | return self.getUpdateEvent() 101 | elif attr == "permissions": 102 | return self.getPermissions() 103 | elif attr == "externalInfo": 104 | return self.getExternalInfo() 105 | else: 106 | raise AttributeError(attr) 107 | 108 | def __setattr__(self, attr, value): 109 | if attr.startswith("_"): 110 | self.__dict__[attr] = value 111 | else: 112 | try: 113 | object.__getattribute__(self, attr) 114 | object.__setattr__(self, attr, value) 115 | except AttributeError: 116 | if attr == "owner": 117 | return self.setOwner(value) 118 | elif attr == "group": 119 | return self.setGroup(value) 120 | elif attr == "creationEvent": 121 | return self.setCreationEvent(value) 122 | elif attr == "updateEvent": 123 | return self.setUpdateEvent(value) 124 | elif attr == "permissions": 125 | return self.setPermissions(value) 126 | elif attr == "externalInfo": 127 | return self.setExternalInfo(value) 128 | else: 129 | raise 130 | 131 | _omero_model.DetailsI = DetailsI 132 | -------------------------------------------------------------------------------- /src/omero_model_UnitBase.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | Multiple inheritance class that can be re-used by all of 24 | the unit implementations. 25 | """ 26 | 27 | 28 | class UnitBase(object): 29 | 30 | def _base_string(self, v, u): 31 | if v is not None: 32 | return "%s %s" % (v, str(u)) 33 | return "" 34 | -------------------------------------------------------------------------------- /src/omero_version.py: -------------------------------------------------------------------------------- 1 | omero_version = "5.20.1.dev0" 2 | ice_compatibility = "3.6.5" 3 | build_year = "2023" 4 | -------------------------------------------------------------------------------- /src/runProcessor.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # OMERO Processor Runner 5 | # Copyright 2009 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | import sys 10 | import Ice 11 | import omero 12 | 13 | from omero.processor import ProcessorI 14 | 15 | if __name__ == "__main__": 16 | app = omero.util.Server( 17 | ProcessorI, "ProcessorAdapter", Ice.Identity("Processor", "")) 18 | sys.exit(app.main(sys.argv)) 19 | -------------------------------------------------------------------------------- /src/runTables.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | # 4 | # OMERO Tables Runner 5 | # Copyright 2009 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | 9 | if __name__ == "__main__": 10 | 11 | import sys 12 | import Ice 13 | import omero 14 | import omero.clients 15 | import omero.tables 16 | from omero.util import Dependency 17 | 18 | # Logging hack 19 | omero.tables.TablesI.__module__ = "omero.tables" 20 | omero.tables.TableI.__module__ = "omero.tables" 21 | 22 | class TablesDependency(Dependency): 23 | 24 | def __init__(self): 25 | Dependency.__init__(self, "tables") 26 | 27 | def get_version(self, target): 28 | self.target = target 29 | ver = "%s, hdf=%s" % (target.__version__, self.optional("hdf5", 1)) 30 | return ver 31 | 32 | def optional(self, key, idx): 33 | try: 34 | x = self.target.whichLibVersion(key) 35 | if x is not None: 36 | return x[idx] 37 | else: 38 | return "unknown" 39 | except: 40 | return "error" 41 | 42 | app = omero.util.Server( 43 | omero.tables.TablesI, "TablesAdapter", Ice.Identity("Tables", ""), 44 | dependencies=(Dependency("numpy"), TablesDependency())) 45 | 46 | sys.exit(app.main(sys.argv)) 47 | -------------------------------------------------------------------------------- /test/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/test/__init__.py -------------------------------------------------------------------------------- /test/conftest.py: -------------------------------------------------------------------------------- 1 | 2 | # 3 | # --repeat argument for py.test taken from: 4 | # http://stackoverflow.com/questions/21764473/ 5 | # how-can-i-repeat-each-test-multiple-times-in-a-py-test-run 6 | # 7 | 8 | import os 9 | import pytest 10 | 11 | 12 | def pytest_addoption(parser): 13 | parser.addoption( 14 | '--repeat', action='store', 15 | help='Number of times to repeat each test') 16 | 17 | 18 | def pytest_generate_tests(metafunc): 19 | if metafunc.config.option.repeat is not None: 20 | count = int(metafunc.config.option.repeat) 21 | 22 | # We're going to duplicate these tests by parametrizing them, 23 | # which requires that each test has a fixture to accept the parameter. 24 | # We can add a new fixture like so: 25 | metafunc.fixturenames.append('tmp_ct') 26 | 27 | # Now we parametrize. This is what happens when we do e.g., 28 | # @pytest.mark.parametrize('tmp_ct', range(count)) 29 | # def test_foo(): pass 30 | metafunc.parametrize('tmp_ct', list(range(count))) 31 | 32 | # If ICE_CONFIG is not set, then set it to a default file 33 | if "ICE_CONFIG" not in os.environ: 34 | os.environ["ICE_CONFIG"] = "ice.config" 35 | 36 | 37 | class Methods(object): 38 | 39 | @classmethod 40 | def assertAlmostEqual(self, first, second, 41 | places=None, 42 | delta=None): 43 | # Copied largely from unittest 44 | """Fail if the two objects are unequal as determined by their 45 | difference rounded to the given number of decimal places 46 | (default 7) and comparing to zero, or by comparing that the 47 | between the two objects is more than the given delta. 48 | 49 | Note that decimal places (from zero) are usually not the same 50 | as significant digits (measured from the most signficant digit). 51 | 52 | If the two objects compare equal then they will automatically 53 | compare almost equal. 54 | """ 55 | if first == second: 56 | # shortcut 57 | return 58 | if delta is not None and places is not None: 59 | raise TypeError("specify delta or places not both") 60 | 61 | if delta is not None: 62 | if abs(first - second) <= delta: 63 | return 64 | 65 | standardMsg = '%s != %s within %s delta' % (first, 66 | second, 67 | delta) 68 | else: 69 | if places is None: 70 | places = 7 71 | 72 | if round(abs(second-first), places) == 0: 73 | return 74 | 75 | standardMsg = '%s != %s within %r places' % (first, 76 | second, 77 | places) 78 | raise Exception(standardMsg) 79 | 80 | 81 | def pytest_configure(): 82 | """ 83 | Add helper methods to the 'pytest' module 84 | """ 85 | pytest.assertAlmostEqual = Methods.assertAlmostEqual 86 | -------------------------------------------------------------------------------- /test/unit/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/test/unit/__init__.py -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_bad/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | unknown: property 3 | path: unknown 4 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_cols/1.fake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/test/unit/clitest/bulk_import/test_cols/1.fake -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_cols/bulk.tsv: -------------------------------------------------------------------------------- 1 | meta_one 1.fake 2 | meta_two 2.fake 3 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_cols/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | columns: 3 | - name 4 | - path 5 | path: bulk.tsv 6 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_dryrun/1.fake: -------------------------------------------------------------------------------- 1 | sizeZ=0 2 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_dryrun/bulk.tsv: -------------------------------------------------------------------------------- 1 | 1.fake 2 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_dryrun/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: no-op 3 | path: bulk.tsv 4 | dry_run: true 5 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_include/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: test-include- 3 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_include/inner/bulk.tsv: -------------------------------------------------------------------------------- 1 | foo.fake 2 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_include/inner/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | include: ../bulk.yml 3 | path: bulk.tsv 4 | continue: true 5 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_include/inner/foo.fake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/test/unit/clitest/bulk_import/test_include/inner/foo.fake -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_javaargs/1.fake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/test/unit/clitest/bulk_import/test_javaargs/1.fake -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_javaargs/bulk.tsv: -------------------------------------------------------------------------------- 1 | 1.fake 2 | 2.fake 3 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_javaargs/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | checksum_algorithm: "File-Size-64" 3 | parallel_upload: "10" 4 | parallel_fileset: "5" 5 | transfer: "ln_s" 6 | exclude: "clientpath" 7 | no_stats_info: True 8 | no_thumbnails: True 9 | no_upgrade_check: True 10 | path: bulk.tsv 11 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_name/1.fake: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/test/unit/clitest/bulk_import/test_name/1.fake -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_name/bulk.tsv: -------------------------------------------------------------------------------- 1 | 1.fake 2 | 2.fake 3 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_name/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: testname 3 | path: bulk.tsv 4 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_simple/1.fake: -------------------------------------------------------------------------------- 1 | sizeZ=0 2 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_simple/bulk.tsv: -------------------------------------------------------------------------------- 1 | 1.fake 2 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_simple/bulk.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: new-name 3 | logprefix: "%(name)s-log-" 4 | path: bulk.tsv 5 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_skip/1.fake: -------------------------------------------------------------------------------- 1 | sizeZ=0 2 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_skip/all.yml: -------------------------------------------------------------------------------- 1 | --- 2 | skip: "all" 3 | path: bulk.tsv 4 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_skip/bulk.tsv: -------------------------------------------------------------------------------- 1 | 1.fake 2 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_skip/checksum.yml: -------------------------------------------------------------------------------- 1 | --- 2 | skip: "checksum" 3 | path: bulk.tsv 4 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_skip/minmax.yml: -------------------------------------------------------------------------------- 1 | --- 2 | skip: "minmax" 3 | path: bulk.tsv 4 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_skip/thumbnails.yml: -------------------------------------------------------------------------------- 1 | --- 2 | skip: "thumbnails" 3 | path: bulk.tsv 4 | -------------------------------------------------------------------------------- /test/unit/clitest/bulk_import/test_skip/upgrade.yml: -------------------------------------------------------------------------------- 1 | --- 2 | skip: "upgrade" 3 | path: bulk.tsv 4 | -------------------------------------------------------------------------------- /test/unit/clitest/readers/no_fakes.txt: -------------------------------------------------------------------------------- 1 | loci.formats.in.MinimalTiffReader 2 | -------------------------------------------------------------------------------- /test/unit/clitest/readers/only_fakes.txt: -------------------------------------------------------------------------------- 1 | loci.formats.in.FakeReader 2 | -------------------------------------------------------------------------------- /test/unit/clitest/test_admin_noomerodir.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2020 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | import pytest 23 | from omero.cli import CLI, ServiceManagerMixin 24 | from omero.plugins.admin import AdminControl 25 | from omero.plugins.prefs import PrefsControl 26 | 27 | 28 | class MockServiceManagerMixin(CLI, ServiceManagerMixin): 29 | SERVICE_MANAGER_KEY = 'test_servicemanager_mixin' 30 | 31 | class MockCtx: 32 | def __init__(self): 33 | self._die_args = [] 34 | 35 | def die(self, *args): 36 | self._die_args.append(args) 37 | 38 | def __init__(self): 39 | super().__init__() 40 | self.ctx = self.MockCtx() 41 | 42 | 43 | class MockConfigXml(object): 44 | def __init__(self, configmap): 45 | self.configmap = configmap 46 | 47 | def as_map(self): 48 | return self.configmap 49 | 50 | 51 | class TestServiceManagerMixin: 52 | 53 | def test_not_required(self, monkeypatch, tmpdir): 54 | monkeypatch.setenv('OMERODIR', str(tmpdir)) 55 | cli = MockServiceManagerMixin() 56 | cli.requires_service_manager(MockConfigXml({})) 57 | assert not cli.ctx._die_args 58 | 59 | def test_required_notset(self, monkeypatch, tmpdir): 60 | monkeypatch.setenv('OMERODIR', str(tmpdir)) 61 | cli = MockServiceManagerMixin() 62 | cli.requires_service_manager(MockConfigXml({ 63 | 'omero.test_servicemanager_mixin.servicemanager.checkenv': 64 | 'TEST_SERVICEMANAGER_MIXIN'})) 65 | assert cli.ctx._die_args == [( 66 | 112, 67 | "ERROR: OMERO is configured to run under a service manager which " 68 | "should also set TEST_SERVICEMANAGER_MIXIN")] 69 | 70 | def test_required_set(self, monkeypatch, tmpdir): 71 | monkeypatch.setenv('OMERODIR', str(tmpdir)) 72 | monkeypatch.setenv('TEST_SERVICEMANAGER_MIXIN', '123') 73 | cli = MockServiceManagerMixin() 74 | cli.requires_service_manager(MockConfigXml({ 75 | 'omero.test_servicemanager_mixin.servicemanager.checkenv': 76 | 'TEST_SERVICEMANAGER_MIXIN'})) 77 | assert not cli.ctx._die_args 78 | 79 | 80 | class TestAdminCommandsFailFast(object): 81 | # These commands should fail immediately so there's no need for the full 82 | # setup 83 | 84 | @pytest.fixture(autouse=True) 85 | def setup_method(self, tmpdir, monkeypatch): 86 | # Other setup 87 | self.cli = CLI() 88 | monkeypatch.setenv('OMERODIR', str(tmpdir)) 89 | self.cli.dir = tmpdir 90 | self.cli.register("admin", AdminControl, "TEST") 91 | self.cli.register("config", PrefsControl, "TEST") 92 | 93 | @pytest.mark.parametrize("command", ["start", "stop", "restart"]) 94 | def testCheckServiceManagerEnv(self, command, mocker): 95 | mock_err = mocker.patch.object(self.cli, "err") 96 | self.cli.invoke([ 97 | "config", "set", 98 | "omero.server.servicemanager.checkenv", 99 | "TESTOMERO_ADMIN_SERVICEMANAGER_CHECKENV"], 100 | strict=True) 101 | self.cli.invoke(["admin", command, "--force-rewrite"], strict=False) 102 | mock_err.assert_called_with( 103 | "ERROR: OMERO is configured to run under a service manager which " 104 | "should also set TESTOMERO_ADMIN_SERVICEMANAGER_CHECKENV", True) 105 | -------------------------------------------------------------------------------- /test/unit/clitest/test_basics.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | 23 | import pytest 24 | from omero.cli import CLI 25 | 26 | cli = CLI() 27 | cli.loadplugins() 28 | commands = list(cli.controls.keys()) 29 | topics = list(cli.topics.keys()) 30 | 31 | 32 | class TestBasics(object): 33 | 34 | def testHelp(self): 35 | self.args = ["help", "-h"] 36 | cli.invoke(self.args, strict=True) 37 | 38 | @pytest.mark.parametrize('recursive', [None, "--recursive"]) 39 | def testHelpAll(self, recursive): 40 | self.args = ["help", "--all"] 41 | if recursive: 42 | self.args.append(recursive) 43 | cli.invoke(self.args, strict=True) 44 | 45 | @pytest.mark.parametrize('recursive', [None, "--recursive"]) 46 | @pytest.mark.parametrize('command', commands) 47 | def testHelpCommand(self, command, recursive): 48 | self.args = ["help", command] 49 | if recursive: 50 | self.args.append(recursive) 51 | cli.invoke(self.args, strict=True) 52 | 53 | @pytest.mark.parametrize('topic', topics) 54 | def testHelpTopic(self, topic): 55 | self.args = ["help", topic, "-h"] 56 | cli.invoke(self.args, strict=True) 57 | 58 | def testHelpList(self): 59 | self.args = ["help", "list"] 60 | cli.invoke(self.args, strict=True) 61 | 62 | def testQuit(object): 63 | cli.invoke(["quit"], strict=True) 64 | 65 | def testVersion(object): 66 | cli.invoke(["version"], strict=True) 67 | 68 | def testLoadGlob(object, monkeypatch, tmp_path, capsys): 69 | (tmp_path / 'etc').mkdir() 70 | (tmp_path / 'etc' / 'grid').mkdir() 71 | monkeypatch.setenv('OMERODIR', str(tmp_path)) 72 | for i in 'abc': 73 | (tmp_path / (i + 'a.omero')).write_text( 74 | 'config set {i} {i}'.format(i=i)) 75 | cli.invoke(["load", "--glob", str(tmp_path / '*.omero')], strict=True) 76 | cli.invoke(["config", "get"], strict=True) 77 | captured = capsys.readouterr() 78 | lines = captured.out.splitlines() 79 | assert lines == ['a=a', 'b=b', 'c=c'] 80 | 81 | def testErrors(object, monkeypatch, tmp_path, capsys): 82 | cli.invoke(["errors"], strict=True) 83 | captured = capsys.readouterr() 84 | assert "52 hql BAD_QUERY" in captured.out 85 | -------------------------------------------------------------------------------- /test/unit/clitest/test_chgrp.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | from omero.cli import CLI 23 | from omero.plugins.chgrp import ChgrpControl 24 | 25 | 26 | class TestChgrp(object): 27 | 28 | def setup_method(self, method): 29 | self.cli = CLI() 30 | self.cli.register("chgrp", ChgrpControl, "TEST") 31 | self.args = ["chgrp"] 32 | 33 | def testHelp(self): 34 | self.args += ["-h"] 35 | self.cli.invoke(self.args, strict=True) 36 | -------------------------------------------------------------------------------- /test/unit/clitest/test_cli.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Test of the omero cli base class including line parsing. 6 | 7 | Copyright 2009 Glencoe Software, Inc. All rights reserved. 8 | Use is subject to license terms supplied in LICENSE.txt 9 | 10 | """ 11 | 12 | import pytest 13 | 14 | from omero.cli import CLI, NonZeroReturnCode 15 | from omero.plugins.basics import LoadControl 16 | 17 | 18 | class TestCli(object): 19 | 20 | def testMultipleLoad(self): 21 | """ 22 | In DropBox, the loading of multiple CLIs seems to 23 | lead to the wrong context being assigned to some 24 | controls. 25 | 26 | See #4749 27 | """ 28 | import random 29 | from threading import Thread, Event 30 | 31 | event = Event() 32 | 33 | class T(Thread): 34 | def run(self, *args): 35 | pause = random.random() 36 | event.wait(pause) 37 | self.cli = CLI() 38 | self.cli.loadplugins() 39 | self.con = self.cli.controls["admin"] 40 | self.cmp = self.con.ctx 41 | 42 | threads = [T() for x in range(20)] 43 | for t in threads: 44 | t.start() 45 | event.set() 46 | for t in threads: 47 | t.join() 48 | 49 | assert len(threads) == len(set([t.cli for t in threads])) 50 | assert len(threads) == len(set([t.con for t in threads])) 51 | assert len(threads) == len(set([t.cmp for t in threads])) 52 | 53 | def testLoad(self, tmpdir): 54 | tmpfile = tmpdir.join('test') 55 | tmpfile.write("foo") 56 | self.cli = CLI() 57 | self.cli.register("load", LoadControl, "help") 58 | 59 | # replace slashes, otherwise C:\\x becomes C:x 60 | tmpfile = tmpfile.strpath.replace("\\", "/") 61 | with pytest.raises(NonZeroReturnCode): 62 | self.cli.invoke("load %s" % tmpfile, strict=True) 63 | 64 | self.cli.invoke("load -k %s" % tmpfile, strict=True) 65 | self.cli.invoke("load --keep-going %s" % tmpfile, strict=True) 66 | -------------------------------------------------------------------------------- /test/unit/clitest/test_download.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | import pytest 23 | from omero.plugins.download import DownloadControl 24 | from omero.cli import CLI, NonZeroReturnCode 25 | 26 | 27 | class TestDownload(object): 28 | 29 | def setup_method(self, method): 30 | self.cli = CLI() 31 | self.cli.register("download", DownloadControl, "TEST") 32 | self.args = ["download"] 33 | 34 | def testHelp(self): 35 | self.args += ["-h"] 36 | self.cli.invoke(self.args, strict=True) 37 | 38 | @pytest.mark.parametrize( 39 | 'bad_input', 40 | ['-1', 'OriginalFile:-1', 'FileAnnotation:-1', 'Image:-1']) 41 | def testInvalidInput(self, bad_input): 42 | self.args += [bad_input, '-'] 43 | with pytest.raises(NonZeroReturnCode): 44 | self.cli.invoke(self.args, strict=True) 45 | -------------------------------------------------------------------------------- /test/unit/clitest/test_export.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Test of the export plugin 6 | 7 | Copyright 2010 Glencoe Software, Inc. All rights reserved. 8 | Use is subject to license terms supplied in LICENSE.txt 9 | 10 | """ 11 | 12 | import os 13 | from omero_ext.path import path 14 | from omero.cli import CLI, NonZeroReturnCode 15 | from omero.plugins.export import ExportControl 16 | from omero.util.temp_files import create_path 17 | 18 | omeroDir = path(os.getcwd()) / "build" 19 | 20 | 21 | class MockCLI(CLI): 22 | 23 | def conn(self, args): 24 | return MockClient() 25 | 26 | 27 | class MockClient(object): 28 | 29 | def getSession(self, *args): 30 | return MockSession() 31 | 32 | 33 | class MockSession(object): 34 | 35 | def createExporter(self): 36 | return MockExporter() 37 | 38 | 39 | class MockExporter(object): 40 | 41 | def all(self, *args, **kwargs): 42 | pass 43 | 44 | def __getattr__(self, key): 45 | if key == "generateTiff": 46 | return self.generateTiff 47 | return self.all 48 | 49 | def generateTiff(self, *args): 50 | return 1 51 | 52 | 53 | class TestExport(object): 54 | 55 | def setup_method(self, method): 56 | self.cli = MockCLI() 57 | self.cli.register("x", ExportControl, "TEST") 58 | self.p = create_path() 59 | self.p.remove() 60 | 61 | def invoke(self, string): 62 | self.cli.invoke(string, strict=True) 63 | 64 | def testSimpleExport(self): 65 | self.invoke(["x", "-f", self.p, "Image:3"]) 66 | 67 | def testStdOutExport(self): 68 | """ 69 | "-f -" should export to stdout. See ticket:7106 70 | """ 71 | self.invoke("x -f - Image:3") 72 | 73 | def testNoStdOutExportForDatasets(self): 74 | try: 75 | self.invoke("x -f - --iterate Dataset:3") 76 | assert False, "ZeroReturnCode??" 77 | except NonZeroReturnCode: 78 | pass 79 | -------------------------------------------------------------------------------- /test/unit/clitest/test_fs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014-2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | 23 | import pytest 24 | from omero.cli import CLI 25 | from omero.plugins.fs import FsControl 26 | 27 | 28 | class TestTag(object): 29 | 30 | def setup_method(self, method): 31 | self.cli = CLI() 32 | self.cli.register("fs", FsControl, "TEST") 33 | self.args = ["fs"] 34 | 35 | def testHelp(self): 36 | self.args += ["-h"] 37 | self.cli.invoke(self.args, strict=True) 38 | 39 | @pytest.mark.parametrize('subcommand', FsControl().get_subcommands()) 40 | def testSubcommandHelp(self, subcommand): 41 | self.args += [subcommand, "-h"] 42 | self.cli.invoke(self.args, strict=True) 43 | -------------------------------------------------------------------------------- /test/unit/clitest/test_group.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014-2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | import pytest 23 | from omero.plugins.group import GroupControl 24 | from omero.cli import CLI 25 | 26 | 27 | class TestGroup(object): 28 | 29 | def setup_method(self, method): 30 | self.cli = CLI() 31 | self.cli.register("group", GroupControl, "TEST") 32 | self.args = ["group"] 33 | 34 | def testHelp(self): 35 | self.args += ["-h"] 36 | self.cli.invoke(self.args, strict=True) 37 | 38 | @pytest.mark.parametrize("subcommand", GroupControl().get_subcommands()) 39 | def testSubcommandHelp(self, subcommand): 40 | self.args += [subcommand, "-h"] 41 | self.cli.invoke(self.args, strict=True) 42 | -------------------------------------------------------------------------------- /test/unit/clitest/test_hql.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | 23 | import pytest 24 | from omero.cli import CLI 25 | from omero.plugins.hql import HqlControl, BLACKLISTED_KEYS, WHITELISTED_VALUES 26 | 27 | 28 | class TestHql(object): 29 | 30 | def setup_method(self, method): 31 | self.cli = CLI() 32 | self.cli.register("hql", HqlControl, "TEST") 33 | self.args = ["hql"] 34 | 35 | def testHelp(self): 36 | self.args += ["-h"] 37 | self.cli.invoke(self.args, strict=True) 38 | 39 | @pytest.mark.parametrize("key", BLACKLISTED_KEYS) 40 | def testFilterBlacklist(self, key): 41 | output = self.cli.controls["hql"].filter({key: 1}) 42 | assert output == {} 43 | 44 | @pytest.mark.parametrize("key", ["rois", "groupExperimenterMap"]) 45 | def testFilterLoaded(self, key): 46 | output = self.cli.controls["hql"].filter({"_" + key + "Loaded": 1}) 47 | assert output == {} 48 | 49 | @pytest.mark.parametrize( 50 | ("value", "outcome"), 51 | [("owner=None;group=None", {}), 52 | ("owner=1", {"details": "owner=1"})]) 53 | def testFilterDetails(self, value, outcome): 54 | output = self.cli.controls["hql"].filter({"_details": value}) 55 | assert output == outcome 56 | 57 | @pytest.mark.parametrize("multi_value", [[0, 1]]) 58 | def testFilterMultiValue(self, multi_value): 59 | output = self.cli.controls["hql"].filter({'key': multi_value}) 60 | assert output == {} 61 | 62 | @pytest.mark.parametrize("empty_value", [None, [], {}]) 63 | def testFilterEmptyValue(self, empty_value): 64 | output = self.cli.controls["hql"].filter({'key': empty_value}) 65 | assert output == {} 66 | 67 | @pytest.mark.parametrize("value", WHITELISTED_VALUES) 68 | def testFilterWhitelist(self, value): 69 | output = self.cli.controls["hql"].filter({'key': value}) 70 | assert output == {'key': value} 71 | 72 | def testFilterStrip(self): 73 | output = self.cli.controls["hql"].filter({'_key': 1}) 74 | assert output == {'key': 1} 75 | -------------------------------------------------------------------------------- /test/unit/clitest/test_ldap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | from omero.cli import CLI 23 | from omero.plugins.ldap import LdapControl 24 | import pytest 25 | 26 | 27 | class TestLdap(object): 28 | 29 | def setup_method(self, method): 30 | self.cli = CLI() 31 | self.cli.register("ldap", LdapControl, "TEST") 32 | self.args = ["ldap"] 33 | 34 | def testHelp(self): 35 | self.args += ["-h"] 36 | self.cli.invoke(self.args, strict=True) 37 | 38 | @pytest.mark.parametrize('subcommand', LdapControl().get_subcommands()) 39 | def testSubcommandHelp(self, subcommand): 40 | self.args += [subcommand, "-h"] 41 | self.cli.invoke(self.args, strict=True) 42 | -------------------------------------------------------------------------------- /test/unit/clitest/test_obj.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2013 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | Test of the omero/plugins/tx.py module 24 | """ 25 | 26 | import pytest 27 | from omero.cli import CLI 28 | from omero.model import ProjectI 29 | from omero.plugins.obj import NewObjectTxAction 30 | from omero.plugins.obj import TxCmd 31 | from omero.plugins.obj import ObjControl 32 | from omero.plugins.obj import TxState 33 | 34 | 35 | class MockCLI(CLI): 36 | 37 | def conn(self, *args, **kwargs): 38 | return self.get_client() 39 | 40 | def close(self, *args, **kwargs): 41 | pass 42 | 43 | def out(self, out): 44 | if hasattr(self, "_out"): 45 | self._out.append(out) 46 | else: 47 | self._out = [out] 48 | 49 | 50 | class TxBase(object): 51 | 52 | def init(self, mocker): 53 | self.client = mocker.patch('omero.clients.BaseClient', autospec=True) 54 | self.sf = mocker.patch('omero.api.ServiceFactoryPrx', autospec=True) 55 | self.query = mocker.patch('omero.api.IQueryPrx', autospec=True) 56 | self.update = mocker.patch('omero.api.IUpdatePrx', autospec=True) 57 | self.client.sf = self.sf 58 | self.cli = MockCLI() 59 | self.cli.set_client(self.client) 60 | self.cli.set("tx.state", TxState(self.cli)) 61 | self.cli.register("obj", ObjControl, "TEST") 62 | self.args = ["obj"] 63 | 64 | def queries(self, obj): 65 | self.sf.getQueryService.return_value = self.query 66 | self.query.get.return_value = obj 67 | 68 | def saves(self, obj): 69 | self.sf.getUpdateService.return_value = self.update 70 | self.update.saveAndReturnObject.return_value = obj 71 | 72 | 73 | class TestNewObjectTxAction(TxBase): 74 | 75 | def test_unknown_class(self, mocker): 76 | self.init(mocker) 77 | self.saves(ProjectI(1, False)) 78 | state = TxState(self.cli) 79 | cmd = TxCmd(state, arg_list=["new", "Project", "name=foo"]) 80 | action = NewObjectTxAction(state, cmd) 81 | action.go(self.cli, None) 82 | 83 | 84 | class TestObjControl(TxBase): 85 | 86 | def test_simple_new_usage(self, mocker): 87 | self.init(mocker) 88 | self.saves(ProjectI(1, False)) 89 | self.cli.invoke("obj new Project name=foo", strict=True) 90 | assert self.cli._out == ["Project:1"] 91 | 92 | def test_simple_update_usage(self, mocker): 93 | self.init(mocker) 94 | self.queries(ProjectI(1, True)) 95 | self.saves(ProjectI(1, False)) 96 | self.cli.invoke(("obj update Project:1 name=bar " 97 | "description=loooong"), strict=True) 98 | assert self.cli._out == ["Project:1"] 99 | 100 | def testHelp(self, mocker): 101 | self.init(mocker) 102 | self.args += ["-h"] 103 | self.cli.invoke(self.args, strict=True) 104 | 105 | @pytest.mark.parametrize('subcommand', ("new", "update", "null", 106 | "map-get", "map-set", 107 | "get", "list-get")) 108 | def testSubcommandHelp(self, subcommand, mocker): 109 | self.init(mocker) 110 | self.args += [subcommand, "-h"] 111 | self.cli.invoke(self.args, strict=True) 112 | -------------------------------------------------------------------------------- /test/unit/clitest/test_rcode.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Test of the return code functionality 6 | 7 | Copyright 2008 Glencoe Software, Inc. All rights reserved. 8 | Use is subject to license terms supplied in LICENSE.txt 9 | 10 | """ 11 | 12 | import os 13 | from omero_ext.path import path 14 | from omero.cli import BaseControl, CLI 15 | 16 | omeroDir = path(os.getcwd()) / "build" 17 | 18 | 19 | class TestRCode(object): 20 | 21 | class T(BaseControl): 22 | def __call__(self, *args): 23 | self.ctx.rv = 1 24 | 25 | def testOne(self): 26 | cli = CLI() 27 | cli.register("t", TestRCode.T, "TEST") 28 | cli.invoke(["t"]) 29 | assert cli.rv == 1, cli.rv 30 | -------------------------------------------------------------------------------- /test/unit/clitest/test_script.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014-2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | from omero.plugins.script import ScriptControl 23 | from omero.cli import CLI 24 | import pytest 25 | 26 | 27 | class TestScript(object): 28 | 29 | def setup_method(self, method): 30 | self.cli = CLI() 31 | self.cli.register("script", ScriptControl, "TEST") 32 | self.args = ["script"] 33 | 34 | # Help subcommands 35 | # ======================================================================== 36 | def testHelp(self): 37 | self.args += ["-h"] 38 | self.cli.invoke(self.args, strict=True) 39 | 40 | @pytest.mark.parametrize("subcommand", ScriptControl().get_subcommands()) 41 | def testSubcommandHelp(self, subcommand): 42 | self.args += [subcommand, "-h"] 43 | self.cli.invoke(self.args, strict=True) 44 | -------------------------------------------------------------------------------- /test/unit/clitest/test_sessions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014-2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | from omero.cli import CLI 23 | from omero.plugins.sessions import SessionsControl 24 | 25 | import os 26 | import pytest 27 | 28 | 29 | class TestSessions(object): 30 | 31 | def setup_method(self, method): 32 | self.cli = CLI() 33 | self.cli.register("sessions", SessionsControl, "TEST") 34 | self.args = ["sessions"] 35 | 36 | def testHelp(self): 37 | self.args += ["-h"] 38 | self.cli.invoke(self.args, strict=True) 39 | 40 | @pytest.mark.parametrize( 41 | "subcommand", SessionsControl().get_subcommands()) 42 | def testSubcommandHelp(self, subcommand): 43 | self.args += [subcommand, "-h"] 44 | self.cli.invoke(self.args, strict=True) 45 | 46 | def testDefaultSessionsDir(self): 47 | from omero.util import get_user_dir 48 | from omero_ext.path import path 49 | 50 | # Default store sessions dir is under user dir 51 | store = self.cli.controls['sessions'].store(None) 52 | assert store.dir == path(get_user_dir()) / 'omero' / 'sessions' 53 | 54 | @pytest.mark.parametrize('environment', ( 55 | {'OMERO_USERDIR': None, 56 | 'OMERO_SESSION_DIR': None, 57 | 'OMERO_SESSIONDIR': None}, 58 | {'OMERO_USERDIR': None, 59 | 'OMERO_SESSION_DIR': 'session_dir', 60 | 'OMERO_SESSIONDIR': None}, 61 | {'OMERO_USERDIR': None, 62 | 'OMERO_SESSION_DIR': None, 63 | 'OMERO_SESSIONDIR': 'sessiondir'}, 64 | {'OMERO_USERDIR': 'userdir', 65 | 'OMERO_SESSION_DIR': None, 66 | 'OMERO_SESSIONDIR': None}, 67 | {'OMERO_USERDIR': None, 68 | 'OMERO_SESSION_DIR': 'session_dir', 69 | 'OMERO_SESSIONDIR': 'sessiondir'}, 70 | {'OMERO_USERDIR': 'userdir', 71 | 'OMERO_SESSION_DIR': 'session_dir', 72 | 'OMERO_SESSIONDIR': None}, 73 | {'OMERO_USERDIR': 'userdir', 74 | 'OMERO_SESSION_DIR': None, 75 | 'OMERO_SESSIONDIR': 'sessiondir'}, 76 | {'OMERO_USERDIR': 'userdir', 77 | 'OMERO_SESSION_DIR': 'session_dir', 78 | 'OMERO_SESSIONDIR': 'sessiondir'})) 79 | @pytest.mark.parametrize('session_args', [None, 'session_dir']) 80 | def testCustomSessionsDir( 81 | self, tmpdir, monkeypatch, environment, 82 | session_args): 83 | from argparse import Namespace 84 | from omero.util import get_user_dir 85 | from omero_ext.path import path 86 | 87 | for var in list(environment.keys()): 88 | if environment[var]: 89 | monkeypatch.setenv(var, "%s%s%s" % (tmpdir, os.path.sep, environment.get(var))) 90 | else: 91 | monkeypatch.delenv(var, raising=False) 92 | 93 | # args.session_dir sets the sessions dir 94 | args = Namespace() 95 | if session_args: 96 | setattr(args, session_args, tmpdir / session_args) 97 | 98 | if environment.get('OMERO_SESSION_DIR') or session_args: 99 | store = pytest.deprecated_call(self.cli.controls['sessions'].store, args) 100 | else: 101 | store = self.cli.controls['sessions'].store(args) 102 | 103 | # By order of precedence 104 | if environment.get('OMERO_SESSIONDIR'): 105 | sdir = path(tmpdir) / environment.get('OMERO_SESSIONDIR') 106 | elif environment.get('OMERO_SESSION_DIR'): 107 | sdir = (path(tmpdir) / environment.get('OMERO_SESSION_DIR') / 108 | 'omero' / 'sessions') 109 | elif session_args: 110 | sdir = path(getattr(args, session_args)) / 'omero' / 'sessions' 111 | elif environment.get('OMERO_USERDIR'): 112 | sdir = path(tmpdir) / environment.get('OMERO_USERDIR') / 'sessions' 113 | else: 114 | sdir = path(get_user_dir()) / 'omero' / 'sessions' 115 | assert store.dir == str(sdir) 116 | -------------------------------------------------------------------------------- /test/unit/clitest/test_tag.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2013-2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | import pytest 23 | from omero.cli import CLI, NonZeroReturnCode 24 | from omero.plugins.tag import TagControl 25 | 26 | 27 | class TestTag(object): 28 | 29 | def setup_method(self, method): 30 | self.cli = CLI() 31 | self.cli.register("tag", TagControl, "TEST") 32 | self.args = ["tag"] 33 | 34 | def testHelp(self): 35 | self.args += ["-h"] 36 | self.cli.invoke(self.args, strict=True) 37 | 38 | @pytest.mark.parametrize('subcommand', TagControl().get_subcommands()) 39 | def testSubcommandHelp(self, subcommand): 40 | self.args += [subcommand, "-h"] 41 | self.cli.invoke(self.args, strict=True) 42 | 43 | def testCreateTagsetFails(self): 44 | self.args += ["createset", "--tag", "A"] 45 | with pytest.raises(NonZeroReturnCode): 46 | self.cli.invoke(self.args, strict=True) 47 | 48 | def testListFails(self): 49 | self.args += ["list", "--tagset", "tagset"] 50 | with pytest.raises(NonZeroReturnCode): 51 | self.cli.invoke(self.args, strict=True) 52 | 53 | def testListsetsFails(self): 54 | self.args += ["listsets", "--tag", "tag"] 55 | with pytest.raises(NonZeroReturnCode): 56 | self.cli.invoke(self.args, strict=True) 57 | 58 | @pytest.mark.parametrize( 59 | ('object_arg', 'tag_arg'), 60 | [('Image:1', 'test'), ('Image', '1'), ('Image:image', '1'), 61 | ('1', '1')]) 62 | def testLinkFails(self, object_arg, tag_arg): 63 | self.args += ["link", object_arg, tag_arg] 64 | with pytest.raises(NonZeroReturnCode): 65 | self.cli.invoke(self.args, strict=True) 66 | -------------------------------------------------------------------------------- /test/unit/clitest/test_user.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2014-2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | from omero.plugins.user import UserControl 23 | from omero.cli import CLI 24 | import pytest 25 | 26 | 27 | class TestUser(object): 28 | 29 | def setup_method(self, method): 30 | self.cli = CLI() 31 | self.cli.register("user", UserControl, "TEST") 32 | self.args = ["user"] 33 | 34 | # Help subcommands 35 | # ======================================================================== 36 | def testHelp(self): 37 | self.args += ["-h"] 38 | self.cli.invoke(self.args, strict=True) 39 | 40 | @pytest.mark.parametrize("subcommand", UserControl().get_subcommands()) 41 | def testSubcommandHelp(self, subcommand): 42 | self.args += [subcommand, "-h"] 43 | self.cli.invoke(self.args, strict=True) 44 | -------------------------------------------------------------------------------- /test/unit/fstest/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ome/omero-py/d2f8480125bf0bda4e5663204366261a398266d2/test/unit/fstest/__init__.py -------------------------------------------------------------------------------- /test/unit/fstest/test_model.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2012 Glencoe Software, Inc. All Rights Reserved. 6 | # Use is subject to license terms supplied in LICENSE.txt 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | Basic usage of the "fileset" model objects. 24 | These tests don't do anything functional, but 25 | just show creation / linkage scenarios. 26 | """ 27 | 28 | import time 29 | import omero 30 | import omero.all 31 | 32 | from omero.rtypes import rstring 33 | from omero.rtypes import rtime 34 | 35 | 36 | class TestModel(object): 37 | 38 | def mkentry(self, clientPath): 39 | originalFile = omero.model.OriginalFileI() 40 | parts = clientPath.split("/") 41 | path = "/".join(parts[:-1]) 42 | name = parts[-1] 43 | originalFile.path = rstring(path) 44 | originalFile.name = rstring(name) 45 | # etc. 46 | entry = omero.model.FilesetEntryI() 47 | entry.clientPath = rstring(clientPath) 48 | entry.originalFile = originalFile 49 | return entry 50 | 51 | def testBasicImport(self): 52 | """ 53 | basic server-side import steps 54 | 55 | Once a list of file paths have been passed to the server, 56 | an omero.model.Fileset object will be created which captures 57 | the state of the import. 58 | """ 59 | 60 | # This will be created server-side 61 | serverInfo = {} 62 | serverInfo['bioformatsReader'] = rstring("ExampleReader") 63 | serverInfo['bioformatsVersion'] = rstring("v4.4.5 git: abc123"), 64 | serverInfo['omeroVersion'] = rstring("v.4.4.4 git: def456"), 65 | serverInfo['osName'] = rstring("Linux"), 66 | serverInfo['osArchitecture'] = rstring("amd64"), 67 | serverInfo['osVersion'] = rstring("2.6.38-8-generic"), 68 | serverInfo['locale'] = rstring("en_US") 69 | 70 | # Now that the basics are setup, we 71 | # need to link to all of the original files. 72 | fs = omero.model.FilesetI() 73 | fs.addFilesetEntry(self.mkentry("main_file.txt")) # First! 74 | fs.addFilesetEntry(self.mkentry("uf1.data")) 75 | fs.addFilesetEntry(self.mkentry("uf2.data")) 76 | 77 | # Now that the files are all added, we 78 | # add the "activities" that will be 79 | # performed on them. 80 | 81 | # Uploading is almost always the first 82 | # step, and must be completed by the clients 83 | # before any other activity. 84 | job1 = omero.model.UploadJobI() 85 | job1.scheduledFor = rtime(time.time() * 1000) # Now 86 | # Set this "started" since we're expecting 87 | # upload to be in process. 88 | 89 | # Import is a server-side activity which 90 | # causes the files to be parsed and their 91 | # metadata to be stored. 92 | job2 = omero.model.MetadataImportJobI() 93 | 94 | # Other possible activities include "pyramids" 95 | # and "re-import" 96 | 97 | fs.linkJob(job1) 98 | fs.linkJob(job2) 99 | -------------------------------------------------------------------------------- /test/unit/gatewaytest/test_argument_errors.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | gateway tests - argument errors in gateway methods 24 | 25 | """ 26 | 27 | from omero.gateway import _BlitzGateway 28 | import pytest 29 | 30 | 31 | class TestArgumentErrors(object): 32 | 33 | @classmethod 34 | @pytest.fixture(autouse=True) 35 | def setup_class(cls, tmpdir, monkeypatch): 36 | ice_config = tmpdir / "ice.config" 37 | ice_config.write("omero.host=localhost\nomero.port=4064") 38 | monkeypatch.setenv("ICE_CONFIG", "%s" % ice_config) 39 | cls.g = _BlitzGateway() 40 | 41 | def test_graphspec_with_plus(self): 42 | """ 43 | The graph_spec Name+Qualifier is no longer supported. 44 | """ 45 | with pytest.raises(AttributeError): 46 | self.g.deleteObjects("Image+Only", ["1"]) 47 | with pytest.raises(AttributeError): 48 | self.g.chgrpObjects("Image+Only", ["1"], 1) 49 | 50 | @pytest.mark.parametrize("object_ids", ["1", [], None]) 51 | def test_bad_object_ids(self, object_ids): 52 | """ 53 | object_ids must be a non-zero length list 54 | """ 55 | with pytest.raises(AttributeError): 56 | self.g.deleteObjects("Image", object_ids) 57 | with pytest.raises(AttributeError): 58 | self.g.chgrpObjects("Image", object_ids, 1) 59 | -------------------------------------------------------------------------------- /test/unit/gatewaytest/test_build_query.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2016 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """Gateway tests - buildQuery() as used by conn.getObjects().""" 23 | 24 | from omero.gateway import _BlitzGateway, BlitzObjectWrapper, KNOWN_WRAPPERS 25 | from omero.sys import Parameters, ParametersI, Filter 26 | import pytest 27 | from omero.rtypes import wrap 28 | 29 | 30 | @pytest.fixture(scope='function') 31 | def gateway(): 32 | """Create a BlitzGateway object.""" 33 | return _BlitzGateway() 34 | 35 | 36 | class TestBuildQuery(object): 37 | """Test the conn.buildQuery() method for all Object Wrappers.""" 38 | 39 | @pytest.mark.parametrize("dtype", list(KNOWN_WRAPPERS.keys())) 40 | def test_no_clauses(self, gateway, dtype): 41 | """Expect a query with no 'where' clauses.""" 42 | result = gateway.buildQuery(dtype) 43 | query, params, wrapper = result 44 | assert isinstance(query, str) 45 | assert isinstance(params, Parameters) 46 | assert isinstance(wrapper(), BlitzObjectWrapper) 47 | assert query.startswith("select ") 48 | assert "where" not in query 49 | assert 'None' not in query 50 | 51 | @pytest.mark.parametrize("dtype", list(KNOWN_WRAPPERS.keys())) 52 | def test_filter_by_owner(self, gateway, dtype): 53 | """Query should filter by owner.""" 54 | p = ParametersI() 55 | p.theFilter = Filter() 56 | p.theFilter.ownerId = wrap(2) 57 | # Test using 'params' argument 58 | with_params = gateway.buildQuery(dtype, params=p) 59 | # Test using 'opts' dictionary 60 | with_opts = gateway.buildQuery(dtype, opts={'owner': 1}) 61 | for result in [with_params, with_opts]: 62 | query, params, wrapper = result 63 | assert isinstance(query, str) 64 | assert isinstance(params, Parameters) 65 | assert isinstance(wrapper(), BlitzObjectWrapper) 66 | if dtype not in ('experimenter', 'experimentergroup'): 67 | assert "where owner" in query 68 | else: 69 | assert "where owner" not in query 70 | 71 | @pytest.mark.parametrize("dtype", list(KNOWN_WRAPPERS.keys())) 72 | def test_pagination(self, gateway, dtype): 73 | """Query should paginate.""" 74 | offset = 1 75 | limit = 100 76 | p = ParametersI() 77 | p.page(offset, limit) 78 | # Test using 'params' argument 79 | with_params = gateway.buildQuery(dtype, params=p) 80 | # Test using 'opts' dictionary 81 | opts = {'offset': offset, 'limit': limit} 82 | with_opts = gateway.buildQuery(dtype, opts=opts) 83 | for result in [with_params, with_opts]: 84 | query, params, wrapper = result 85 | assert isinstance(query, str) 86 | assert isinstance(params, Parameters) 87 | assert isinstance(wrapper(), BlitzObjectWrapper) 88 | assert params.theFilter.offset.val == offset 89 | assert params.theFilter.limit.val == limit 90 | -------------------------------------------------------------------------------- /test/unit/scriptstest/test_prototypes.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Test of the omero.scripts comparison functionality 6 | 7 | Copyright 2010-2014 Glencoe Software, Inc. All rights reserved. 8 | Use is subject to license terms supplied in LICENSE.txt 9 | 10 | """ 11 | 12 | import omero 13 | from omero.scripts import Long, List, validate_inputs 14 | from omero.rtypes import rmap, rint, rlong, rstring, rlist, rset, unwrap 15 | 16 | 17 | class TestPrototypes(object): 18 | 19 | def testRSetRInt(self): 20 | params = omero.grid.JobParams() 21 | param = omero.grid.Param() 22 | param.prototype = rset(rint(0)) 23 | params.inputs = {"a": param} 24 | 25 | input = rset(rint(1)) 26 | inputs = {"a": input} 27 | assert "" == validate_inputs(params, inputs) 28 | 29 | # Nested lists 30 | def testRListRInt(self): 31 | params = omero.grid.JobParams() 32 | param = omero.grid.Param() 33 | param.prototype = rlist(rint(0)) 34 | params.inputs = {"a": param} 35 | 36 | input = rlist(rint(1)) 37 | inputs = {"a": input} 38 | assert "" == validate_inputs(params, inputs) 39 | 40 | def testRListRList(self): 41 | params = omero.grid.JobParams() 42 | param = omero.grid.Param() 43 | param.prototype = rlist(rlist()) 44 | params.inputs = {"a": param} 45 | 46 | input = rlist(rlist(rint(1), rstring("a"))) 47 | inputs = {"a": input} 48 | assert "" == validate_inputs(params, inputs) 49 | 50 | def testRListRListRString(self): 51 | params = omero.grid.JobParams() 52 | param = omero.grid.Param() 53 | param.prototype = rlist(rlist(rstring(""))) 54 | params.inputs = {"a": param} 55 | 56 | input = rlist(rlist(rstring("a"))) 57 | inputs = {"a": input} 58 | assert "" == validate_inputs(params, inputs) 59 | 60 | input.val[0].val.insert(0, rint(1)) 61 | assert not "" == validate_inputs(params, inputs) 62 | 63 | # Nested maps 64 | def testRMapRInt(self): 65 | params = omero.grid.JobParams() 66 | param = omero.grid.Param() 67 | param.prototype = rmap({"b": rint(0)}) 68 | params.inputs = {"a": param} 69 | 70 | input = rmap({"b": rint(1)}) 71 | inputs = {"a": input} 72 | assert "" == validate_inputs(params, inputs) 73 | 74 | def testRMapRMap(self): 75 | params = omero.grid.JobParams() 76 | param = omero.grid.Param() 77 | param.prototype = rmap({"b": rmap({})}) 78 | params.inputs = {"a": param} 79 | 80 | input = rmap({"b": rmap({"l": rlong(0)})}) 81 | inputs = {"a": input} 82 | assert "" == validate_inputs(params, inputs) 83 | 84 | def testRMapRMapRInt(self): 85 | params = omero.grid.JobParams() 86 | param = omero.grid.Param() 87 | param.prototype = rmap({"b": rmap({"c": rint(0)})}) 88 | params.inputs = {"a": param} 89 | 90 | input = rmap({"b": rmap({"c": rint(1)})}) 91 | inputs = {"a": input} 92 | assert "" == validate_inputs(params, inputs) 93 | 94 | # Other 95 | def testAllParametersChecked(self): 96 | params = omero.grid.JobParams() 97 | param = omero.grid.Param() 98 | param.prototype = rlist(rstring("")) 99 | params.inputs = {"a": param} 100 | 101 | input = rlist(rstring("foo"), rint(1)) 102 | inputs = {"a": input} 103 | assert not "" == validate_inputs(params, inputs) 104 | 105 | # Bugs 106 | def testTicket2323Min(self): 107 | params = omero.grid.JobParams() 108 | # Copied from integration/scripts.py:testUploadOfficialScripts 109 | param = Long('longParam', True, description='theDesc', min=int(1), 110 | max=int(10), values=[rlong(5)]) 111 | assert 1 == param.min.getValue(), \ 112 | "Min value not correct:" + str(param.min) 113 | assert 10 == param.max.getValue(), \ 114 | "Max value not correct:" + str(param.max) 115 | assert 5 == param.values.getValue()[0].getValue(), \ 116 | "First option value not correct:" + str(param.values) 117 | 118 | params.inputs = {"a": param} 119 | inputs = {"a": rlong(5)} 120 | errors = validate_inputs(params, inputs) 121 | assert "" == errors, errors 122 | 123 | def testTicket2323List(self): 124 | param = List('listParam', True, description='theDesc', 125 | values=[rlong(5)]) 126 | assert [5] == unwrap(param.values), str(param.values) 127 | -------------------------------------------------------------------------------- /test/unit/tablestest/library.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Test of the HDF storage for the Tables API. 6 | 7 | Copyright 2009-2014 Glencoe Software, Inc. All rights reserved. 8 | Use is subject to license terms supplied in LICENSE.txt 9 | 10 | """ 11 | 12 | 13 | from omero.util.temp_files import create_path 14 | 15 | 16 | class TestCase(object): 17 | 18 | def setup_method(self, method): 19 | self.dir = self.tmpdir() 20 | 21 | def tmpdir(self): 22 | """ 23 | """ 24 | return create_path(folder=True) 25 | -------------------------------------------------------------------------------- /test/unit/test_conversions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | Simple tests of the new conversions used for units. 24 | """ 25 | 26 | from pytest import assertAlmostEqual 27 | from omero.conversions import Add 28 | from omero.conversions import Int 29 | from omero.conversions import Mul 30 | from omero.conversions import Pow 31 | from omero.conversions import Rat 32 | from omero.conversions import Sym 33 | 34 | 35 | class TestConversions(object): 36 | 37 | def assertEquals(self, a, b, places=6): 38 | assertAlmostEqual(a, b, places=places) 39 | 40 | def testSimpleAdd(self): 41 | add = Add(Rat(1, 2), Rat(1, 2)) 42 | assert "(1 + 2)", str(add) 43 | whole = add(-1) # -1 is ignored 44 | self.assertEquals(1.0, whole) 45 | 46 | def testSimpleMul(self): 47 | mul = Mul(Int(1000000), Sym("megas")) 48 | assert "(1000000 * x)" == str(mul) 49 | seconds = mul(5.0) 50 | self.assertEquals(5000000.0, seconds) 51 | 52 | def testSimpleInt(self): 53 | i = Int(123) 54 | assert "123" == str(i) 55 | x = i(-1) # -1 is ignored 56 | self.assertEquals(123.0, x) 57 | 58 | def testBigInt(self): 59 | big = "123456789012345678901234567890" 60 | big = big * 5 61 | i = Mul(Int(big), Int(big)) 62 | x = i(-1) # -1 is ignored 63 | target = float(big) * float(big) 64 | self.assertEquals(target, x) 65 | 66 | def testSimplePow(self): 67 | p = Pow(3, 2) 68 | assert "(3 ** 2)" == str(p) 69 | x = p(-1) # -1 is ignored 70 | self.assertEquals(9.0, x) 71 | 72 | def testSimpleRat(self): 73 | r = Rat(1, 3) 74 | assert "(1 / 3)" == str(r) 75 | x = r(-1) # -1 is ignored 76 | self.assertEquals(0.333333, x) 77 | 78 | def testDelayedRat(self): 79 | r = Rat(Int(1), Int(3)) 80 | x = r(-1) # -1 is ignored 81 | self.assertEquals(0.333333, x) 82 | 83 | def testSimpleSym(self): 84 | s = Sym("s") 85 | assert "x" == str(s) 86 | x = s(5.0) 87 | self.assertEquals(5.0, x) 88 | 89 | def testFahrenheitCelsius(self): 90 | ftoc = Add(Mul(Rat(5, 9), Sym("f")), Rat(-160, 9)) 91 | assert "(((5 / 9) * x) + (-160 / 9))" == str(ftoc) 92 | self.assertEquals(0.0, ftoc(32.0)) 93 | self.assertEquals(100.0, ftoc(212.0)) 94 | self.assertEquals(-40.0, ftoc(-40.0)) 95 | -------------------------------------------------------------------------------- /test/unit/test_path.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Test custom modifications to path.py. 6 | 7 | Copyright 2014 CRS4. All rights reserved. 8 | Use is subject to license terms supplied in LICENSE.txt. 9 | """ 10 | 11 | import omero_ext.path as path 12 | 13 | 14 | class TestPath(object): 15 | 16 | def test_parpath(self): 17 | root = path.path('/') 18 | a1, a2 = [root / _ for _ in ('a1', 'a2')] 19 | b = a1 / 'b' 20 | for x, y in (root, a1), (root, a2), (a1, b): 21 | assert len(y.parpath(x)) == 1 22 | assert len(x.parpath(y)) == 0 23 | assert len(a1.parpath(a2)) == 0 24 | assert len(a2.parpath(a1)) == 0 25 | assert len(b.parpath(root)) == 2 26 | assert len(root.parpath(b)) == 0 27 | -------------------------------------------------------------------------------- /test/unit/test_python_only.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """ 5 | Test of the differences in the OmeroPy mapping. 6 | 7 | Copyright 2008-2014 Glencoe Software, Inc. All rights reserved. 8 | Use is subject to license terms supplied in LICENSE.txt 9 | 10 | """ 11 | 12 | import pytest 13 | import omero 14 | import Ice 15 | 16 | from omero.clients import BaseClient 17 | 18 | 19 | class test_client(BaseClient): 20 | def __init__(self): 21 | pass 22 | 23 | def __del__(self): 24 | pass 25 | 26 | 27 | class TestPythonOnly(object): 28 | 29 | def testRepairArguments(self): 30 | t = test_client() 31 | ar = ["a", "b"] 32 | id = Ice.InitializationData() 33 | pm = {'A': 1} 34 | ho = "host" 35 | po = 4064 36 | no = None 37 | assert [no == no, no, no, no], t._repair(no, no, no, no, no) 38 | assert [ar == no, no, no, no], t._repair(ar, no, no, no, no) 39 | assert [no == id, no, no, no], t._repair(id, no, no, no, no) 40 | assert [no == no, ho, no, no], t._repair(ho, no, no, no, no) 41 | assert [no == no, ho, po, no], t._repair(ho, po, no, no, no) 42 | assert [no == no, no, no, pm], t._repair(pm, no, no, no, no) 43 | # All mixed up 44 | assert [ar == id, ho, po, pm], t._repair(id, pm, po, ho, ar) 45 | # Duplicates 46 | pytest.raises(omero.ClientError, t._repair, id, id, no, no, no) 47 | pytest.raises(omero.ClientError, t._repair, ho, ho, no, no, no) 48 | -------------------------------------------------------------------------------- /test/unit/test_rois.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # 5 | # Copyright (C) 2015 University of Dundee & Open Microscopy Environment. 6 | # All rights reserved. 7 | # 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2 of the License, or 11 | # (at your option) any later version. 12 | # 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU General Public License along 19 | # with this program; if not, write to the Free Software Foundation, Inc., 20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 21 | 22 | """ 23 | Simple tests of various ROI utilities 24 | """ 25 | 26 | from omero.util.ROI_utils import pointsStringToXYlist, xyListToBbox 27 | from omero.util.roi_handling_utils import points_string_to_xy_list 28 | 29 | 30 | class TestRoiUtils(object): 31 | 32 | def test_old_format(self): 33 | xy_list = pointsStringToXYlist(( 34 | "points[1,2, 3,4, 5,6] " 35 | )) 36 | assert xy_list == [(1, 2), (3, 4), (5, 6)] 37 | 38 | def test_new_format(self): 39 | xy_list = pointsStringToXYlist(( 40 | "1,2 3,4 5,6" 41 | )) 42 | assert xy_list == [(1, 2), (3, 4), (5, 6)] 43 | 44 | def test_bbox(self): 45 | xy_list = points_string_to_xy_list(( 46 | "points[1,2, 3,4, 5,6] " 47 | )) 48 | bbox = xyListToBbox(xy_list) 49 | assert bbox == (1, 2, 4, 4) 50 | 51 | def test_old_format_new_method(self): 52 | xy_list = points_string_to_xy_list(( 53 | "points[1,2, 3,4, 5,6] " 54 | )) 55 | assert xy_list == [(1, 2), (3, 4), (5, 6)] 56 | 57 | def test_new_format_new_method(self): 58 | xy_list = points_string_to_xy_list(( 59 | "1,2 3,4 5,6" 60 | )) 61 | assert xy_list == [(1, 2), (3, 4), (5, 6)] 62 | -------------------------------------------------------------------------------- /test/unit/test_tempfiles.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | """ 4 | /* 5 | * $Id$ 6 | * 7 | * Copyright 2009-2014 Glencoe Software, Inc. All rights reserved. 8 | * Use is subject to license terms supplied in LICENSE.txt 9 | */ 10 | """ 11 | 12 | import logging 13 | logging.basicConfig(level=0) 14 | 15 | import omero.util.temp_files as t_f 16 | 17 | 18 | class TestTemps(object): 19 | 20 | def testBasicUsage(self): 21 | p = t_f.create_path("foo", ".bar") 22 | assert p.exists() 23 | t_f.remove_path(p) 24 | assert not p.exists() 25 | 26 | def testBasicUsagePassString(self): 27 | p = t_f.create_path("foo", ".bar") 28 | assert p.exists() 29 | t_f.remove_path(str(p)) 30 | assert not p.exists() 31 | 32 | def testNoCleanUp(self): 33 | p = t_f.create_path("foo", ".bar") 34 | assert p.exists() 35 | # Logger should print out one file 36 | 37 | def testUsingThePath(self): 38 | p = t_f.create_path("write", ".txt") 39 | p.write_text("hi") 40 | assert ["hi"] == p.lines() 41 | 42 | def testUsingThePath2(self): 43 | p = t_f.create_path("write2", ".txt") 44 | p.write_text("hi2") 45 | assert ["hi2"] == p.lines() 46 | 47 | def testUsingThePathAndAFile(self): 48 | p = t_f.create_path("write", ".txt") 49 | p.write_text("hi") 50 | f = open(str(p), "r") 51 | assert ["hi"] == f.readlines() 52 | f.close() 53 | 54 | def testFolderSimple(self): 55 | p = t_f.create_path("close", ".dir", folder=True) 56 | assert p.exists() 57 | assert p.isdir() 58 | 59 | def testFolderWrite(self): 60 | p = t_f.create_path("close", ".dir", folder=True) 61 | f = p / "file" 62 | f.write_text("hi") 63 | assert ["hi"] == f.lines() 64 | 65 | def testFolderDelete(self): 66 | p = t_f.create_path("close", ".dir", folder=True) 67 | assert p.exists() 68 | p.rmtree() 69 | assert not p.exists() 70 | 71 | # 72 | # Misc 73 | # 74 | 75 | def DISABLEDtestManagerPrefix(self): 76 | mgr = t_f.TempFileManager(prefix="omero_temp_files_test") 77 | dir = mgr.gettempdir() 78 | mgr.clean_tempdir() # start with a blank dir 79 | assert not dir.exists() 80 | mgr.create_path("test", ".tmp") 81 | assert dir.exists() 82 | mgr.clean_tempdir() 83 | # There should still be one file lock 84 | assert dir.exists() 85 | -------------------------------------------------------------------------------- /tox.ini: -------------------------------------------------------------------------------- 1 | [tox] 2 | envlist = py39, py310, py311, py312 3 | # https://tox.readthedocs.io/en/latest/config.html#conf-requires 4 | # Ensure pip is new enough 5 | requires = pip >= 19.0.0 6 | virtualenv >= 16.0.0 7 | 8 | [testenv] 9 | # For environment markers see 10 | # https://www.python.org/dev/peps/pep-0508/#environment-markers 11 | deps = 12 | setuptools 13 | numpy 14 | Pillow 15 | pytest 16 | PyYAML 17 | tables 18 | pytest-rerunfailures 19 | pytest-xdist 20 | pytest-mock 21 | restructuredtext-lint 22 | https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp39-cp39-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.9" 23 | https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp310-cp310-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.10" 24 | https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp311-cp311-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.11" 25 | https://github.com/glencoesoftware/zeroc-ice-py-linux-x86_64/releases/download/20240202/zeroc_ice-3.6.5-cp312-cp312-manylinux_2_28_x86_64.whl; platform_system=="Linux" and python_version=="3.12" 26 | https://github.com/glencoesoftware/zeroc-ice-py-macos-x86_64/releases/download/20231130/zeroc_ice-3.6.5-cp39-cp39-macosx_11_0_x86_64.whl; platform_system!="Windows" and platform_system!="Linux" and python_version=="3.9" 27 | https://github.com/glencoesoftware/zeroc-ice-py-macos-universal2/releases/download/20240131/zeroc_ice-3.6.5-cp310-cp310-macosx_11_0_universal2.whl; platform_system!="Windows" and platform_system!="Linux" and python_version=="3.10" 28 | https://github.com/glencoesoftware/zeroc-ice-py-win-x86_64/releases/download/20240325/zeroc_ice-3.6.5-cp39-cp39-win_amd64.whl; platform_system=="Windows" and python_version=="3.9" 29 | https://github.com/glencoesoftware/zeroc-ice-py-win-x86_64/releases/download/20240325/zeroc_ice-3.6.5-cp310-cp310-win_amd64.whl; platform_system=="Windows" and python_version=="3.10" 30 | https://github.com/glencoesoftware/zeroc-ice-py-win-x86_64/releases/download/20240325/zeroc_ice-3.6.5-cp311-cp311-win_amd64.whl; platform_system=="Windows" and python_version=="3.11" 31 | https://github.com/glencoesoftware/zeroc-ice-py-win-x86_64/releases/download/20240325/zeroc_ice-3.6.5-cp312-cp312-win_amd64.whl; platform_system=="Windows" and python_version=="3.12" 32 | # zeroc-ice installed automatically on other platforms (setup.py install_requires) 33 | pywin32; platform_system=="Windows" 34 | jinja2 35 | pass_env = 36 | OMERODIR 37 | setenv = 38 | ICE_CONFIG = {toxinidir}/ice.config 39 | passenv = 40 | PIP_CACHE_DIR 41 | commands = 42 | rst-lint README.rst 43 | python setup.py install 44 | pytest {posargs:-n auto -m "not broken" --reruns 5 -rf test -v} 45 | omero version 46 | --------------------------------------------------------------------------------