Detect missing builder early

This commit is contained in:
Stefano Rivera 2011-07-25 19:32:15 +02:00
parent b4a6cf5310
commit 6e05bb7e74

View File

@ -19,6 +19,7 @@
#
import os
import os.path
from devscripts.logger import Logger
from ubuntutools import subprocess
@ -41,6 +42,12 @@ class Builder(object):
(os.path.basename(dsc_file), self.name))
return returncode
def exists_in_path(self):
for path in os.environ.get('PATH', os.defpath).split(os.pathsep):
if os.path.isfile(os.path.join(path, self.name)):
return True
return False
def get_architecture(self):
return self.architecture
@ -155,7 +162,10 @@ _SUPPORTED_BUILDERS = {
def get_builder(builder):
if builder in _SUPPORTED_BUILDERS:
return _SUPPORTED_BUILDERS[builder]()
b = _SUPPORTED_BUILDERS[builder]()
if b.exists_in_path():
return b
Logger.error("Builder doesn't appear to be installed: %s", builder)
else:
Logger.error("Unsupported builder specified: %s.", builder)
Logger.error("Supported builders: %s",