From 799f3aed22fe46d21b85abebe2a180aa6a690664 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Tue, 11 Jun 2019 14:11:00 +0200 Subject: [PATCH] [IMP] runbot: add more objects in run python Since the use of the "python jobs", we spotted various needs that were not fulfilled. In order to add flexibility to "python jobs", this commit adds some useful objetcs in the _run_python eval context. Also, the glob.glob function is given instead of the whole glob module to avoid giving access to the os module via glob.os. --- runbot/models/build_config.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/runbot/models/build_config.py b/runbot/models/build_config.py index b8f88a30..99994416 100644 --- a/runbot/models/build_config.py +++ b/runbot/models/build_config.py @@ -1,3 +1,4 @@ +import base64 import glob import logging import os @@ -211,7 +212,23 @@ class ConfigStep(models.Model): build._log('create_build', 'created with config %s' % create_config.name, log_type='subbuild', path=str(children.id)) def _run_python(self, build, log_path): - eval_ctx = {'self': self, 'build': build, 'log_path': log_path, 'docker_run': docker_run, 'glob': glob, '_logger': _logger, 'build_odoo_cmd': build_odoo_cmd} + eval_ctx = { + 'self': self, + 'fields': fields, + 'models': models, + 'build': build, + 'docker_run': docker_run, + '_logger': _logger, + 'log_path': log_path, + 'glob': glob.glob, + 'build_odoo_cmd': build_odoo_cmd, + 'base64': base64, + 're': re, + 'time': time, + 'grep': grep, + 'get_py_version': get_py_version, + 'rfind': rfind, + } return safe_eval(self.sudo().python_code.strip(), eval_ctx, mode="exec", nocopy=True) def _run_odoo_run(self, build, log_path):