Skip to content

Commit f910aed

Browse files
authored
Replaced os.system with subprocess.run. (#89)
1 parent e2d5788 commit f910aed

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

manim_voiceover/translate/gettext_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import os
33
import typing as t
44

5+
import subprocess
6+
57
from manim import logger
68

79
from manim_voiceover.helper import prompt_ask_missing_extras
@@ -27,10 +29,10 @@ def init_gettext(files, domain, localedir):
2729
# Check if pot_path exists
2830
if os.path.exists(pot_path):
2931
# If it does, update it
30-
os.system(f"xgettext -j -o {pot_path} {file}")
32+
subprocess.run(["xgettext", "-j", "-o", pot_path, file])
3133
else:
3234
# If it does not, create it
33-
os.system(f"xgettext -o {pot_path} {file}")
35+
subprocess.run(["xgettext", "-o", pot_path, file])
3436

3537

3638
def init_language(target_lang, domain, localedir):
@@ -52,9 +54,7 @@ def init_language(target_lang, domain, localedir):
5254
pass
5355
else:
5456
# If it does not, create it
55-
os.system(
56-
f"msginit --no-translator -i {localedir / f'{domain}.pot'} -o {po_path} -l {target_lang}"
57-
)
57+
subprocess.run(["msginit", "--no-translator", "-i", localedir / f"{domain}.pot", "-o", po_path, "-l", target_lang])
5858

5959
return po_path
6060

manim_voiceover/translate/render.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
import sys
44
from pathlib import Path
55

6+
import subprocess
7+
68

79
# Get the current working directory as Path
810
CWD = Path.cwd()
@@ -108,15 +110,13 @@ def main():
108110
# If the .mo file does not exist, create it
109111
if not os.path.exists(mo_path):
110112
print(f"Creating {domain}.mo for {locale}")
111-
os.system(f"msgfmt {po_path} -o {mo_path}")
113+
subprocess.run(["msgfmt", po_path, "-o", mo_path])
112114

113115
print(f"Rendering {scene} in {locale}...")
114116
# Set LOCALE environment variable to locale
115117
os.environ["LOCALE"] = locale
116118
ofile = scene + "_" + locale + ".mp4"
117119
cmd = [
118-
f"LOCALE={locale}",
119-
f"DOMAIN={domain}",
120120
"manim",
121121
f"-q{quality}",
122122
file,
@@ -128,7 +128,7 @@ def main():
128128

129129
# Run manim with the command
130130
try:
131-
result = os.system(" ".join(cmd))
131+
result = subprocess.run(cmd, env={"LOCALE": locale, "DOMAIN": domain}).returncode
132132
except KeyboardInterrupt:
133133
print("KeyboardInterrupt")
134134
sys.exit(0)

0 commit comments

Comments
 (0)