kaliiiiiiiiii / CDP-Socket

socket for handling chrome-developer-protocol connections
MIT License
13 stars 3 forks source link

python site-packages should be treated as read-only #17

Closed milahu closed 9 months ago

milahu commented 9 months ago
  File "/lib/python3.10/site-packages/cdp_socket/utils/utils.py", line 119, in launch_chrome
    os.makedirs(data_dir_path, exist_ok=True)
PermissionError: [Errno 13] Permission denied: '/lib/python3.10/site-packages/cdp_socket/files/tmp'

https://github.com/kaliiiiiiiiii/CDP-Socket/blob/4bae35c6a93b5c86da8978a82820c5944b2b6ed8/src/cdp_socket/utils/utils.py#L116-L119

https://github.com/kaliiiiiiiiii/CDP-Socket/blob/4bae35c6a93b5c86da8978a82820c5944b2b6ed8/src/cdp_socket/utils/utils.py#L60-L61

quickfix:

def cdp_sock_path():
    return os.environ.get("HOME", "/tmp") + "/.cache/cdp-socket"

similar issue: https://github.com/kaliiiiiiiiii/Selenium-Driverless/issues/122

kaliiiiiiiiii commented 9 months ago

Ahh yep get what you mean. It's just some util function for demonstration, shouldn't & isn't really used anywhere. I'll fix it tho, thx.

milahu commented 9 months ago

It's just some util function

this code is reached by https://github.com/kaliiiiiiiiii/Selenium-Driverless/issues/123#issuecomment-1858803756

kaliiiiiiiiii commented 9 months ago

@milahu I'm aware that changing the arguments is suboptimal. However, as the function should only be used for testing, I think that making the data_dir_path not optional anymore is the way to go.

For usage at deployment, creating a tempfile.TemporaryDirectory and after usage cleaning it with shutil.rmdir whould be the way to go I'd suppose.