From c8c96b977b26fb30d72d030805d9aa900a8f81eb Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 9 Jun 2016 09:24:47 +0800 Subject: [PATCH 1/2] Improve path resolution for executables in config --- mdk/config.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/mdk/config.py b/mdk/config.py index 39afb953..be2e027d 100644 --- a/mdk/config.py +++ b/mdk/config.py @@ -26,6 +26,7 @@ import json import re import copy +from distutils.spawn import find_executable class ConfigObject(object): @@ -56,6 +57,13 @@ def get(self, name=None, default=None): break return data + def getExecutable(self, name=None, default=None): + path = self.get(name, default) + if path != None and path: + return path + path = find_executable(name) + return path + def getFlat(self, data=None, parent=''): """Return the entire data as a flat array""" flatten = {} @@ -170,6 +178,10 @@ def get(self, name=None): """Return a setting""" return self.data.get(name) + def getExecutable(self, name=None): + """Return a path to an executable""" + return self.data.getExecutable(name) + def load(self, allowMissing=False): """Loads the configuration from the config files""" From 402d3c29cd5d911b9099673b71a7da97dec56211 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 9 Jun 2016 09:25:04 +0800 Subject: [PATCH 2/2] Add pathtogs for behat runs --- mdk/config-dist.json | 2 ++ mdk/moodle.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/mdk/config-dist.json b/mdk/config-dist.json index 69f8d2fc..18249834 100644 --- a/mdk/config-dist.json +++ b/mdk/config-dist.json @@ -201,6 +201,8 @@ "shifter": "/usr/bin/shifter", // Path to yuidoc "yuidoc": "/usr/local/bin/yuidoc", + // Path to ghostscript + "gs": "", // Path to your favourite editor. Set to null to guess it from the System environment. "editor": null, diff --git a/mdk/moodle.py b/mdk/moodle.py index 16fde31f..7b8a59cd 100644 --- a/mdk/moodle.py +++ b/mdk/moodle.py @@ -338,6 +338,9 @@ def initBehat(self, switchcompletely=False, force=False, prefix=None, faildumppa elif currentWwwroot != wwwroot: logging.warning('Behat wwwroot not changed, already set to \'%s\', expected \'%s\'.' % (currentWwwroot, wwwroot)) + # Set the pathtogs as this is required by some tests. + self.updateConfig('pathtogs', C.getExecutable('gs')) + # Force a cache purge self.purge()