ESA-PhiLab / OpenSarToolkit

High-level functionality for the inventory, download and pre-processing of Sentinel-1 data in the python language.
https://opensartoolkit.readthedocs.io/en/latest/
MIT License
211 stars 54 forks source link

Unable to find gpt.exe when SNAP is installed for the current user only #97

Closed pedep closed 9 months ago

pedep commented 1 year ago

Describe the bug When importing ost on Windows, not all common paths are searched. When SNAP has been installed for the current user only, its located in %LocalAppData%, not in %ProgramFiles% which is the only place being searched currently.

This affects all non-administrator users, who are quite common among government and corporat

To Reproduce

  1. Install SNAP for the current user only.
  2. Run a python program which imports ost:
    # program.py
    import ost

    $ python3 program.py

  3. The input() prompt appears, even though snap is installed in a default location

Expected behavior

  1. Common search paths should be searched when resolving the gpt.exe path.
  2. Fallback resolution using path resolvers such as shutil.which (which are already available for unix installs) should be available for non-standard install paths.

Screenshots N/A

Desktop (please complete the following information):

Additional context There currently exists a workaround for this, which abuses the input() fallback:

import sys
from io import StringIO

original_stdin = = sys.stdin
sys.stdin = StringIO(r"C:\path\to\snap\bin\gpt.exe")
import ost
sys.stdin = original_stdin