diff --git a/pisa-btc/apps/cli/DEPENDENCIES.md b/pisa-btc/apps/cli/DEPENDENCIES.md index 0253878..58422f8 100644 --- a/pisa-btc/apps/cli/DEPENDENCIES.md +++ b/pisa-btc/apps/cli/DEPENDENCIES.md @@ -1,7 +1,78 @@ # Dependencies -The app has the following dependencies (which can be satisfied by using `pip install -r requirements.txt`): +`pisa-cli` has both system-wide and Python dependencies. This document walks you trough how to satisfy them. -#### Cryptography -`cryptography` +## System-wide dependencies +`pisa-cli` has the following system-wide dependencies: + +- `python3` +- `pip3` + +### Checking if the dependencies are already satisfied + +Most UNIX systems ship with `python3` already installed, whereas OSX systems tend to ship with `python2`. In order to check our python version we should run: + + python --version + +For what we will get something like: + + Python 2.X.X + +Or + + Python 3.X.X + +It is also likely that, if `python3` is installed in our system, the `python` alias is not set to it but instead to `python2`. In order to check so, we can run: + + python3 --version + +If `python3` is installed but the `python` alias is not set to it, we should either set it, or use `python3` to run `pisa-cli`. + +Regarding `pip`, we can check what version is installed in our system (if any) by running: + + pip --version + +For what we will get something like: + + pip X.X.X from /usr/local/lib/python2.X/dist-packages/pip (python 2.X) + +Or + + pip X.X.X from /usr/local/lib/python3.X/dist-packages/pip (python 3.X) + +A similar thing to the `python` alias applies to the `pip` alias. We can check if pip3 is install by running: + + pip3 --version + +And, if it happens to be installed, change the alias to `pip3`, or use `pip3` instead of `pip`. + + +### Installing the dependencies + +`python3` ca be downloaded from the [Python official website](https://www.python.org/downloads/) or installed using a package manager, depending on your distribution. Examples for both UNIX-like and OSX systems are provided. + +#### Ubuntu + +`python3` can be installed using `apt` as follows: + + sudo apt-get update + sudo apt-get install python3 + +and for `pip3`: + + sudo apt-get install python3-pip + +#### OSX + +`python3` can be installed using `Homebriew` as follows: + + brew install python3 + +`pip3` will be installed alongside `python3` in this case. + +## Python dependencies + +`pisa-cli` has the following dependencies (which can be satisfied by using `pip install -r requirements.txt`): + +- `cryptography` \ No newline at end of file diff --git a/pisa-btc/apps/cli/INSTALL.md b/pisa-btc/apps/cli/INSTALL.md new file mode 100644 index 0000000..007fcf2 --- /dev/null +++ b/pisa-btc/apps/cli/INSTALL.md @@ -0,0 +1,20 @@ +# Install + +`pisa-cli` has some dependencies that can be satisfied by following [DEPENDENCIES.md](DEPENDENCIES.md). If your system already satisfies the dependencies, you can skip that part. + +In order to run `pisa-cli`, you should set your `PYTHONPATH` env variable to include the folder that contains the `apps` folder. You can do so by running: + + export PYTHONPATH=$PYTHONPATH: + +For example, for user alice running a UNIX system and having `apps` in her home folder, she would run: + + export PYTHONPATH=$PYTHONPATH:/home/alice/ + +You should also include the command in your `.bash_rc` to avoid having to run it every time you open a new terminal. You can do it by running: + + echo 'export PYTHONPATH=$PYTHONPATH:' >> ~/.bash_rc + +Once the `PYTHONPATH` is set, you should be able to run `pisa-cli` straightaway. Try it by running: + + cd /apps/cli + python pisa-cli.py -h \ No newline at end of file diff --git a/pisa-btc/apps/cli/README.md b/pisa-btc/apps/cli/README.md index 7e9f45a..1e4020b 100644 --- a/pisa-btc/apps/cli/README.md +++ b/pisa-btc/apps/cli/README.md @@ -1,8 +1,15 @@ ## pisa-cli -`pisa-cli` is a command line interface to interact with the PISA server. +`pisa-cli` is a command line interface to interact with the PISA server, written in Python3. -#### Usage +### Dependencies +Refer to [DEPENCENCIES.md](DEPENCENCIES.md) + +### Installation + +Refer to [INSTALL.md](INSTALL.md) + +### Usage python pisa-cli.py [global options] command [command options] [arguments] @@ -119,8 +126,8 @@ Run: Shows the list of commands or help about how to run a specific command. #### Usage - python pisa-cli help command + python pisa-cli help or - python pisa-cli command -h \ No newline at end of file + python pisa-cli help command \ No newline at end of file diff --git a/pisa-btc/apps/cli/pisa-cli.py b/pisa-btc/apps/cli/pisa-cli.py index 9d49f5d..a32db2c 100644 --- a/pisa-btc/apps/cli/pisa-cli.py +++ b/pisa-btc/apps/cli/pisa-cli.py @@ -8,9 +8,9 @@ from sys import argv from getopt import getopt, GetoptError from hashlib import sha256 from binascii import unhexlify -from apps.cli.blob import Blob from requests import ConnectTimeout, ConnectionError from apps.cli import DEFAULT_PISA_API_SERVER, DEFAULT_PISA_API_PORT, CLIENT_LOG_FILE +from apps.cli.blob import Blob from apps.cli.help import help_add_appointment, help_get_appointment @@ -211,6 +211,8 @@ if __name__ == '__main__': else: sys.exit("Unknown command. Use help to check the list of available commands.") + else: + sys.exit("No command provided. Use help to check the list of available commands.") except GetoptError as e: print(e)