tesladdicts / testatus

Python suite to access the Tesla JSON API, pollers and log via the API, parse the log, rpc, etc
MIT License
12 stars 2 forks source link

Password set from CLI does not accept special characters #7

Closed benderl closed 4 years ago

benderl commented 4 years ago

It seems like the argument parser does not recognize passwords starting with a hyphen. Even if I encapsulate the password in single or double quotes, the parser throws an error:

python ./teslajson.py --email test@mail.com --password '-atest'
usage: teslajson.py [-h] [--email EMAIL] [--password PASSWORD]
                    [--tokens_file TOKENS_FILE] [--tokens_file_use]
                    [--access_token ACCESS_TOKEN] [--proxy_url PROXY_URL]
                    [--proxy_user PROXY_USER]
                    [--proxy_password PROXY_PASSWORD] [--retries RETRIES]
                    [--retry_delay RETRY_DELAY] [--tesla_client TESLA_CLIENT]
                    [--debug] [--vid VID] [--json]
                    [command] [args [args ...]]
teslajson.py: error: argument --password: expected one argument

What is the recommended way for passing passwords with special characters from CLI?

SethRobertson commented 4 years ago

This is a python argparse bug https://bugs.python.org/issue35049 . However, there is an easy fix, just use the --password=-atest argument specification variant.

benderl commented 4 years ago

Thanks for looking into this and even provide a fix.