Workaround infrared setup failures

Change-Id: I601ce00ef00822e602a4f7f50357cd134b564ad5
This commit is contained in:
Federico Ressi 2020-07-03 12:44:04 +02:00
parent be4ab43b37
commit ebb5ff5c0a
1 changed files with 45 additions and 15 deletions

View File

@ -28,26 +28,46 @@ LOG = common.get_logger(__name__)
def main(): def main():
common.setup_logging() common.setup_logging()
add_tobiko_plugin() show_infrared_version()
plugin_path = os.environ.get('IR_TOBIKO_PLUGIN')
if plugin_path:
add_tobiko_plugin(path=plugin_path)
show_infrared_workspaces()
ensure_workspace() ensure_workspace()
copy_inventory() copy_inventory()
def show_infrared_version():
return common.execute('ir --version || ir --version', capture_stdout=False)
def show_infrared_plugins():
return common.execute('ir plugin list', capture_stdout=False)
def has_plugin(name):
try:
common.execute("ir plugin list | awk '( $4 == \"{}\" )'", name,
capture_stdout=False)
except subprocess.CalledProcessError as ex:
LOG.debug("tobiko plugin not found ({})", ex)
return False
else:
LOG.info("tobiko plugin found")
return True
def show_infrared_workspaces():
return common.execute('ir workspace list', capture_stdout=False)
def add_tobiko_plugin(path=None): def add_tobiko_plugin(path=None):
path = path or os.environ.get('IR_TOBIKO_PLUGIN') if has_plugin('tobiko'):
if path: remove_plugin('tobiko')
add_plugin('tobiko', path) add_plugin(path)
show_infrared_plugins()
def add_plugin(name, path):
path = common.normalize_path(path)
if not os.path.isdir(path):
message = ("invalid plug-in '{}' directory: '{}'").format(name, path)
raise RuntimeError(message)
remove_plugin(name)
common.execute('ir plugin add "{}"', path)
LOG.info("plug-in '%s' added from path '%s'", name, path)
def remove_plugin(name): def remove_plugin(name):
@ -61,6 +81,16 @@ def remove_plugin(name):
return True return True
def add_plugin(path):
path = common.normalize_path(path)
if not os.path.isdir(path):
message = ("invalid plug-in directory: '{}'").format(path)
raise RuntimeError(message)
common.execute('ir plugin add "{}"', path)
LOG.info("plug-in added from path '%s'", path)
def ensure_workspace(filename=None): def ensure_workspace(filename=None):
filename = (filename or filename = (filename or
os.environ.get('IR_WORKSPACE_FILE') or os.environ.get('IR_WORKSPACE_FILE') or