G-Two / subarulink

A python package for interacting with Subaru STARLINK remote vehicle services.
Apache License 2.0
84 stars 14 forks source link

[Question] Passing arguments to the CLI #8

Closed mconlow closed 4 years ago

mconlow commented 4 years ago

I'm excited for the native HA integration for this. In the meantime, maybe a basic(?) question? Is it possible to pass arguments into the CLI ? If I could do that, I'm sure I could get a couple of the basic actions working in HA as a stopgap.

Is something like: subarulink VIN lock possible?

G-Two commented 4 years ago

@mconlow Thanks for the suggestion. I've added the feature to the CLI subarulink==0.3.2. Please give it a try and let me know if it works for you. If you only have one VIN on your account, you don't need to worry about specifying the VIN. Assuming you have your sign-in credentials setup, all you should need to do is subarulink lock. If you have more than one VIN, you can now specify a default VIN (which is saved in the config file), or you can specify it when invoking the command with subarulink lock --vin <enter_vin_here>.

mconlow commented 4 years ago

Wow fast turnaround thanks!

i did pip install subarulink --upgrade and now I get this error when trying to do anything with the program, such as subarulink or subarulink lock:

  File "/Users/default_user/.pyenv/versions/3.7.3/lib/python3.7/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I haven't dug in much on this so don't know if I can give you any pointers. The only thing I can say about my specific install was I had problems with permissions to the config file, so wound up doing chmod ugo+rwx .subarulink.cfg and then commenting out the line that tried to do chmod in the app.

For the curious out there, there is a way to interact with the CLI, but I bet it would run into limitations down the road:

import subprocess

command = "subarulink"

p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                     shell=True, universal_newlines=True)
output, err = p.communicate(input="lock")
mconlow commented 4 years ago

Ah, got it working. Specified a config file with this other cool new feature you added in the local directory and all seems to work great.