File size: 801 Bytes
9150552
896bcfb
9150552
 
 
6b9994d
896bcfb
9150552
 
 
 
896bcfb
9150552
 
 
 
 
 
 
6b9994d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
from utils.log import logger

def generate_ppt(markdown_source, output_name, chromium_path="./chrome_sandbox") -> None:
    # check for marp
    if os.system("npx -y @marp-team/marp-cli --version") != 0:
        logger.critical("Marp is not installed")
        raise Exception("Marp is not installed")
    
    # if user is root, then set CHROMIUM_PATH to chromium_path
    if os.getuid() == 0 and os.name == "posix":
        logger.info("Running as root, setting CHROME_PATH")
        os.environ["CHROME_PATH"] = chromium_path
    
    # check for markdown source
    if not os.path.exists(markdown_source):
        raise Exception("Markdown source does not exist")
    
    # generate ppt
    os.system(f"npx -y @marp-team/marp-cli {markdown_source} -o {output_name} --allow-local-files")