dbosk / ladok3

Python wrapper around the LADOK3 REST API.
https://pypi.org/project/ladok3/
MIT License
5 stars 1 forks source link

`os.mkdir` seems to not create missing parents on Windows #61

Closed dbosk closed 1 year ago

dbosk commented 1 year ago

(Thanks Robert Jonsson!)

Here is another type of error (executed in Windows command prompt as an administrator):

C:\WINDOWS\system32>ladok data dt133g
Course  Round   Component       Student Grade   Time
...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Python311\Scripts\ladok.exe\__main__.py", line 7, in <module>
  File "C:\Python311\Lib\site-packages\ladok3\cli.py", line 339, in main
    store_ladok_session(ls, LADOK_VARS)
  File "C:\Python311\Lib\site-packages\ladok3\cli.py", line 37, in
store_ladok_session
    os.mkdir(dirs.user_cache_dir)
FileNotFoundError: [WinError 3] Det går inte att hitta sökvägen:
'C:\\Users\\roberi\\AppData\\Local\\dbosk@kth.se\\ladok\\Cache'

The error occurred after almost 400 printed results.

That error seems more reasonable. This happens when it's done. It wants to write the cache to disk. It seems like the os.mkdir function on Windows doesn't create parent directories, which it seems to do on *nix. (Because I would assume that the administrator has the right to create that directory in the roberi user's home directory.)

dbosk commented 1 year ago

Uses os.makedirs now.