From eed683fabf55b09d8eead2c33bffdee7ca64ff77 Mon Sep 17 00:00:00 2001 From: cemrealpsoy Date: Wed, 20 Jul 2016 16:23:50 +0300 Subject: [PATCH] util.py remove_package added --- opt/ahenk/base/util/util.py | 23 +++++++++++++++++++---- opt/ahenk/plugins/package-manager | 1 - 2 files changed, 19 insertions(+), 5 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 4925481..1dcf6fd 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 @@ -267,4 +283,3 @@ class Util: command = "sudo apt-get --yes --force-yes purge {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