Commit dc495960 authored by David Seaward's avatar David Seaward
Browse files

Update to version 0.0.3



* Switch from `liberty tunnel_setup` to `liberty setup tunnel`.
* Add skeleton for `liberty setup files`.
* Decompose common and default functions/values.
* Expand developer instructions in README.
Signed-off-by: David Seaward's avatarDavid Seaward <david.seaward@puri.sm>
parent 8d36c03b
# Copying notice
Liberty CLI
<https://source.puri.sm/liberty/ldh_client>
Copyright 2017-2019 Purism SPC
<https://source.puri.sm/liberty/tool/client>
Copyright 2017-2020 Purism SPC
SPDX-License-Identifier: AGPL-3.0-or-later
This program is free software: you can redistribute it and/or modify
......@@ -27,9 +27,9 @@ are listed below, and also appear in the files where that code appears.
---
Network-Manager tunnel setup code includes some code from
Network-Manager Pyhton examples: <br />
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/blob/master/examples/python/gi/vpn-import.py <br />
Copyright 2014 Red Hat, Inc.<br />
Network-Manager Python examples:
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/blob/master/examples/python/gi/vpn-import.py
Copyright 2014 Red Hat, Inc.
SPDX-License-Identifier: GPL-2.0-or-later
This program is distributed in the hope that it will be useful,
......
......@@ -10,6 +10,9 @@ sh = ">=1.12.14,<1.13.0"
[requires]
python_version = "3.7"
[dev-packages]
twine = "==1.12.1"
[dev-packages.e1839a8]
path = "."
editable = true
{
"_meta": {
"hash": {
"sha256": "f6a47165359f01b264a1357826ec33f3a488f679539c5fa1e5afe94af9661f77"
"sha256": "94e7dbcbfe2ce75d95eb5e2ef0244d9fdc67d2e78d8a36530e8a2a1f5c47d24e"
},
"pipfile-spec": 6,
"requires": {
......@@ -34,6 +34,13 @@
}
},
"develop": {
"bleach": {
"hashes": [
"sha256:44f69771e2ac81ff30d929d485b7f9919f3ad6d019b6b20c74f3b8687c3f70df",
"sha256:aa8b870d0f46965bac2c073a93444636b0e1ca74e9777e34f03dd494b8a59d48"
],
"version": "==3.1.1"
},
"certifi": {
"hashes": [
"sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3",
......@@ -56,16 +63,30 @@
"index": "pypi",
"version": "==6.7"
},
"docutils": {
"hashes": [
"sha256:0c5b78adfbf7762415433f5515cd5c9e762339e23369dbe8000d84a4bf4ab3af",
"sha256:c2de3a60e9e7d07be26b7f2b00ca0309c207e06c100f9cc2a94931fc75a478fc"
],
"version": "==0.16"
},
"e1839a8": {
"editable": true,
"path": "."
},
"idna": {
"hashes": [
"sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407",
"sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c"
"sha256:7588d1c14ae4c77d74036e8c22ff447b26d0fde8f007354fd48a7814db15b7cb",
"sha256:a068a21ceac8a4d63dbfd964670474107f541babbd2250d61922f029858365fa"
],
"version": "==2.9"
},
"pkginfo": {
"hashes": [
"sha256:7424f2c8511c186cd5424bbf31045b77435b37a8d604990b79d4e70d741148bb",
"sha256:a6d9e40ca61ad3ebd0b72fbadd4fba16e4c0e4df0428c041e01e06eb6ee71f32"
],
"version": "==2.8"
"version": "==1.5.0.1"
},
"pycairo": {
"hashes": [
......@@ -73,18 +94,39 @@
],
"version": "==1.19.1"
},
"pygments": {
"hashes": [
"sha256:2a3fe295e54a20164a9df49c75fa58526d3be48e14aceba6d6b1e8ac0bfd6f1b",
"sha256:98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe"
],
"version": "==2.5.2"
},
"pygobject": {
"hashes": [
"sha256:2acb0daf2b3a23a90f52066cc23d1053339fee2f5f7f4275f8baa3704ae0c543"
],
"version": "==3.34.0"
},
"readme-renderer": {
"hashes": [
"sha256:bb16f55b259f27f75f640acf5e00cf897845a8b3e4731b5c1a436e4b8529202f",
"sha256:c8532b79afc0375a85f10433eca157d6b50f7d6990f337fa498c96cd4bfc203d"
],
"version": "==24.0"
},
"requests": {
"hashes": [
"sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4",
"sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31"
"sha256:43999036bfa82904b6af1d99e4882b560e5e2c68e5c4b0aa03b655f3d7d73fee",
"sha256:b3f43d496c6daba4493e7c431722aeb7dbc6288f52a6e04e7b6023b0247817e6"
],
"version": "==2.22.0"
"version": "==2.23.0"
},
"requests-toolbelt": {
"hashes": [
"sha256:380606e1d10dc85c3bd47bf5a6095f815ec007be7a8b69c878507068df059e6f",
"sha256:968089d4584ad4ad7c171454f0a5c6dac23971e9472521ea3b6d49d610aa6fc0"
],
"version": "==0.9.1"
},
"sh": {
"hashes": [
......@@ -94,12 +136,41 @@
"index": "pypi",
"version": "==1.12.14"
},
"six": {
"hashes": [
"sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a",
"sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c"
],
"version": "==1.14.0"
},
"tqdm": {
"hashes": [
"sha256:0d8b5afb66e23d80433102e9bd8b5c8b65d34c2a2255b2de58d97bd2ea8170fd",
"sha256:f35fb121bafa030bd94e74fcfd44f3c2830039a2ddef7fc87ef1c2d205237b24"
],
"version": "==4.43.0"
},
"twine": {
"hashes": [
"sha256:7d89bc6acafb31d124e6e5b295ef26ac77030bf098960c2a4c4e058335827c5c",
"sha256:fad6f1251195f7ddd1460cb76d6ea106c93adb4e56c41e0da79658e56e547d2c"
],
"index": "pypi",
"version": "==1.12.1"
},
"urllib3": {
"hashes": [
"sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc",
"sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc"
],
"version": "==1.25.8"
},
"webencodings": {
"hashes": [
"sha256:a0af1213f3c2226497a97e2b3aa01a7e4bee4f403f95be16fc9acd2947514a78",
"sha256:b36a1c245f2d304965eb4e0a82848379241dc04b865afcc4aab16748587e1923"
],
"version": "==0.5.1"
}
}
}
......@@ -3,34 +3,36 @@
[project] | [code] | [tracker]
*Liberty CLI* is a user-facing command-line client for interacting
with a Liberty Deckplan Host (LDH).
with Librem One or another Liberty Deckplan Host (LDH).
Dive into https://liberty.one for LDH design and development.
## Installation
The preferred way to install Liberty CLI is with your package
manager. The recommended package name is `ldh_client`. For example:
manager. The recommended package name is `ldh-client`. For example:
sudo apt install ldh-client # Debian-based (doesn't exist yet)
or
pipx install ldh-client
pipx install ldh-client # Python-based
## Usage
Get help
For help and a list of available commands:
```bash
liberty --help
```
Add Librem One tunnel VPN to your Network-Manager connections:
To add a tunnel connection to Network-Manager:
```bash
liberty tunnel-setup
liberty setup tunnel
# you will be prompted for your Librem One/LDH credentials
```
I will ask your Librem One username and password.
## Installation (from source)
If you'd prefer to run from source...
......@@ -38,13 +40,16 @@ If you'd prefer to run from source...
1. Install Python 3.x and pipenv. (See
<https://docs.pipenv.org/install/> for a tutorial.)
2. Get source:
2. Install prerequisites:
git clone https://source.puri.sm/liberty/ldh_client.git
apt-get install libcairo2-dev libgirepository1.0-dev
3. Install with pipenv:
3. Get source:
git clone https://source.puri.sm/liberty/tool/client.git ldh_client
4. Install with pipenv:
apt-get install libcairo2-dev libgirepository1.0-dev
cd ldh_client
pipenv install --dev -e .
......@@ -55,11 +60,45 @@ cd ldh_client
pipenv run liberty --help
```
or
```bash
cd ldh_client
pipenv shell
liberty --help
```
## Build wheel package (and optionally upload)
Follow these instructions to build Liberty CLI as a Python package:
```
$ git clone https://source.puri.sm/liberty/tool/client.git ldh_client
$ cd ldh_client
$ pipenv install --dev
$ pipenv shell
$ # optionally edit defaults.py
$ python setup.py sdist bdist_wheel
```
If everything works as expected you should end up with the files:
* `ldh_client-<version>-py3-none-any.whl`
* `ldh_client-<version>.tar.gz`
under `dist/` folder.
You can now optionally upload the created Python package to PyPI using twine:
```
$ twine upload dist/*
```
## Sharing and contributions
Liberty CLI (LDH client)
<https://source.puri.sm/liberty/ldh_client>
Copyright 2018-2019 Purism SPC
<https://source.puri.sm/liberty/tool/client>
Copyright 2018-2020 Purism SPC
SPDX-License-Identifier: AGPL-3.0-or-later
Shared under AGPL-3.0-or-later. We adhere to the Community Covenant
......@@ -74,9 +113,9 @@ For details see:
<!-- Links -->
[project]: https://source.puri.sm/liberty/ldh_client
[code]: https://source.puri.sm/liberty/ldh_client/tree/master
[tracker]: https://source.puri.sm/liberty/ldh_client/issues
[project]: https://source.puri.sm/liberty/tool/client
[code]: https://source.puri.sm/liberty/tool/client/tree/master
[tracker]: https://source.puri.sm/liberty/tool/client/issues
[SETUP.md]: SETUP.md
[COPYING.AGPL.md]: COPYING.AGPL.md
[CODE_OF_CONDUCT.md]: CODE_OF_CONDUCT.md
......
......@@ -4,6 +4,10 @@
import re
from getpass import getpass
from scripts import defaults
# define strings that use defaults
prompt_string = "Enter your " + defaults.HOST_LABEL + " address: "
class LdhCredential(object):
......@@ -35,7 +39,7 @@ def prompt_for_credentials():
valid_address = False
while not valid_address:
address = input("Enter your Librem One address: ")
address = input(prompt_string)
regex = r"^[A-Za-z][A-Za-z0-9]*@[A-Za-z0-9]+(\.[A-Za-z0-9]+)+$"
if not re.match(regex, address):
print(address + " is not a valid email address.")
......
#!/usr/bin/env python3
# Copyright 2017-2020 Purism SPC
# SPDX-License-Identifier: AGPL-3.0-or-later
# These default strings appear in user-facing prompts.
# The user can enter any address/host they want.
HOST_LABEL = "Librem One"
HOST_DOMAIN = "librem.one"
#!/usr/bin/env python3
# Copyright 2017-2020 Purism SPC
# SPDX-License-Identifier: AGPL-3.0-or-later
import click
from scripts.nm_tunnel_setup import nm_tunnel_setup
from scripts.nautilus_files_setup import nautilus_files_setup
......@@ -6,11 +10,17 @@ from scripts.nautilus_files_setup import nautilus_files_setup
@click.group()
@click.pass_context
def cli(ctx):
"""Liberty CLI is a command line tool for interacting with Librem
One and other Liberty Domain Hosts (LDHs)."""
"""Liberty CLI is a user-facing command-line client for interacting with
Librem One or another Liberty Deckplan Host (LDH)."""
pass
@cli.command()
def tunnel_setup():
"""This command is deprecated. Please use `liberty setup tunnel` instead."""
print("This command is deprecated. Please use `liberty setup tunnel` instead.")
@cli.group()
def setup():
"""Configure or reconfigure services on an XDG desktop."""
......@@ -27,3 +37,23 @@ def tunnel_setup():
def files_setup():
"""Create mountpoint for files."""
nautilus_files_setup()
# @set.command(name="default")
# def default_get():
# ...
#
#
# @set.command(name="default")
# def default_set():
# ...
#
#
# @set.command(name="passphrase")
# def passphrase_set():
# ...
#
#
# @get.command(name="passphrase")
# def passphrase_get():
# ...
#!/usr/bin/env python3
# Copyright 2017-2019 Purism SPC
# Copyright 2017-2020 Purism SPC
# SPDX-License-Identifier: AGPL-3.0-or-later
import sh
from scripts.common import *
import sys
from scripts import common
def nautilus_files_setup():
credentials = prompt_for_credentials()
print(sh.echo("Hello world!"))
print("This feature is not yet implemented.")
sys.exit(1)
# credentials = common.prompt_for_credentials()
#!/usr/bin/env python3
# Copyright 2017-2019 Purism SPC
# Copyright 2017-2020 Purism SPC
# SPDX-License-Identifier: AGPL-3.0-or-later
# Original file from Network-Manager Python examples
......@@ -16,7 +16,7 @@ from json.decoder import JSONDecodeError
gi.require_version("NM", "1.0")
from gi.repository import NM, GLib
from scripts.common import *
from scripts import common
PROTO = "https://"
PATH = "/api/v1/user/tunnel_account"
......@@ -33,7 +33,7 @@ def nm_tunnel_setup():
"""
# Get tunnel credentials
credentials = prompt_for_credentials()
credentials = common.prompt_for_credentials()
url = PROTO + credentials.host + PATH
try:
......@@ -50,7 +50,7 @@ def nm_tunnel_setup():
else:
print("\nSomething went wrong when connecting to", url)
try:
detail = r.json().get("detail", "No detail available")
detail = r.json().get("detail", "No detail available.")
except JSONDecodeError as e:
detail = r.reason
print("Problem details:", detail)
......@@ -117,7 +117,7 @@ def nm_tunnel_setup():
def added_cb(client, result, data):
try:
client.add_connection_finish(result)
print("Librem One Tunnel successfully added to NetworkManager.")
print("Tunnel successfully added to NetworkManager.")
except Exception as e:
print("ERROR: failed to add connection: %s\n" % e)
main_loop.quit()
......@@ -125,7 +125,3 @@ def nm_tunnel_setup():
client.add_connection_async(new_con, True, None, added_cb, None)
main_loop.run()
if __name__ == "__main__":
nm_tunnel_setup()
[metadata]
name = ldh_client
version = 0.0.2
description = Liberty CLI is a user-facing command-line client for interacting with a Liberty Deckplan Host (LDH).
version = 0.0.3
description = Liberty CLI is a user-facing command-line client for interacting with Librem One or another Liberty Deckplan Host (LDH).
long_description = file: README.md
long_description_content_type = text/markdown; charset=UTF-8
license = AGPL-3.0-or-later
author = Purism SPC
author_email = doublerainbows@librem.one
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment