コード例 #1
0
        for s in stmts:
            if s == None:
                continue

            # skip comment
            s_stripped = s.strip()
            if len(s_stripped) == 0 or s_stripped.startswith("#"):
                continue

            if final_code:
                final_code += "\n" + s
            else:
                final_code = s

        if final_code:
            compiledCode = compile(final_code, "<string>", "exec")
            sc.setJobGroup(jobGroup, "Zeppelin")
            eval(compiledCode)

        intp.setStatementsFinished(output.get(), False)
    except Py4JJavaError:
        excInnerError = traceback.format_exc()  # format_tb() does not return the inner exception
        innerErrorStart = excInnerError.find("Py4JJavaError:")
        if innerErrorStart > -1:
            excInnerError = excInnerError[innerErrorStart:]
        intp.setStatementsFinished(excInnerError + str(sys.exc_info()), True)
    except:
        intp.setStatementsFinished(traceback.format_exc(), True)

    output.reset()
コード例 #2
0
        for s in stmts:
            if s == None:
                continue

            # skip comment
            s_stripped = s.strip()
            if len(s_stripped) == 0 or s_stripped.startswith("#"):
                continue

            final_code.append(s)

        if final_code:
            # use exec mode to compile the statements except the last statement,
            # so that the last statement's evaluation will be printed to stdout
            sc.setJobGroup(jobGroup, "Zeppelin")
            code = compile('\n'.join(final_code), '<stdin>', 'exec',
                           ast.PyCF_ONLY_AST, 1)
            to_run_hooks = []
            if (nhooks > 0):
                to_run_hooks = code.body[-nhooks:]
            to_run_exec, to_run_single = (code.body[:-(nhooks + 1)],
                                          [code.body[-(nhooks + 1)]])

            try:
                for node in to_run_exec:
                    mod = ast.Module([node])
                    code = compile(mod, '<stdin>', 'exec')
                    exec(code)

                for node in to_run_single:
コード例 #3
0
ファイル: mix_pyspark.py プロジェクト: WeBankFinTech/Linkis
            if bdp_dwc_s == None:
                continue

            # skip comment
            s_stripped = bdp_dwc_s.strip()
            if len(s_stripped) == 0 or s_stripped.startswith("#"):
                continue

            if final_code:
                final_code += "\n" + bdp_dwc_s
            else:
                final_code = bdp_dwc_s

        if final_code:
            compiledCode = compile(final_code, "<string>", "exec")
            sc.setJobGroup(jobGroup, final_code)
            eval(compiledCode)

        intp.setStatementsFinished("", False)
    except Py4JJavaError:
        excInnerError = traceback.format_exc() # format_tb() does not return the inner exception
        innerErrorStart = excInnerError.find("Py4JJavaError:")
        if innerErrorStart > -1:
            excInnerError = excInnerError[innerErrorStart:]
        intp.setStatementsFinished(excInnerError + str(sys.exc_info()), True)
    except Py4JNetworkError:
         # lost connection from gateway server. exit
         intp.setStatementsFinished(msg, True)
         sys.exit(1)
    except:
        msg = traceback.format_exc()