summaryrefslogtreecommitdiff
path: root/bin
diff options
authorTaihsiang Ho <taihsiang.ho@canonical.com>2014-05-28 12:28:48 +0800
committerTaihsiang Ho <taihsiang.ho@canonical.com>2014-05-28 12:28:48 +0800
commit141358ce43f7e13eaac5e02df3d30f9b9b4d6dd5 (patch)
treec382b20c2c2413ba78666e526814508601b87e4a /bin
parent5b141915ffb9908631097206571176a2808b6141 (diff)
import lsb_release to make our code clearer
Diffstat (limited to 'bin')
-rwxr-xr-xbin/lock_screen_watcher22
1 files changed, 3 insertions, 19 deletions
diff --git a/bin/lock_screen_watcher b/bin/lock_screen_watcher
index c12921f..57efdef 100755
--- a/bin/lock_screen_watcher
+++ b/bin/lock_screen_watcher
@@ -2,6 +2,7 @@
import argparse
import sys
import subprocess
+import lsb_release
from gi.repository import GObject
@@ -19,26 +20,9 @@ class SceenSaverStatusHelper(threading.Thread):
self._loop = loop
self.quit = False
- def getDistributor(self):
- return self.getLSBReleaseProcess("-i")
-
- def getCodename(self):
- return self.getLSBReleaseProcess("-c")
-
- def getLSBReleaseProcess(self,option):
- """
- use the command "lsb_release" to get the distribution-specific information.
- This method should work on Debian and Ubuntu.
- """
- p = subprocess.Popen(["lsb_release", option],
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
- stdout = p.communicate()[0]
- return stdout.decode().split("\t")[-1][0:-1]
-
def query(self):
- if (self.getDistributor() == "Ubuntu"):
- if (self.getCodename() == "trusty"):
+ if (lsb_release.get_distro_information()["ID"] == "Ubuntu"):
+ if (lsb_release.get_distro_information()["CODENAME"] == "trusty"):
# trusty uses login screen as screen saver
process_ps = subprocess.Popen(["ps", "aux"], stdout=subprocess.PIPE)
process_grep = subprocess.Popen(["grep",