summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-05 01:06:49 (GMT)
committerWolfgang Rohdewald <wolfgang@rohdewald.de>2016-08-24 11:47:05 (GMT)
commitd017dd25da404edc640e47695e5da2ac54f25522 (patch)
tree61913f5f350b339178fe4232c93da4b9ea1a27f7
parentfe8d3a391e563bd42fd491f9b8091d41316baf5d (diff)
raise an exception if kde4-config is missing
-rw-r--r--src/kdestub.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/kdestub.py b/src/kdestub.py
index 941f4dc..acadf26 100644
--- a/src/kdestub.py
+++ b/src/kdestub.py
@@ -753,10 +753,19 @@ class KStandardDirs(object):
dirMap[key] = list(os.path.normpath(x)
for x in dirMap[key])
else:
- KStandardDirs.prefix = subprocess.Popen(
- ['which', 'kde4-config'],
- stdout=subprocess.PIPE).communicate()[0].split(b'/')[1].decode('utf-8') # TODO: fsencoding
- KStandardDirs.prefix = '/%s/' % KStandardDirs.prefix
+ kde4configPath = self.which('kde4-config')
+ if kde4configPath:
+ KStandardDirs.prefix = '/{}/'.format(
+ kde4configPath.split(b'/')[1].decode('utf-8'))
+ else:
+ raise Exception('Cannot find kde4-config')
+
+ @staticmethod
+ def which(program):
+ """calls which program"""
+ return subprocess.Popen(
+ ['which', program],
+ stdout=subprocess.PIPE).communicate()[0]
@classmethod
def kde_default(cls, type_):