From 890b3ffa413d27a717319b906517fd1977e8dd14 Mon Sep 17 00:00:00 2001 From: "emre.akkaya" Date: Wed, 20 Jul 2016 16:10:52 +0300 Subject: [PATCH] bug fix for install/uninstall util methods & remove redundant symbolic link --- opt/ahenk/base/util/util.py | 29 +++++++++++++++++++---------- opt/ahenk/plugins/package-manager | 1 - 2 files changed, 19 insertions(+), 11 deletions(-) delete mode 120000 opt/ahenk/plugins/package-manager diff --git a/opt/ahenk/base/util/util.py b/opt/ahenk/base/util/util.py index 48b0f83..a5da88a 100644 --- a/opt/ahenk/base/util/util.py +++ b/opt/ahenk/base/util/util.py @@ -201,10 +201,26 @@ class Util: raise @staticmethod - def install_with_apt_get(package_name): + def install_with_apt_get(package_name, package_version=None): try: - process = subprocess.Popen('apt-get install --yes --force-yes ' + package_name, shell=True) - process.wait() + if package_version is not None: + process = subprocess.Popen('apt-get install --yes --force-yes {0}={1}'.format(package_name, package_version), shell=True) + process.wait() + else: + process = subprocess.Popen('apt-get install --yes --force-yes {0}'.format(package_name), shell=True) + process.wait() + except: + raise + + @staticmethod + def uninstall_package(package_name, package_version=None): + try: + if package_version is not None: + process = subprocess.Popen('apt-get purge --yes --force-yes {0}={1}'.format(package_name, package_version), shell=True) + process.wait() + else: + process = subprocess.Popen('apt-get purge --yes --force-yes {0}'.format(package_name), shell=True) + process.wait() except: raise @@ -255,10 +271,3 @@ class Util: if attr_name in j: return True return False - - @staticmethod - def install_package(package_name, package_version): - command = "sudo apt-get --yes --force-yes install {0}={1}".format(package_name, package_version) - result_code, p_out, p_err = Util.execute(command) - return result_code, p_out, p_err - diff --git a/opt/ahenk/plugins/package-manager b/opt/ahenk/plugins/package-manager deleted file mode 120000 index e4cd6ea..0000000 --- a/opt/ahenk/plugins/package-manager +++ /dev/null @@ -1 +0,0 @@ -/home/cemre/git/lider-ahenk-package-manager-plugin/ahenk-package-manager/package-manager \ No newline at end of file