Giter Site home page Giter Site logo

alicecli's Introduction

Upload Python Package Maintainability Rating Quality Gate Status Coverage

Project Alice CLI

This is a Project Alice command line tool.

It simplifies to the maximum the installation and maintenance of Project Alice.

It is not meant to be installed on the device that runs/will run Alice, but on your main computer.

It handles connecting to network discoverable devices through SSH and generates RSA keys for a passwordless connection.

Although it's a command line tool, made possible thanks to the awesome "Click" package, it is using the wonderful "InquirerPy" package, a reboot of the deprecated "PyInquirer", to offer an interactive menu for people not used or wanting to type commands.

Users

Install this tool via pip, on your main computer:

pip3 install projectalice-cli

Note that you need Python 3.8 at least

Devs of this tool

  • Clone this repository
  • Open a terminal on whatever OS you are
  • CD to the path where you cloned this repository
  • Create a python 3.8+ virtual environment: python -m venv
  • Activate your virtual environment
  • Install the package in dev mode: pip install --editable .

Usage

Type alice in your terminal to open the main menu or type alice --help to discover the available commands

Useful information

This tool stores its configurations in %USER_DIRECTORY%/.pacli

This tool stores its generated SSH certificates in %USER_DIRECTORY%/.ssh

Thank You!

jonah1024: A big thank you for making this work in macOs as well!

alicecli's People

Contributors

aaronchantrill avatar hipitihop avatar oliverrahner avatar philipp2310 avatar psychokiller1888 avatar thehacker avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar

alicecli's Issues

Broken PyInquirer dependency on Python 3.10

PyInquirer requires a pretty out of date version of prompt-toolkit (1.0.14, current version is 3.0.24), which has a broken import statement in Python 3.10.

The file prompt_toolkit/styles/from_dict.py includes the line from collections import Mapping which needs to be updated to from collections.abc import Mapping.

Psycho suggested swapping out another compatible library: possibly https://github.com/magmax/python-inquirer. I'll try it and see how it goes.

Error on "Prepare your SD card"

I'm trying to use AliceCLI to prepare an SDCard but getting an error when i select it:

Project Alice CLI version 1.2.1

?  Prepare your SD card
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\Scripts\alice.exe\__main__.py", line 7, in <module>
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\core.py", line 1637, in invoke
    super().invoke(ctx)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\AliceCli\AliceCli.py", line 34, in cli
    ctx.invoke(MainMenu.mainMenu)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\AliceCli\MainMenu.py", line 107, in mainMenu
    action()
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\AliceCli\MainMenu.py", line 79, in <lambda>
    Choice(lambda: ctx.invoke(prepareSdCard), name='Prepare your SD card'),
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\click\decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "C:\Users\abcabc\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\AliceCli\install\install.py", line 400, in prepareSdCard
    flasherAvailable = Path(balenaExecutablePath).exists()
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 958, in __new__
    self = cls._from_parts(args)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 592, in _from_parts
    drv, root, parts = self._parse_args(args)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.752.0_x64__qbz5n2kfra8p0\lib\pathlib.py", line 576, in _parse_args
    a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType

install issue

Just in case it's something you need to know ? I got the below install errors while trying to update to the latest CLI. feel free to close the issue if it's not something you want to account for :)

larry@larrys-linux:$ pip3.8 uninstall projectalice-cli
Found existing installation: projectalice-cli 0.1.3
Uninstalling projectalice-cli-0.1.3:
Would remove:
/home/larry/.local/bin/alice
/home/larry/.local/lib/python3.8/site-packages/AliceCli/*
/home/larry/.local/lib/python3.8/site-packages/projectalice_cli-0.1.3.dist-info/*
Proceed (Y/n)? y
Successfully uninstalled projectalice-cli-0.1.3
larry@larrys-linux:
$ pip3.8 install projectalice-cli
Defaulting to user installation because normal site-packages is not writeable
Collecting projectalice-cli
Downloading projectalice_cli-1.1.0-py3-none-any.whl (44 kB)
|████████████████████████████████| 44 kB 405 kB/s
Collecting coverage~=6.2
Downloading coverage-6.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (217 kB)
|████████████████████████████████| 217 kB 17 kB/s
Collecting beautifulsoup4~=4.10.0
Downloading beautifulsoup4-4.10.0-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 68 kB/s
Collecting requests~=2.26.0
Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
|████████████████████████████████| 62 kB 40 kB/s
Collecting InquirerPy~=0.3.1
Downloading InquirerPy-0.3.1-py3-none-any.whl (66 kB)
|████████████████████████████████| 66 kB 39 kB/s
Collecting click~=8.0.3
Downloading click-8.0.3-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 42 kB/s
Collecting paramiko~=2.8.1
Downloading paramiko-2.8.1-py2.py3-none-any.whl (206 kB)
|████████████████████████████████| 206 kB 20 kB/s
Collecting tqdm~=4.62.3
Downloading tqdm-4.62.3-py2.py3-none-any.whl (76 kB)
|████████████████████████████████| 76 kB 20 kB/s
Collecting pytest-cov~=3.0.0
Downloading pytest_cov-3.0.0-py3-none-any.whl (20 kB)
Requirement already satisfied: networkscan~=1.0.9 in ./.local/lib/python3.8/site-packages (from projectalice-cli) (1.0.9)
Requirement already satisfied: psutil~=5.8.0 in ./.local/lib/python3.8/site-packages (from projectalice-cli) (5.8.0)
Collecting pytest~=6.2.5
Downloading pytest-6.2.5-py3-none-any.whl (280 kB)
|████████████████████████████████| 280 kB 18 kB/s
Collecting pyyaml~=6.0
Downloading PyYAML-6.0-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (701 kB)
|████████████████████████████████| 701 kB 20 kB/s
Collecting coveralls~=3.3.1
Downloading coveralls-3.3.1-py2.py3-none-any.whl (14 kB)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.8/dist-packages (from beautifulsoup4~=4.10.0->projectalice-cli) (2.0.1)
Requirement already satisfied: docopt>=0.6.1 in /usr/local/lib/python3.8/dist-packages (from coveralls~=3.3.1->projectalice-cli) (0.6.2)
Collecting pfzy<0.4.0,>=0.3.1
Downloading pfzy-0.3.3-py3-none-any.whl (8.5 kB)
Collecting prompt-toolkit<4.0.0,>=3.0.1
Downloading prompt_toolkit-3.0.24-py3-none-any.whl (374 kB)
|████████████████████████████████| 374 kB 25 kB/s
Requirement already satisfied: bcrypt>=3.1.3 in /usr/lib/python3/dist-packages (from paramiko~=2.8.1->projectalice-cli) (3.1.7)
Requirement already satisfied: cryptography>=2.5 in /usr/lib/python3/dist-packages (from paramiko~=2.8.1->projectalice-cli) (2.8)
Requirement already satisfied: pynacl>=1.0.1 in /usr/lib/python3/dist-packages (from paramiko~=2.8.1->projectalice-cli) (1.3.0)
Requirement already satisfied: toml in /usr/local/lib/python3.8/dist-packages (from pytest~=6.2.5->projectalice-cli) (0.10.1)
Requirement already satisfied: iniconfig in /usr/local/lib/python3.8/dist-packages (from pytest~=6.2.5->projectalice-cli) (1.1.1)
Requirement already satisfied: packaging in /usr/local/lib/python3.8/dist-packages (from pytest~=6.2.5->projectalice-cli) (20.4)
Requirement already satisfied: py>=1.8.2 in /usr/local/lib/python3.8/dist-packages (from pytest~=6.2.5->projectalice-cli) (1.9.0)
Requirement already satisfied: pluggy<2.0,>=0.12 in /usr/local/lib/python3.8/dist-packages (from pytest~=6.2.5->projectalice-cli) (0.13.1)
Requirement already satisfied: attrs>=19.2.0 in /usr/local/lib/python3.8/dist-packages (from pytest~=6.2.5->projectalice-cli) (20.2.0)
Requirement already satisfied: idna<4,>=2.5 in /usr/lib/python3/dist-packages (from requests~=2.26.0->projectalice-cli) (2.8)
Collecting charset-normalizer~=2.0.0
Downloading charset_normalizer-2.0.10-py3-none-any.whl (39 kB)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests~=2.26.0->projectalice-cli) (2019.11.28)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.local/lib/python3.8/site-packages (from requests~=2.26.0->projectalice-cli) (1.25.10)
Collecting tomli
Downloading tomli-2.0.0-py3-none-any.whl (12 kB)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.8/dist-packages (from prompt-toolkit<4.0.0,>=3.0.1->InquirerPy~=0.3.1->projectalice-cli) (0.2.5)
Requirement already satisfied: six in ./.local/lib/python3.8/site-packages (from packaging->pytest~=6.2.5->projectalice-cli) (1.14.0)
Requirement already satisfied: pyparsing>=2.0.2 in /usr/local/lib/python3.8/dist-packages (from packaging->pytest~=6.2.5->projectalice-cli) (2.4.7)
Installing collected packages: tomli, coverage, charset-normalizer, requests, pytest, prompt-toolkit, pfzy, tqdm, pyyaml, pytest-cov, paramiko, InquirerPy, coveralls, click, beautifulsoup4, projectalice-cli
Attempting uninstall: requests
Found existing installation: requests 2.24.0
Uninstalling requests-2.24.0:
Successfully uninstalled requests-2.24.0
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pyinquirer 1.0.3 requires prompt-toolkit==1.0.14, but you have prompt-toolkit 3.0.24 which is incompatible.
projectalice-sk 1.9.5 requires coverage~=4.5.4, but you have coverage 6.2 which is incompatible.
projectalice-sk 1.9.5 requires coveralls~=1.8.2, but you have coveralls 3.3.1 which is incompatible.
projectalice-sk 1.9.5 requires prompt-toolkit==1.0.14, but you have prompt-toolkit 3.0.24 which is incompatible.
projectalice-sk 1.9.5 requires pytest~=5.2.2, but you have pytest 6.2.5 which is incompatible.
projectalice-sk 1.9.5 requires pytest-cov~=2.8.1, but you have pytest-cov 3.0.0 which is incompatible.
mediawikiapi 1.1.5 requires beautifulsoup4==4.9.1, but you have beautifulsoup4 4.10.0 which is incompatible.
Successfully installed InquirerPy-0.3.1 beautifulsoup4-4.10.0 charset-normalizer-2.0.10 click-8.0.3 coverage-6.2 coveralls-3.3.1 paramiko-2.8.1 pfzy-0.3.3 projectalice-cli-1.1.0 prompt-toolkit-3.0.24 pytest-6.2.5 pytest-cov-3.0.0 pyyaml-6.0 requests-2.26.0 tomli-2.0.0 tqdm-4.62.3
larry@larrys-linux:~$

Tool oservations and Issues ?

I thought today that i'd test the Cli tool out and use it to wipe and reinstall alice. The below is my observations.

  • CLI tool installed on Ubuntu which is running Python 3.8
  • Successfully connected to my "testAlice" rpi 3b+
  1. "prepareSdCard" wouldn't work for me, always returned " please insert sd card " message. I'm using a 32gb sandisk card if that is relevant.
    1.1 "search for a device" - returns no devices, however i have two alices and a satellite on my network
  2. Next option choosen was "install soundcard" - as far as i can tell all went smoothly
  3. Then i tried "install Alice" - CLI tool told me alice aready exists.. erase and reinstall ?....., i said yes
  4. Observation... the venv gets created using python 3.7, should that not be 3.8 at minimum nowadays ?
  5. During initilizer stage i get the below
Missing key **False** in provided yaml file.
[Initializer]	  Config file already existing and user not wanting to rewrite, aborting
[Project Alice]           Starting Alice main unit
  1. start up kept looping due to this error https://paste.ubuntu.com/p/GnGVC7mq2x/ the remedy for that is to "reboot" however there is no automation of that or any indication that a user should reboot to allow Alice to continue
  2. after reboot (#6) the mqtt error sort of disappears, Alice then tried about 3 times to connect, initially had the same as #6, then she tried again and had a audio error so she restarted again , then had another " mqtt keyword error" so she restarted herself again ,and then finally started the rest of the install process.
  3. During the install a dependency was "deepspeech" so it downloaded that. Suggest it doesnt do that as its a huge file and doesnt work well anyway.
  4. Eventually everything installed and Alice started ,
  5. Each reboot i continue to get
[SkillManager]            Skill "Telemetry" does not comply to "activeManager" condition, required "['TelemetryManager']"
  1. each reboot it keeps doing
[Initializer]	  Starting Project Alice initialization
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Note, selecting 'libxslt1-dev' instead of 'libxslt-dev'
and all the other version checks

I tested the above steps three times. same deal every time i tried.

Device discovery looks very fragile

Just had a look into discover(), because AliceCLI did not display any devices for me.

I found
a) socket.gethostbyname(socket.gethostname()) just reverses-lookup my hostname, resulting in 127.0.1.1, a loopback address.
b) AliceCLI then just assumes this is a '/24' net (it is not!) and pings 254 times the (local) machine. All these IPs are pingable, and therefore end up in devices.
c) A "potential device" must have "projectalice" or "raspberrypi" inside name.
d) There is a .home replacement hack in the code.

There are a couple of suggestions to improve here :)
a)

  • I would not only do this approach, but try more ways. For example ip a or hostname -I. These depend very much on the underlying OS, but so does the current approach with ping (there is also a switch between Windows and the rest).
  • The user should be able to see, what's happening (display all found nets and let the user choose "My PI is in 192.168.0.0/24", "Just search all found nets" or even provide a text field option "My PI is in neither of the above nets / or not detectable. I would like to type the IP address manually".
    Hint: I have Docker installed on my machine, I have 22 different IP addresses/nets on this machine.

b)

c)

  • I don't like too long hostnames (I have a lot of machines in my network), so I would name my Alice "project-alice" (with a minus sign). Maybe just searching for "alice" or "raspberry" (even "pi" as a word, not just substring).

d)

  • For example I use .thehacker.local at home 😁 - not sure, whether you should keep this special case.

I have seen, there is the option to explicitly list all device, not just the potential ones, by alice discover -a. As also the --network option. I get good results, if I use them both. However all the data is displayed twice (on top with IP and hostname, then below in the menu only with IP adress), so it's hard to read. – What about putting both (IP and name) into the menu?


Looking forward to feedback on my finding and suggestions. I would be happy to code something and create a PR, but makes sense only, if you like my direction. 😃

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.