From 889a733447c3538a5b32243afc738ecd6ae5d585 Mon Sep 17 00:00:00 2001 From: Vishal <321vishalds@gmail.com> Date: Mon, 31 Jul 2023 10:59:54 +0530 Subject: [PATCH] Finalized v0.1 (#8) * Removed encrypted keyring * Finalised v0.1 --- README.md | 8 +++++++- __tests__/check.py | 7 +++++++ main.py | 9 +-------- utils/auth.py | 9 ++++----- 4 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 __tests__/check.py diff --git a/README.md b/README.md index 6a812b8..fa798c5 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,13 @@ The first thing that you have to do is to set up and test run the software to se 3. Install all the required modules ```bash - $ pip install -r requirements.txt + $ sudo pip3 install -r requirements.txt # make sure to run it as root + ``` + + Now, test whether all the imports are working fine. + + ```bash + $ sudo __tests__/check.py # again run as root ``` 4. Run the script as root from the command line itself after connecting the OBD adapter to a car. diff --git a/__tests__/check.py b/__tests__/check.py new file mode 100644 index 0000000..95c38e9 --- /dev/null +++ b/__tests__/check.py @@ -0,0 +1,7 @@ +try: + import obd, pynmea2, qrcode, pyserial, requests, websockets, qrcode + print("You're good to go! All modules have been installed and appear to be working fine...") +except Exception as e: + print("Some modules couldn't be imported. This is what the Python interpreter has to say...\n") + print(e) + print("\nYou have to fix this error before continuing...\nTry running sudo pip install -r requirements.txt instead of pip3.\nIf it persists, please open a detailed issue at https://github.com/alpaDrive/vehicle/issues.") \ No newline at end of file diff --git a/main.py b/main.py index 46d8bb9..7572025 100644 --- a/main.py +++ b/main.py @@ -17,13 +17,6 @@ def power_check(): def register(): company = input("Enter the brand/make of this car >> ") model = input("Enter the model/name of this car >> ") - encrypt = False - should_encrypt = input("Do you want to have encrypted credentials in this device? (y/Y) >> ") - if should_encrypt.lower() == 'y': - print("Encryption will be enabled. You will be prompted to enter a keyring password later on.") - encrypt = True - else: - print("Encryption will stay disabled.") payload = { "company": company, "model": model @@ -38,7 +31,7 @@ def register(): initial: True })) print("\nOpen the mobile app & scan this QR code to pair. This is a one time use code. If you want to share this vehicle, use the share option in the app instead.") - auth.set_creds(creds, encrypt) + auth.set_creds(creds) def get_message(message, vid, mode='broadcast', conn_id="", status="success", attachments=[]): # Create message in standard format diff --git a/utils/auth.py b/utils/auth.py index 3cc2912..b703c43 100644 --- a/utils/auth.py +++ b/utils/auth.py @@ -7,6 +7,10 @@ import keyring.backend from keyrings.alt.file import PlaintextKeyring +# We can't use the default encrypted backend as that keeps asking for an encryption password in the console +# which is not viable for simplicity to the end user. ofc this is the same as using a text file but :( +keyring.set_keyring(PlaintextKeyring()) + def is_authenticated(): return keyring.get_password("alpaDrive", "vehicle") is not None @@ -15,9 +19,4 @@ def get_creds(): return creds if creds is not None else "" def set_creds(value, encrypt=False): - if encrypt: - # We can't use the default encrypted backend as that keeps asking for an encryption password in the console - # which is not viable for simplicity to the end user. ofc this is the same as using a text file but :( - keyring.set_keyring(PlaintextKeyring()) - keyring.set_password("alpaDrive", "vehicle", value) \ No newline at end of file