Closed AnderssonPeter closed 7 years ago
Curses is used for the interactive mode (samsungctl -i
). I am afraid it's not available for Windows.
Please test if #32 fixes this issue for you. The pull request makes curses optional, so that you can use everything else except the interactive mode even without it.
i tried it and got the following error instead
ran py -m samsungctl
and py -m samsungctl --host 192.168.0.23 --port 8001 --method websocket key KEY_VOLUP
both gave the error..
Traceback (most recent call last):
File "C:\Users\xbmc\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\xbmc\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\xbmc\Downloads\samsungctl-pr-optional_curses\samsungctl\__main__.py", line 122, in <module>
main()
File "C:\Users\xbmc\Downloads\samsungctl-pr-optional_curses\samsungctl\__main__.py", line 92, in main
config = _read_config()
File "C:\Users\xbmc\Downloads\samsungctl-pr-optional_curses\samsungctl\__main__.py", line 30, in _read_config
directories.append(os.path.join(os.getenv("HOME"), ".config"))
File "C:\Users\xbmc\AppData\Local\Programs\Python\Python36-32\lib\ntpath.py", line 75, in join
path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType
So I guess os.getenv("HOME")
returns None
. I'm not surprised that it's not set on Windows, but might be that it's sometimes not available even on Linux (although usually it is). So this needs to be fixed. I'll make a pull request.
However, to properly support Windows and other operating systems, we should replace the whole config path list with something more generic or make OS specific paths.
I would help but i have only written like 20 lines of python (i find dynamic languages somewhat confusing), but i'm happy to test any changes you make.
But yes if i open py
and write
import os
str(os.getenv("HOME"))
it outputs 'None'
.
If i understand correctly os.getenv
tries to read a environment variable?
On windows i think we have a few diffrent alternatives where you can store configuration data.
"USERPROFILE"
Root directory of the user profile"APPDATA"
Location to store application data that will be synchronized between computers if same user logs in (requires a domain for the synchronization to take place)"LOCALAPPDATA"
Same as above without synchronization."ProgramData"
Here you can store data that is shared between all users.I made #35 to fix this. Could you check how it works in Windows? Are the system-wide and user specific paths correct / meaningful in Windows?
Ill try it out later when i get home, i don't have a samsung tv at work.
I don't know if the Paths are correct or meaningful, i tried to run import appdirs
in my python console but it just gave me ModuleNotFoundError: No module named 'appdirs'
so i can't check what appdirs.user_config_dir()
and appdirs.site_config_dir(title)
resolve into on windows.
But when looking at the documentation for appdirs 1.4.3
it seems they will be stored in C:\Users\<User>\AppData\Local\<AppName>
and that seems like good place as any.
i tried and got the following result
py -m samsungctl --name test --host 192.168.0.23 --port 8001 --method websocket KEY_VOLUP
Traceback (most recent call last):
File "C:\Users\xbmc\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\xbmc\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\xbmc\Downloads\samsungctl-pr-appdirs\samsungctl\__main__.py", line 1, in <module>
import appdirs
ModuleNotFoundError: No module named 'appdirs'
You need to have appdirs
installed. Try pip install appdirs
.
Ok that solves that error, then i got the same error but for websocket
so i installed that 2.
Now i get the following error:
py -m samsungctl --name test --host 192.168.0.23 --port 8001 --method websocket KEY_VOLUP
Traceback (most recent call last):
File "C:\Users\xbmc\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\Users\xbmc\AppData\Local\Programs\Python\Python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\xbmc\Downloads\samsungctl-pr-appdirs\samsungctl\__main__.py", line 119, in <module>
main()
File "C:\Users\xbmc\Downloads\samsungctl-pr-appdirs\samsungctl\__main__.py", line 97, in main
with Remote(config) as remote:
File "C:\Users\xbmc\Downloads\samsungctl-pr-appdirs\samsungctl\remote.py", line 10, in __init__
self.remote = RemoteWebsocket(config)
File "C:\Users\xbmc\Downloads\samsungctl-pr-appdirs\samsungctl\remote_websocket.py", line 21, in __init__
self.connection = websocket.WebSocket()
TypeError: __init__() missing 3 required positional arguments: 'environ', 'socket', and 'rfile'
Edit: this is the exact same error i get in Home Assistant
but i guess thats understandable as it uses this component.
Do you have websocket-client
installed? Which version is it? You may need to uninstall websocket
.
I had websocket (0.2.1)
installed, uninstalled it and installed websocket-client
instead and the error went away! now everything is working properly!
Thanks for your patience with me!
Hi had exactly the same issue with getting HOME dir on windows, i did: from pathlib import Path home = str(Path.home())
in main.py, as described here: https://stackoverflow.com/questions/4028904/how-to-get-the-home-directory-in-python
and it worked
Im running on windows and followed your instructions:
I get the following error from
2.
What am i doing wrong?
Python version 3.6.0