ev3dev / ev3dev-lang-fake-sys

Test ev3dev-lang bindings with fake /sys/class tree
5 stars 6 forks source link

Error when running clean script: we never create the "arena" directory #4

Closed WasabiFan closed 8 years ago

WasabiFan commented 8 years ago

I'm getting the following error when running the populate clean script:

> Error: FileNotFoundError: [WinError 3] The system cannot find the path specified: '<...>\\ev3dev-lang-js\\test\\fake-sys\\arena'
    ----- Python Traceback -----
    File "<...>\ev3dev-lang-js\test\fake-sys\clean_arena.py", line 11, in <module>
      clean_arena()
    File "<...>\ev3dev-lang-js\test\fake-sys\clean_arena.py", line 8, in clean_arena
      shutil.rmtree(os.path.join(root, 'arena'))
    File "D:\tools\Python35\lib\shutil.py", line 488, in rmtree
      return _rmtree_unsafe(path, onerror)
    File "D:\tools\Python35\lib\shutil.py", line 370, in _rmtree_unsafe
      onerror(os.listdir, path, sys.exc_info())
    File "D:\tools\Python35\lib\shutil.py", line 368, in _rmtree_unsafe
      names = os.listdir(path)

... So the script doesn't actually ever create the arena directory, and it looks like the tree copy function isn't willing to create it for us. Is the proper solution to just add a mkdir-equivalent before the copy?

WasabiFan commented 8 years ago

If the answer is yes, I can fix it in my PR with the other changes.

ddemidov commented 8 years ago

hmm, shutil.copytree handles that for me.

Ok, the problem is that clean_arena fails when there is nothing to clean. I think wrapping this line into a try/except block should help.

WasabiFan commented 8 years ago

Oh wow, I completely missed the fact that it was running the clean script and not the populate one!

I'll make that change in my PR.

ddemidov commented 8 years ago

Even better, rmtree has ignore_errors flag: https://docs.python.org/2/library/shutil.html#shutil.rmtree