Commit 5b0c9dc9 authored by David Seaward's avatar David Seaward
Browse files

Create debug command with dependencies. Remove liberty.py from build configuration.


Signed-off-by: David Seaward's avatarDavid Seaward <david.seaward@puri.sm>
parent 55f8ad30
......@@ -30,11 +30,11 @@
},
"click": {
"hashes": [
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
"sha256:8a18b4ea89d8820c5d0c7da8a64b2c324b4dabb695804dbfea19b9be9d88c0cc",
"sha256:e345d143d80bf5ee7534056164e5e112ea5e22716bbb1ce727941f4c8b471b9a"
],
"index": "pypi",
"version": "==7.0"
"version": "==7.1.1"
},
"distro": {
"hashes": [
......@@ -59,10 +59,10 @@
},
"pygobject": {
"hashes": [
"sha256:2acb0daf2b3a23a90f52066cc23d1053339fee2f5f7f4275f8baa3704ae0c543"
"sha256:b97f570e55017fcd3732164811f24ecf63983a4834f61b55b0aaf64ecefac856"
],
"index": "pypi",
"version": "==3.34.0"
"version": "==3.36.0"
},
"requests": {
"hashes": [
......@@ -178,11 +178,11 @@
},
"click": {
"hashes": [
"sha256:2335065e6395b9e67ca716de5f7526736bfa6ceead690adf616d925bdc622b13",
"sha256:5b94b49521f6456670fdb30cd82a4eca9412788a93fa6dd6df72c94d5a8ff2d7"
"sha256:8a18b4ea89d8820c5d0c7da8a64b2c324b4dabb695804dbfea19b9be9d88c0cc",
"sha256:e345d143d80bf5ee7534056164e5e112ea5e22716bbb1ce727941f4c8b471b9a"
],
"index": "pypi",
"version": "==7.0"
"version": "==7.1.1"
},
"cryptography": {
"hashes": [
......@@ -246,17 +246,18 @@
},
"jeepney": {
"hashes": [
"sha256:0ba6d8c597e9bef1ebd18aaec595f942a264e25c1a48f164d46120eacaa2e9bb",
"sha256:6f45dce1125cf6c58a1c88123d3831f36a789f9204fbad3172eac15f8ccd08d0"
"sha256:3479b861cc2b6407de5188695fa1a8d57e5072d7059322469b62628869b8e36e",
"sha256:d6c6b49683446d2407d2fe3acb7a368a77ff063f9182fe427da15d622adc24cf"
],
"version": "==0.4.2"
"markers": "sys_platform == 'linux'",
"version": "==0.4.3"
},
"keyring": {
"hashes": [
"sha256:1f393f7466314068961c7e1d508120c092bd71fa54e3d93b76180b526d4abc56",
"sha256:24ae23ab2d6adc59138339e56843e33ec7b0a6b2f06302662477085c6c0aca00"
"sha256:b7bdfb1978cfdbabec63a3d389ad60242e7ffe9d739cae00760408c4f07d2c13",
"sha256:ebce8a4acfcabbcdfdcae2fc58571cebf11f71262cca898edceef89cdc891898"
],
"version": "==21.1.0"
"version": "==21.1.1"
},
"pkginfo": {
"hashes": [
......@@ -273,23 +274,24 @@
},
"pycparser": {
"hashes": [
"sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3"
"sha256:2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0",
"sha256:7582ad22678f0fcd81102833f60ef8d0e57288b6b5fb00323d101be910e35705"
],
"version": "==2.19"
"version": "==2.20"
},
"pygments": {
"hashes": [
"sha256:2a3fe295e54a20164a9df49c75fa58526d3be48e14aceba6d6b1e8ac0bfd6f1b",
"sha256:98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe"
"sha256:647344a061c249a3b74e230c739f434d7ea4d8b1d5f3721bc0f3558049b38f44",
"sha256:ff7a40b4860b727ab48fad6360eb351cc1b33cbf9b15a0f689ca5353e9463324"
],
"version": "==2.5.2"
"version": "==2.6.1"
},
"pygobject": {
"hashes": [
"sha256:2acb0daf2b3a23a90f52066cc23d1053339fee2f5f7f4275f8baa3704ae0c543"
"sha256:b97f570e55017fcd3732164811f24ecf63983a4834f61b55b0aaf64ecefac856"
],
"index": "pypi",
"version": "==3.34.0"
"version": "==3.36.0"
},
"readme-renderer": {
"hashes": [
......
......@@ -52,3 +52,101 @@ def prompt_for_credentials():
passphrase = getpass(PASSPHRASE_PROMPT)
return LdhCredential(user, host, passphrase)
def get_accounts_from_goa():
try:
import gi
gi.require_version('Goa', '1.0')
except ValueError:
raise ImportError('GOA library not available')
from gi.repository import Goa
client = Goa.Client.new_sync()
return client.get_accounts()
def count_goa_credentials():
count = 0
try:
accounts = get_accounts_from_goa()
for objprx in accounts:
accprx = objprx.get_account()
if accprx.props.provider_type == 'librem_one':
count += 1
except Exception:
count = -1
return count
def get_single_goa_credential():
"""Query GOA for valid credentials."""
user = None
host = None
passphrase = None
accounts = get_accounts_from_goa()
count = 0
for objprx in accounts:
accprx = objprx.get_account()
if accprx.props.provider_type == 'librem_one':
count += 1
address = accprx.props.identity
(user, host) = address.split("@")
pbobj = objprx.get_password_based()
passphrase = pbobj.call_get_password_sync('password')
if count == 0:
raise ValueError("No GOA credentials found.")
elif count > 1:
raise ValueError("Too many GOA credentials found.")
return LdhCredential(user, host, passphrase)
def get_rclone_version():
"""Extract version number from rclone, if it is available."""
try:
import sh
from sh import rclone
from io import StringIO
buffer = StringIO()
try:
rclone("--version", _out=buffer)
except sh.ErrorReturnCode_252:
pass
return buffer.getvalue()
except Exception:
return "None"
def get_yad_version():
"""Extract version number from yad, if it is available."""
try:
import sh
from sh import yad
from io import StringIO
buffer = StringIO()
try:
yad("--version", _out=buffer)
except sh.ErrorReturnCode_252:
pass
return buffer.getvalue()
except Exception:
return "None"
......@@ -24,18 +24,25 @@ def debug():
import platform
import distro
import os
import ldh_client.common
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)
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(" ", " ")
path = "$PATH " + os.environ["PATH"].replace(os.environ["HOME"], "~")
goa_accounts = "GOA accounts " + str(ldh_client.common.count_goa_credentials())
print(package_version)
print(python_version)
print(platform_version)
print(distro_version)
print(rclone_version)
print(yad_version)
print(path)
print(goa_accounts)
@cli.command(name="tunnel_setup")
......
[metadata]
name = ldh_client
version = 0.0.7
version = 0.0.8
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
......@@ -25,7 +25,7 @@ install_requires =
ruamel.yaml >=0.15.34, <1.0
sh >=1.12.14, <2.0
PyGObject >=3.32.0, <4.0
scripts = liberty.py
# scripts = liberty.py
[options.entry_points]
console_scripts =
......
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