From 7663afc3a950d020500c1233fdd7b3ef1f01fcf2 Mon Sep 17 00:00:00 2001 From: Laurence Miao Date: Thu, 4 Oct 2012 13:27:58 +0800 Subject: [PATCH] virtualenv quite installation for zypper * tools/install_venv.py Added new class Suse Change-Id: I4629ca683edcd07f5707fe015bfc58bf904209f2 --- tools/install_venv.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tools/install_venv.py b/tools/install_venv.py index 725810a0c..ecfc93eae 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -144,10 +144,35 @@ class Fedora(Distro): super(Fedora, self).install_virtualenv() +class Suse(Distro): + """This covers all SuSE distributions.""" + + def check_pkg(self, pkg): + return run_command_with_code(['rpm', '-q', pkg], + check_exit_code=False)[1] == 0 + + def zypper_install(self, pkg, **kwargs): + run_command(['sudo', 'zypper', '-qn', 'install', pkg], **kwargs) + + def apply_patch(self, originalfile, patchfile): + run_command(['patch', originalfile, patchfile]) + + def install_virtualenv(self): + if self.check_cmd('virtualenv'): + return + + if not self.check_pkg('python-virtualenv'): + self.zypper_install('python-virtualenv', check_exit_code=False) + + super(Suse, self).install_virtualenv() + + def get_distro(): if (os.path.exists('/etc/fedora-release') or os.path.exists('/etc/redhat-release')): return Fedora() + elif os.path.exists('/etc/SuSE-release'): + return Suse() elif os.path.exists('/etc/debian_version'): return Debian() else: