liberty.py 2.28 KB
Newer Older
David Seaward's avatar
David Seaward committed
1 2 3 4
#!/usr/bin/env python3
# Copyright 2017-2020 Purism SPC
# SPDX-License-Identifier: AGPL-3.0-or-later

5
import click
6 7
from ldh_client.nm_tunnel_setup import nm_tunnel_setup
from ldh_client.nautilus_files_setup import nautilus_files_setup
8 9 10


@click.group()
11 12
@click.pass_context
def cli(ctx):
David Seaward's avatar
David Seaward committed
13 14
    """Liberty CLI is a user-facing command-line client for interacting with
    Librem One or another Liberty Deckplan Host (LDH)."""
15 16 17
    pass


David Seaward's avatar
David Seaward committed
18
@cli.command()
19
def debug():
20
    """Display debug info, useful in bug reports."""
21 22 23 24 25 26

    import pkg_resources
    import sys
    import platform
    import distro
    import os
27
    import ldh_client.common
28 29 30 31 32

    package_version = pkg_resources.require("ldh_client")[0]
    python_version = "Python " + sys.version.replace("\n", " ").replace("  ", " ")
    platform_version = "Platform " + platform.platform()
    distro_version = "Distribution " + distro.name(pretty=True)
33 34
    rclone_version = "rclone " + ldh_client.common.get_rclone_version().replace("\n", " ").replace("  ", " ").replace("rclone ", "")
    yad_version = "YAD " + ldh_client.common.get_yad_version().replace("\n", " ").replace("  ", " ")
35
    path = "$PATH " + os.environ["PATH"].replace(os.environ["HOME"], "~")
36
    goa_accounts = "GOA accounts " + str(ldh_client.common.count_goa_credentials())
37 38 39 40 41

    print(package_version)
    print(python_version)
    print(platform_version)
    print(distro_version)
42 43
    print(rclone_version)
    print(yad_version)
44
    print(path)
45
    print(goa_accounts)
46 47 48 49


@cli.command(name="tunnel_setup")
def old_tunnel_setup():
David Seaward's avatar
David Seaward committed
50 51 52 53
    """This command is deprecated. Please use `liberty setup tunnel` instead."""
    print("This command is deprecated. Please use `liberty setup tunnel` instead.")


54 55 56 57 58 59 60
@cli.group()
def setup():
    """Configure or reconfigure services on an XDG desktop."""
    pass


@setup.command(name="tunnel")
61
def tunnel_setup():
62
    """Download tunnel config and add to NetworkManager."""
63
    nm_tunnel_setup()
David Seaward's avatar
David Seaward committed
64 65


66
@setup.command(name="files")
David Seaward's avatar
David Seaward committed
67 68 69
def files_setup():
    """Create mountpoint for files."""
    nautilus_files_setup()
David Seaward's avatar
David Seaward committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89


# @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():
#     ...