From 00e6f25071c376ac863ae9bf7124df51652633ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Qui=C3=B1ones?= Date: Fri, 6 Sep 2019 11:43:01 -0300 Subject: [PATCH] system: Add method to check if an app is installed This is implemented as a workaround for now, checking the output of the flatpak command. https://github.com/flatpak/xdg-desktop-portal/issues/283 --- eosclubhouse/system.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/eosclubhouse/system.py b/eosclubhouse/system.py index c3a8b23d0..8aa61ce33 100644 --- a/eosclubhouse/system.py +++ b/eosclubhouse/system.py @@ -21,6 +21,7 @@ import configparser import os import shutil +import subprocess import time from eosclubhouse import logger @@ -438,6 +439,15 @@ def get_gtk_launch_app_proxy(self): def is_running(self): return self.get_gtk_app_proxy().props.g_name_owner is not None + def is_installed(self): + '''Check if the app is installed. + + Note: This only works for apps distributed as flatpaks. + ''' + result = subprocess.run(['/usr/bin/flatpak-spawn', '--host', + 'flatpak', 'info', '--show-ref', self.dbus_name]) + return result.returncode == 0 + def get_object_property(self, obj, prop): return self.get_clippy_proxy().Get('(ss)', obj, prop)