在python中使用libreoffice5.0将.odt转换为.docx

时间:2016-03-10 10:55:55

标签: apache python-2.7 libreoffice

private boolean isPixelColorBright(int color) {
    if (android.R.color.transparent == color)
        return true;

    boolean rtnValue = false;

    int[] rgb = {Color.red(color), Color.green(color), Color.blue(color)};

    int brightness = (int) Math.sqrt(rgb[0] * rgb[0] * .299 + rgb[1]
            * rgb[1] * .587 + rgb[2] * rgb[2] * .114);

    if (brightness >= 200) {    // light color
        rtnValue = true;
    }

    return rtnValue;
}

当我们在终端上运行此命令时,我会输出

  

/data/Format/000001535edbaf8f27a9c331003600c900520045/test.odt

但是每当我尝试使用apache请求command = "libreoffice5.0 --headless --convert-to odt /data/Format/000001535edbaf8f27a9c331003600c900520045/test.docx --outdir /data/Format/000001535edbaf8f27a9c331003600c900520045" 时,它都会进行,但不会返回任何内容。该过程不断在后台运行。

1 个答案:

答案 0 :(得分:0)

您是否考虑过使用

subprocess.call(["ls", "-l"])
  

“子进程模块允许您生成新进程,连接到它们的输入/输出/错误管道,并获取它们的返回代码。该模块打算替换几个较旧的模块和函数:”

     

使用os.system

     

os.spawn *

     

os.popen *

     

popen2。*

     

命令。*

参考Python 2.7.x module subprocess