server: fix import of CalledProcessError from subprocess

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2023-09-27 20:33:03 +02:00
parent 4d4f8f2956
commit 01bed38f31
No known key found for this signature in database
GPG Key ID: FE65CD384D5BF7B4
1 changed files with 5 additions and 5 deletions

View File

@ -5,10 +5,10 @@ import logging as log
from flask import Flask
from git import Repo, util
from webhook import Webhook
from subprocess import check_output
from os import environ as env, path
from urllib.parse import urlparse
from argparse import ArgumentParser
from subprocess import check_output, CalledProcessError
app = Flask(__name__)
webhook = Webhook(app, endpoint='/gh_webhook')
@ -85,14 +85,14 @@ def remove_prefix(text, prefix):
return text[text.startswith(prefix) and len(prefix):]
def run_command(command):
log.info('Running command: %s' % command)
log.info('Running command: %s', command)
try:
output = check_output(command.split())
except subprocess.CalledProcessError as err:
except CalledProcessError as err:
log.error('Command failed, return code: %d' % err.returncode)
log.error('Command stdout:\n%s' % err.output)
log.error('Command stdout:\n%s', err.output)
else:
log.info('Command success:\n%s' % output)
log.info('Command success:\n%s', output)
def define_push_hook(repo, post_action):
@webhook.hook()