diff --git a/ee/core/aptget.py b/ee/core/aptget.py index aa64c8c0..bcaa16c0 100644 --- a/ee/core/aptget.py +++ b/ee/core/aptget.py @@ -1,20 +1,48 @@ """EasyEngine package installation using apt-get module.""" +import apt +import sys -Class EEAptGet(): + +class EEAptGet: """Generice apt-get intialisation""" - def __init__(): - # TODO Common method of apt-get module - pass + + def __init__(self): + self.cache = apt.cache.Cache() """Installation of packages""" - def install(): - # TODO Method to install packages + def update(self): + self.cache.update() pass + """Installation of packages""" + def install(self, packages): + pkg = self.cache[packages] + if pkg.is_installed: + print("pkg already installed") + else: + pkg.mark_install() + try: + self.cache.commit(apt.progress.TextFetchProgress(), + apt.progress.InstallProgress()) + + except Exception as e: + print("Sorry, package installation failed [{err}]" + .format(err=str(e))) + """Removal of packages""" - def remove(): - # TODO Method to remove packages - pass + def remove(self, packages): + pkg = self.cache[packages] + if pkg.is_installed: + pkg.mark_delete() + try: + self.cache.commit() + + except Exception as e: + print("Sorry, package installation failed [{err}]" + .format(err=str(e))) + + else: + print("pkg not installed") """Purging of packages""" def purge():