cwerner / fastclass

Little tools to download and then weed through images, delete and classify them into groups for building deep learning image datasets (based on crawler and tkinter)
Apache License 2.0
133 stars 25 forks source link

NotADirectoryError with fcd #19

Closed H4dr1en closed 5 years ago

H4dr1en commented 5 years ago

I encountered the following error:

Searching: >> Skechers Skech-Air: Porter - Zevelo <<
(1) Crawling ...
Traceback (most recent call last):
File "...\envs\py3\lib\runpy.py", line 193, in _run_module_as_main                                                       "__main__", mod_spec)
File "...\envs\py3\lib\runpy.py", line 85, in _run_code                                                                  exec(code, run_globals)
File "...\envs\py3\Scripts\fcd.exe\__main__.py", line 9, in <module>                                                   
File "...\envs\py3\lib\site-packages\click\core.py", line 764, in __call__                                               return self.main(*args, **kwargs)
File "...\envs\py3\lib\site-packages\click\core.py", line 717, in main                                                   rv = self.invoke(ctx)
File "...\envs\py3\lib\site-packages\click\core.py", line 956, in invoke                                                 return ctx.invoke(self.callback, **ctx.params)
File "...\envs\py3\lib\site-packages\click\core.py", line 555, in invoke                                                 return callback(*args, **kwargs)
File "...\envs\py3\lib\site-packages\fastclass\fc_download.py", line 168, in cli                                         main(infile, size, crawler, keep, maxnum, outpath)
File "...\envs\py3\lib\site-packages\fastclass\fc_download.py", line 117, in main                                        source_urls = crawl(raw_folder, search_term, maxnum, crawlers=crawler)                                                                                              File "...\envs\py3\lib\site-packages\fastclass\fc_download.py", line 46, in crawl                                        os.makedirs(folder, exist_ok=True)
File "...\envs\py3\lib\os.py", line 220, in makedirs                                                                     mkdir(name, mode)
NotADirectoryError: [WinError 267] The directory name is invalid: 'C:\\Users\\x\\AppData\\Local\\Temp\\tmpi3pqkz6f\\Skechers_Skech-Air:_Porter_-_Zevelo'  

The bug comes from this line because the character ":" of the string Skechers Skech-Air: Porter - Zevelo is not escaped and is not valid inside a Windows path.

I would suggest to use the sanitizer of Django for this.

I implemented it in #16