Skip to content

Instantly share code, notes, and snippets.

@RyuzakiKK
Created September 11, 2018 09:31
Show Gist options
  • Save RyuzakiKK/99511b7f012da426ecd957f0cf24ca67 to your computer and use it in GitHub Desktop.
Save RyuzakiKK/99511b7f012da426ecd957f0cf24ca67 to your computer and use it in GitHub Desktop.
seahorse import from dbus+flatpak test

Run

$ flatpak-builder build-dir org.flatpak.SeaTest.json --force-clean
$ flatpak-builder --run build-dir org.flatpak.SeaTest.json dbus-test.py
#!/usr/bin/python3
import sys
import dbus
bus = dbus.SessionBus()
print("SEAHORSE DBUS CALL")
proxy_obj = bus.get_object('org.gnome.seahorse', '/org/gnome/seahorse/keys')
service = dbus.Interface(proxy_obj, 'org.gnome.seahorse.KeyService')
types = service.GetKeyTypes()
# This is just an openpgp key type
print("GetKeyTypes(): ", types)
if not len(types):
print("No key types found")
sys.exit(0)
path = service.GetKeyset(types[0])
print("GetKeySet(): ", path)
proxy_obj = bus.get_object('org.gnome.seahorse', path)
keyset = dbus.Interface(proxy_obj, "org.gnome.seahorse.Keys")
data = """-----BEGIN PGP PUBLIC KEY BLOCK-----
mI0EW5eD7wEEALoS2l3a9+4F9me4tmoSLC5NKaN02aEurcYega5iXOysFh8BCZOO
oD1D8JDCI4cHujnT5So2+IJdjfh746mssa8wFZnPgw4Ql9Kc62L/NhghPiti+e8/
auws1alR/TD3C87Y84MeQERVKFF5+qF3EcTwrGFnzjrXq0nGrSE2J7OLABEBAAG0
GWRidXN0ZXN0IDxkYnVzQHRlc3QudGVzdD6IzgQTAQgAOBYhBDqD5uRpNXGYke+U
RfYfzhdIgH4MBQJbl4PvAhsDBQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEPYf
zhdIgH4M4bEEAKkmLigCvveB2fmVk1StgHplBIBWXzvmoTE0mJUzvmLbOlkboNeB
CC2fMMPe7NI7BEQoYY7TGVwqr5GLAW6gx46j1+CykWu+YUIRe2wNu46KilNEDT69
ccSXj8OW7B+RYdLaGJY2lTE3P3URebfPSLKhgBG85Gi9VI7HYPdtIt1buI0EW5eD
7wEEANWVqiRFFvarn3SQYJmOu4wdID8dMnqaLL+75BiICzd100eSm3rXfxdsHigi
9tghO08autxffz0TCnmde//rXsLWzFjYD+vhmJnI00AJFTifBjUQY1nMehKseHfS
1/mc/KqXg4H3uDR10V6FL8Wr/7p1LcWpVIamRLoCMWr5SeR/ABEBAAGItgQYAQgA
IBYhBDqD5uRpNXGYke+URfYfzhdIgH4MBQJbl4PvAhsMAAoJEPYfzhdIgH4MorYD
+wT6C3fAVc/uSp9ndxABoZsMXdVfPLRgtYuruVUOHWv+BKpuDTwnINEYYWvaabDk
VAtSmgAjuFxnWJR7no+kUtvmahYmYI61uoluwhSw/NYZjm3/ovnkoit2K6l/i7X8
0miFhY/0HO6Upa/poZoibp4htPHYX5mF/o4oA0Z7G7F0
=6tPX
-----END PGP PUBLIC KEY BLOCK-----
"""
print("IMPORT")
res = service.ImportKeys(types[0], data)
print(res)
# keys = keyset.ListKeys()
# if not len(keys):
# print("No keys found")
# sys.exit(0)
# for i in range(len(keys)):
# print(keys[i])
# print(keyset.GetKeyField(keys[i], "display-name"))
# print(keyset.GetKeyFields(keys[i], ["display-name", "raw-id", "fingerprint"]))
# print(service.ExportKeys("openpgp", [keys[i]]))
{
"app-id": "org.flatpak.SeaTest",
"runtime": "org.gnome.Platform",
"runtime-version": "3.28",
"sdk": "org.gnome.Sdk",
"command": "dbus-test.py",
"finish-args" : [
"--talk-name=org.gnome.seahorse"
],
"modules": [
{
"name": "python3-dbus-python",
"buildsystem": "simple",
"ensure-writable": [
"easy-install.pth",
"setuptools.pth"
],
"build-commands": [
"pip3 install --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} dbus-python"
],
"sources": [
{
"type": "file",
"url": "https://files.pythonhosted.org/packages/3f/e7/4edb582d1ffd5ac3c84188deea32e960b5c8c0fe1da56ce70224f85ce542/dbus-python-1.2.8.tar.gz",
"sha256": "abf12bbb765e300bf8e2a1b2f32f85949eab06998dbda127952c31cb63957b6f"
}
]
},
{
"name": "dbus-test",
"buildsystem": "simple",
"build-commands": [
"install -D dbus-test.py /app/bin/dbus-test.py"
],
"sources": [
{
"type": "file",
"path": "dbus-test.py"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment