使用Python和Redis脚本的Jython宏给出了

2024-04-18 06:07:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我们正在尝试使用Jython宏在confluence中使用Redis脚本,Jython宏是confluence脚本的confluence宏之一

我们可以在命令行中使用Jython执行操作,并且可以从redis数据库读取变量并获得结果,但是当我们尝试在Java应用程序中使用PythonInterpreter类时,我们会得到以下错误。如果你能建议如何处理这个错误,那就太好了

回溯(最近一次呼叫最后一次): 第4行,在 文件“/opt/jython/Lib/site packages/redis/init.py”,第1行,在 从redis.client导入redis,StrictRedis SyntaxError:(“在输入“”处没有可行的替代方案,('/opt/jython/Lib/site packages/redis/client.py',28,13'))

我们能够通过命令行重现问题的精确性,但不能通过解释器

try {
PythonInterpreter interpreter = new PythonInterpreter();
interpreter.setOut(out);
interpreter.setErr(err);
setVariable(interpreter, variableNames, "out", stdout);
setVariable(interpreter, variableNames, "err", stderr);
setVariables(interpreter, variableNames, info);
setParameterVariables(interpreter, variableNames, info);
interpreter.exec(code);
  } catch (PyException exception) {   // Exception from parsing script
            errorText = getModifiedErrorText(exception.toString());
            errorTitle = errorText.startsWith("SyntaxError") ? "Syntax error" : "Error running script";
        } catch (Exception exception) {   // Some other exception from the script
            errorTitle = "Unexpected error running script";
            errorText = exception.toString();
        }

请让我们知道,如果有任何事情是不清楚的或需要更多的信息,以提供解决这个问题的办法


Tags: 命令行脚本redislib错误confluenceexceptionscript