Skip to content

Improve error message of ome_zarr finder on read-only locations #508

@imagejan

Description

@imagejan

When you try running ome_zarr finder . in a directory with read-only permission, you currently get:

Traceback (most recent call last):
  File "/<user_path>/.pixi/envs/ome-zarr/bin/ome_zarr", line 10, in <module>
    sys.exit(main())
             ~~~~^^
  File "/<user_path>/.pixi/envs/ome-zarr/lib/python3.13/site-packages/ome_zarr/cli.py", line 210, in main
    ns.func(ns)
    ~~~~~~~^^^^
  File "/<user_path>/.pixi/envs/ome-zarr/lib/python3.13/site-packages/ome_zarr/cli.py", line 44, in finder
    bff_finder(args.path, args.port)
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/<user_path>/.pixi/envs/ome-zarr/lib/python3.13/site-packages/ome_zarr/utils.py", line 250, in finder
    with open(bff_csv, "w", newline="") as csvfile:
         ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: './biofile_finder.csv'

I suggest wrapping these lines in a try .. catch clause:

with open(bff_csv, "w", newline="") as csvfile:
writer = csv.writer(csvfile, delimiter=",")

.. and providing a more informative error message, such as:

'ome_zarr finder' needs write permission, the provided location {location} seems to be read-only.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions