Open3

libre office

nassynassy

libreoffice のコマンドを debian 上で使えるようにする

root@fb665dce9999:~/site/wwwroot# which libreoffice7.4
/usr/local/bin/libreoffice7.4
root@fb665dce9999:~/site/wwwroot# ln -s /usr/local/bin/libreoffice7.4 /usr/local/bin/libreoffice
root@fb665dce9999:~/site/wwwroot# chmod +x /usr/local/bin/libreoffice
root@fb665dce9999:~/site/wwwroot# libreoffice --version
LibreOffice 7.4.7.2 723314e595e8007d3cf785c16538505a1c878ca5
nassynassy

libre コマンドの存在チェックモジュール

import subprocess


def check_libreoffice_exists():
    try:
        result = subprocess.run(['libreoffice', '--version'], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        print("libreoffice command exists.")
        print("Output:", result.stdout)
    except subprocess.CalledProcessError as e:
        raise ImportError("libreoffice command not found") from e

check_libreoffice_exists()
nassynassy

libre はハングするので実行毎に prfile を持つ必要がある。