Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

path too long on windows when opening radarsat2 dataset #465

Open
underchemist opened this issue Feb 22, 2020 · 0 comments
Open

path too long on windows when opening radarsat2 dataset #465

underchemist opened this issue Feb 22, 2020 · 0 comments

Comments

@underchemist
Copy link

Hi,

when opening a radarsat2 dataset on windows the Node.py module throws an error similar to

stat: path too long for Windows
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\genericpath.py", line 19, in exists
    os.stat(path)
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\site-packages\nansat\node.py", line 307, in create
    if os.path.exists(dom):
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\site-packages\nansat\mappers\mapper_radarsat2.py", line 75, in __init__
    rs2_0 = Node.create(productXml)
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\site-packages\nansat\nansat.py", line 1143, in _get_mapper
    tmp_vrt = nansatMappers[mappername](self.filename, gdal_dataset, metadata, **kwargs)
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\site-packages\nansat\nansat.py", line 160, in __init__
    self.vrt = self._get_mapper(mapper, **kwargs)
  File "C:\Users\yanns\Downloads\nansat-scratch.py", line 3, in <module>
    src = nansat.Nansat('RS2_OK76385_PK678064_DK606753_F2N_20080419_142127_HH_HV_SLC\RS2_OK76385_PK678064_DK606753_F2N_20080419_142127_HH_HV_SLC', mapper='radarsat2')
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\runpy.py", line 263, in run_path
    pkg_name=pkg_name, script_name=fname)
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\yanns\Miniconda3\envs\nansat\Lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)

which seems to be tied to the fact that productXml is a raw xml string and os.path.exists is being called on it. I was able to avoid this by checking adding a check to Node.py:create method something like

WIN_PATH_MAX_LENGTH = 32000  # arbitrary, sourced from a stack overflow post on NT max path length
if len(dom) < WIN_PATH_MAX_LENGTH and os.path.exists(dom):
    ...

Although maybe it would be better to ensure that dom is either a path or already parsed xml object. I'm new to nansat but can submit a PR.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant