2017-10-25 22:32:06 -07:00
|
|
|
import logging
|
2017-10-26 06:38:27 +02:00
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
|
2017-10-25 22:32:06 -07:00
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def execute_hook(commands, config_filename, description):
|
|
|
|
|
if not commands:
|
|
|
|
|
logger.debug('{}: No commands to run for {} hook'.format(config_filename, description))
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
if len(commands) == 1:
|
|
|
|
|
logger.info('{}: Running command for {} hook'.format(config_filename, description))
|
|
|
|
|
else:
|
|
|
|
|
logger.info('{}: Running {} commands for {} hook'.format(config_filename, len(commands), description))
|
|
|
|
|
|
|
|
|
|
for command in commands:
|
|
|
|
|
logger.debug('{}: Hook command: {}'.format(config_filename, command))
|
|
|
|
|
subprocess.check_call(command, shell=True)
|