diff options
author | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-14 17:17:49 (GMT) |
---|---|---|
committer | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-11-14 17:17:49 (GMT) |
commit | 4526b912b1e35bfad217a7d4068c7d35b48c7f09 (patch) | |
tree | 6a4bcbf1c9ee746e5877d7d9c8ec71f2c61efd37 /devbot/distro.py | |
parent | 35cd6c621138516926a04f0359ebf2a596d26fbd (diff) |
Factor out installing packages
Diffstat (limited to 'devbot/distro.py')
-rw-r--r-- | devbot/distro.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/devbot/distro.py b/devbot/distro.py index 34f54bc..fe2522d 100644 --- a/devbot/distro.py +++ b/devbot/distro.py @@ -1,5 +1,29 @@ import subprocess +from devbot import command + +class FedoraPackageManager: + def install_packages(self, packages): + args = ["yum", "install"] + args.extend(packages) + + command.run_with_sudo(args) + +class UbuntuPackageManager: + def install_packages(self, packages): + args = ["apt-get", "install"] + args.extend(packages) + + command.run_with_sudo(args) + +def get_package_manager(): + name, version = _get_distro_info() + + if name == "fedora": + return FedoraPackageManager() + elif name == "ubuntu": + return UbuntuPackageManager() + def get_system_version(): name, version = _get_distro_info() if (name == "ubuntu" and version == "12.10") or \ |