Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devbot/distro.py
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-11-14 15:32:49 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-11-14 15:40:37 (GMT)
commit66dc2e7ea7011ae63e1d404ebffeaa7782a7f2f5 (patch)
treea862db846c2bdb303a96108502402115eef40693 /devbot/distro.py
parentf83756431a5b6f8551f0902655ca39bf18a5e5b0 (diff)
Refactor check-system to use a devbot module
This is necessary to be able to share code, all the commands will be gradually refactored to follow this pattern.
Diffstat (limited to 'devbot/distro.py')
-rw-r--r--devbot/distro.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/devbot/distro.py b/devbot/distro.py
new file mode 100644
index 0000000..34f54bc
--- /dev/null
+++ b/devbot/distro.py
@@ -0,0 +1,47 @@
+import subprocess
+
+def get_system_version():
+ name, version = _get_distro_info()
+ if (name == "ubuntu" and version == "12.10") or \
+ (name == "fedora" and version == "18"):
+ return "3.6"
+ else:
+ return "3.4"
+
+def get_distro_name():
+ name, version = _get_distro_info()
+ return name
+
+def _get_distro_info():
+ distro = "unsupported"
+ version = "unknown"
+
+ # Fedora
+ try:
+ fedora_release = open("/etc/fedora-release").read().strip()
+ if fedora_release == "Fedora release 17 (Beefy Miracle)":
+ distro = "fedora"
+ version = "17"
+ elif fedora_release == "Fedora release 18 (Spherical Cow)":
+ distro = "fedora"
+ version = "18"
+ except IOError:
+ pass
+
+ # Ubuntu
+ try:
+ distributor = subprocess.check_output(["lsb_release", "-si"]).strip()
+ release = subprocess.check_output(["lsb_release", "-sr"]).strip()
+
+ if distributor == "Ubuntu" and release == "12.10":
+ distro = "ubuntu"
+ version = "12.10"
+ except OSError:
+ pass
+
+ arch = subprocess.check_output(["uname", "-i"]).strip()
+ if arch not in ["i386", "i686", "x86_64"]:
+ distro = "unsupported"
+ version = "unknown"
+
+ return distro, version