mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00

Show alternate message when package string for host_dependencies starts with http:// or https://
31 lines
1 KiB
Python
31 lines
1 KiB
Python
from base import Task
|
|
from common import phases
|
|
from common.exceptions import TaskError
|
|
|
|
|
|
class CheckExternalCommands(Task):
|
|
description = 'Checking availability of external commands'
|
|
phase = phases.preparation
|
|
|
|
@classmethod
|
|
def run(cls, info):
|
|
from common.tools import log_check_call
|
|
from subprocess import CalledProcessError
|
|
import re
|
|
missing_packages = []
|
|
for command, package in info.host_dependencies.items():
|
|
try:
|
|
log_check_call(['type ' + command], shell=True)
|
|
except CalledProcessError:
|
|
if re.match('^https?:\/\/', package):
|
|
msg = ('The command `{command}\' is not available, '
|
|
'you can download the software at `{package}\'.'
|
|
.format(command=command, package=package))
|
|
else:
|
|
msg = ('The command `{command}\' is not available, '
|
|
'it is located in the package `{package}\'.'
|
|
.format(command=command, package=package))
|
|
missing_packages.append(msg)
|
|
if len(missing_packages) > 0:
|
|
msg = '\n'.join(missing_packages)
|
|
raise TaskError(msg)
|