1
0
mirror of https://github.com/gsi-upm/senpy synced 2025-09-17 20:12:22 +00:00

Merge branch '22-pip-screws-with-logging-config' into 0.8.x

This commit is contained in:
J. Fernando Sánchez
2017-04-04 11:12:23 +02:00
3 changed files with 32 additions and 3 deletions

View File

@@ -22,11 +22,18 @@ import importlib
import logging
import traceback
import yaml
import pip
import subprocess
logger = logging.getLogger(__name__)
def log_subprocess_output(process):
for line in iter(process.stdout.readline, b''):
logger.info('%r', line)
for line in iter(process.stderr.readline, b''):
logger.error('%r', line)
class Senpy(object):
""" Default Senpy extension for Flask """
@@ -333,13 +340,19 @@ class Senpy(object):
def _install_deps(cls, info=None):
requirements = info.get('requirements', [])
if requirements:
pip_args = []
pip_args = ['pip']
pip_args.append('install')
pip_args.append('--use-wheel')
for req in requirements:
pip_args.append(req)
logger.info('Installing requirements: ' + str(requirements))
pip.main(pip_args)
process = subprocess.Popen(pip_args,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
log_subprocess_output(process)
exitcode = process.wait()
if exitcode != 0:
raise Error("Dependencies not properly installed")
@classmethod
def _load_module(cls, name, root):

View File

@@ -357,5 +357,8 @@ class Error(SenpyMixin, Exception):
def __delattr__(self, key):
delattr(self._error, key)
def __str__(self):
return str(self.to_JSON(with_context=False))
register(Error, 'error')