question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: object of type 'NoneType' has no len() & NotADirectoryError:

See original GitHub issue
  • which operating system are you using?
    Windows 10,
  • which environment is pyroSAR running in?
    python 3.6, spyder 4.1.3
  • which version of pyroSAR are you using?
    0.12.1 one installed via pip or a clone of the GitHub repository? pip install
  • which function of pyroSAR did you call with which parameters?

I used your example to create the *.xml file it works fine, I only changed the GRD item, and the path

from pyroSAR.snap.auxil import parse_recipe, parse_node

workflow = parse_recipe('blank')

read = parse_node('Read')
read.parameters['file'] = 'D:\pyrosar_test\S1A_IW_GRDH_----------------------------.zip' # I think not necessary which item is.

read.parameters['formatName'] = 'SENTINEL-1'
workflow.insert_node(read)

tnr = parse_node('ThermalNoiseRemoval')
workflow.insert_node(tnr, before=read.id)

bnr = parse_node('Remove-GRD-Border-Noise')
bnr.parameters['selectedPolarisations'] = ['VV'] 

workflow.insert_node(bnr, before=tnr.id)

write = parse_node('Write')
write.parameters['file'] = 'outname'
write.parameters['formatName'] = 'BEAM-DIMAP'
workflow.insert_node(write, before=bnr.id)

workflow.write('D:\pyrosar_test\outname_proc')
from pyroSAR.snap.auxil import gpt
gpt('D:\\pyrosar_test\\outname_proc.xml', 'D:\\pyrosar_test')

AND I tried up also,

gpt('D:\pyrosar_test\outname_proc.xml', 'D:\pyrosar_test')
  • if applicable, which version of SNAP or GAMMA are you using in pyroSAR? SNAP 8
  • the full error message
Traceback (most recent call last):

  File "C:\Users\FALAH FAKHRI\untitled0.py", line 36, in <module>
    gpt('D:\\pyrosar_test\\outname_proc.xml', 'D:\\pyrosar_test')

  File "C:\Users\FALAH FAKHRI\AppData\Local\Programs\Python\Python36\lib\site-packages\pyroSAR\snap\auxil.py", line 343, in gpt
    while i < len(groups) - 1:

TypeError: object of type 'NoneType' has no len()

Then I used the *.xml which has been created in SNAP, it runs and I got the results I could open them, but gives this error,

from pyroSAR.snap.auxil import gpt

gpt('D:\\pyrosar_test\\spdivpy201524.xml', 'D:\\pyrosar_test')
executing node sequence..
ThermalNoiseRemoval -> Apply-Orbit-File -> Calibration -> Speckle-Filter -> Speckle-Filter(2) -> Speckle-Divergence -> Speckle-Divergence(2)
Traceback (most recent call last):

  File "C:\Users\FALAH FAKHRI\untitled0.py", line 36, in <module>
    gpt('D:\\pyrosar_test\\spdivpy201524.xml', 'D:\\pyrosar_test')

  File "C:\Users\FALAH FAKHRI\AppData\Local\Programs\Python\Python36\lib\site-packages\pyroSAR\snap\auxil.py", line 420, in gpt
    shutil.rmtree(tmpname, onerror=windows_fileprefix)

  File "C:\Users\FALAH FAKHRI\AppData\Local\Programs\Python\Python36\lib\shutil.py", line 488, in rmtree
    return _rmtree_unsafe(path, onerror)

  File "C:\Users\FALAH FAKHRI\AppData\Local\Programs\Python\Python36\lib\shutil.py", line 370, in _rmtree_unsafe
    onerror(os.listdir, path, sys.exc_info())

  File "C:\Users\FALAH FAKHRI\AppData\Local\Programs\Python\Python36\lib\site-packages\pyroSAR\ancillary.py", line 303, in windows_fileprefix
    func(u'\\\\?\\' + path)

NotADirectoryError: [WinError 267] The directory name is invalid: '\\\\?\\D:\\pyrosar_test\\VH\\S1A_IW_GRDH_1SDV_20150824_VH_Orb_Cal_Spk_SpkDiv.dim'

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
johntruckenbrodtcommented, Mar 22, 2021

Hi @falahfakhri-Iraq. Great you have found a workaround in the meantime! Yes, this is very similar to execute. I’ll post updates to the bug fixing in the next days…

0reactions
johntruckenbrodtcommented, Nov 5, 2021

The following works now:

import os
from pyroSAR.snap.auxil import parse_recipe, parse_node, gpt

workflow = parse_recipe('blank')

src = 'D:\\pyrosar_test\\S1A_IW_GRDH_----------------------------.zip'

outdir = 'D:\\pyrosar_test'
tmpdir = os.path.join(outdir, 'tmp')
outname = os.path.join(outdir, 'outname')
xmlfile = os.path.join(outdir, 'outname_proc.xml')

os.makedirs(outdir, exist_ok=True)

read = parse_node('Read')
read.parameters['file'] = src

read.parameters['formatName'] = 'SENTINEL-1'
workflow.insert_node(read)

tnr = parse_node('ThermalNoiseRemoval')
workflow.insert_node(tnr, before=read.id)

bnr = parse_node('Remove-GRD-Border-Noise')
bnr.parameters['selectedPolarisations'] = ['VV']

workflow.insert_node(bnr, before=tnr.id)

write = parse_node('Write')
write.parameters['file'] = outname
write.parameters['formatName'] = 'BEAM-DIMAP'
workflow.insert_node(write, before=bnr.id)

workflow.write(xmlfile)

gpt(xmlfile=xmlfile, cleanup=True, tmpdir=tmpdir)

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: object of type 'NoneType' has no len() in Python
The Python "TypeError: object of type 'NoneType' has no len()" occurs when we pass a None value to the len() function. To solve...
Read more >
Python TypeError: object of type 'NoneType' has no len()
The “TypeError: object of type 'NoneType' has no len() ” error is caused when you try to use the len() method on an...
Read more >
Python: TypeError: object of type 'NoneType' has no len()
Drop the assignment. This function returns None and that's why you have the error: TypeError: object of type 'NoneType' has no len().
Read more >
TypeError: object of type 'NoneType' has no len() - STechies
This error is generated in Python when we try to calculate the length of an object which returns 'none'. Let us understand it...
Read more >
TypeError: object of type 'NoneType' has no len() - Yawin Tutor
If a python variable is not assigned with any value, or objects, the variable would have none data type. If the length function...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found