Giter Club home page Giter Club logo

Comments (12)

Ape avatar Ape commented on July 21, 2024

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.

from samsungctl.

AnderssonPeter avatar AnderssonPeter commented on July 21, 2024

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

from samsungctl.

Ape avatar Ape commented on July 21, 2024

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.

from samsungctl.

AnderssonPeter avatar AnderssonPeter commented on July 21, 2024

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.

from samsungctl.

Ape avatar Ape commented on July 21, 2024

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?

from samsungctl.

AnderssonPeter avatar AnderssonPeter commented on July 21, 2024

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.

from samsungctl.

AnderssonPeter avatar AnderssonPeter commented on July 21, 2024

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'

from samsungctl.

Ape avatar Ape commented on July 21, 2024

You need to have appdirs installed. Try pip install appdirs.

from samsungctl.

AnderssonPeter avatar AnderssonPeter commented on July 21, 2024

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.

from samsungctl.

Ape avatar Ape commented on July 21, 2024

Do you have websocket-client installed? Which version is it? You may need to uninstall websocket.

from samsungctl.

AnderssonPeter avatar AnderssonPeter commented on July 21, 2024

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!

from samsungctl.

Bakipl avatar Bakipl commented on July 21, 2024

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

from samsungctl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.