• Douglas's avatar
    erp5 jupyter kernel: print capturing using AST processor to modify print calls · 79ba7515
    Douglas authored
    This is a duplicate of !150, because by unknown reasons it's showing problem to merge.
    
    Before, we we're redirecting `sys.stdout` and this doesn't play nice with the
    distribute architecture of ERP5 and our Jupyter kernel needs to be adjusted for this.
    
    So, we're now using an AST processor to fix print calls. It will modify the print
    and make it write to a different file-like object. All the writes are collected
    after code execution and sent to Jupyter.
    
    It's still necesasry though to fix print inside other libraries. But for this
    deeper investigation is necessary because we cannot replace print as a statement
    inside `exec` contetx, it needs to be used as a function. Code can be compiled to
    run with `print` as a function, but then external libraries calls will be
    broken.
    
    /reviewed-on !157
    79ba7515
extension.erp5.JupyterCompile.py 36.2 KB