def install_app(app, sudo_pwd=None, gui=True): pkgs = " ".join(app["packages"] + app["dependencies"]) cmd = "" if gui: cmd = "rxvt -title 'Installing {}' -e bash -c ".format(app["title"]) if sudo_pwd: cleanup_cmd = "echo {} | sudo -S dpkg --configure -a".format(sudo_pwd) update_cmd = "echo {} | sudo -S apt-get update".format(sudo_pwd) run = "echo {} | sudo -S apt-get install -y {}".format(sudo_pwd, pkgs) else: cleanup_cmd = "sudo dpkg --configure -a".format(sudo_pwd) update_cmd = "sudo apt-get update".format(sudo_pwd) run = "sudo apt-get install -y {}".format(pkgs) if gui: run = "'{}'".format(run) cmd += run # make sure there are no broken packages on the system run_cmd(cleanup_cmd) run_cmd(update_cmd) os.system(cmd) done = True installed_packages = get_dpkg_dict()[0] for pkg in app["packages"] + app["dependencies"]: if pkg not in installed_packages: done = False break return done
def uninstall_packages(app, sudo_pwd=None): if len(app["packages"]) == 0: return True pkgs = " ".join(app["packages"]) cmd = ("rxvt -title " + _("'Uninstalling {}'") + " -e bash -c ").format(app["title"]) if sudo_pwd: cmd += "'echo {} | sudo -S apt-get purge -y {}'".format(sudo_pwd, pkgs) else: cmd += "'sudo apt-get purge -y {}'".format(pkgs, sudo_pwd) os.system(cmd.encode('utf8')) done = True installed_packages = get_dpkg_dict()[0] for pkg in app["packages"]: if pkg in installed_packages: done = False break return done
def refresh_package_list(): """ Reload the cached list of installed packages. """ global _INSTALLED_PKGS _INSTALLED_PKGS = get_dpkg_dict()[0]
# Which apps to look for on the system import os import re import json from kano_settings.system.locale import get_locale, ensure_utf_locale from kano_apps.utils import get_dpkg_dict from kano_i18n.init import get_current_translation # The system directory that contains *.app and *.desktop entries _SYSTEM_APPLICATIONS_LOC = '/usr/share/applications/' # Store the package list globally so it doesn't get parsed every time # we query for applications - it takes some time to parse it. _INSTALLED_PKGS = get_dpkg_dict()[0] def refresh_package_list(): """ Reload the cached list of installed packages. """ global _INSTALLED_PKGS _INSTALLED_PKGS = get_dpkg_dict()[0] def try_exec(app): """ Searches through system path and tries executing the app in question. :param app: Application name or full absolute path. :type app: str
def refresh_package_list(): """ Reload the cached list of installed packages. """ global _INSTALLED_PKGS _INSTALLED_PKGS = get_dpkg_dict()[0]
import json from kano_settings.system.locale import get_locale, ensure_utf_locale from kano_apps.utils import get_dpkg_dict from kano_i18n.init import get_current_translation # The system directory that contains *.app and *.desktop entries _SYSTEM_APPLICATIONS_LOC = '/usr/share/applications/' DEFAULT_LOCALE = 'en_US' LOCALE_KEY = 'locale' APP_LOCALE_DIR = os.path.join(_SYSTEM_APPLICATIONS_LOC, 'locale') # Store the package list globally so it doesn't get parsed every time # we query for applications - it takes some time to parse it. _INSTALLED_PKGS = get_dpkg_dict()[0] def refresh_package_list(): """ Reload the cached list of installed packages. """ global _INSTALLED_PKGS _INSTALLED_PKGS = get_dpkg_dict()[0] def try_exec(app): """ Searches through system path and tries executing the app in question. :param app: Application name or full absolute path. :type app: str