Use os.openfile() on Windows and gitignore media folder (#384)

* Gitignored media and .vscode

* Switched to os.startfile for Windows
This commit is contained in:
F.W
2018-12-30 02:37:29 +01:00
committed by Devin Neal
parent 47d8caa80e
commit 11781a5baa
2 changed files with 26 additions and 14 deletions

2
.gitignore vendored
View File

@@ -11,8 +11,10 @@ ben_playground.py
ben_cairo_test.py
.floo
.flooignore
.vscode
*.xml
*.iml
media
manim.sublime-project
manim.sublime-workspace

View File

@@ -25,23 +25,33 @@ def handle_scene(scene, **config):
config["show_file_in_finder"]
])
if open_file:
commands = ["open"]
if (platform.system() == "Linux"):
commands = ["xdg-open"]
elif (platform.system() == "Windows"):
commands = ["start"]
if config["show_file_in_finder"]:
commands.append("-R")
current_os = platform.system()
file_path = None
if config["show_last_frame"]:
commands.append(scene.get_image_file_path())
file_path = scene.get_image_file_path()
else:
commands.append(scene.get_movie_file_path())
# commands.append("-g")
FNULL = open(os.devnull, 'w')
sp.call(commands, stdout=FNULL, stderr=sp.STDOUT)
FNULL.close()
file_path = scene.get_movie_file_path()
if current_os == "Windows":
os.startfile(file_path)
else:
commands = []
if (current_os == "Linux"):
commands.append("xdg-open")
else: # Assume macOS
commands.append("open")
if config["show_file_in_finder"]:
commands.append("-R")
commands.append(file_path)
# commands.append("-g")
FNULL = open(os.devnull, 'w')
sp.call(commands, stdout=FNULL, stderr=sp.STDOUT)
FNULL.close()
if config["quiet"]:
sys.stdout.close()