Repository: ManimCommunity/manim

Issue:
-fp does not work on Ubuntu 
On Ubuntu, when passing -f flag (open the file in file browser) and -p (preview) no preview is shown, only the file browser is open, instead of both. 

IIRC it is working on windows, as I remember having worked on this flag to make it work on Windows. 

Seems like an easy PR 
-fp does not work on Ubuntu 
On Ubuntu, when passing -f flag (open the file in file browser) and -p (preview) no preview is shown, only the file browser is open, instead of both. 

IIRC it is working on windows, as I remember having worked on this flag to make it work on Windows. 

Seems like an easy PR 


Discussion:
Thanks for reporting. I find it extremely weird that many flags seem to be failing lately. I was able to use -p only last week. There must be a PR that messed this up recently.

Another sign we need more tests. All the regressions are getting frustrating. We can't release v0.1 if -p can break at any point. I suggest we stop merging PRs without new tests added.
Yes, but how do you want to test -p and -f ? 
They're two of the most used flags, no?

On Sun, Sep 27, 2020, 11:26 AM Hugues Devimeux <notifications@github.com>
wrote:

> Yes, but how do you want to test -p and -f ?
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/ManimCommunity/manim/issues/484#issuecomment-699649185>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAILYAH6AWH4IN5AVAAMXZDSH5KQ5ANCNFSM4R3TQB5A>
> .
>

Yes, I think so. 
Works for me on Windows. So it is only for Linux. For contributors, the below code needs to be fixed.
https://github.com/ManimCommunity/manim/blob/9271ca88936b4723415df20f9f87e01c108152a5/manim/utils/file_ops.py#L56-L72
I couldn't make -fp work on Windows either. The problem is, open_media_file runs *once* regardless if -f or -p or both of them are given at that time. (ofc doesn't run if neither is given)
https://github.com/ManimCommunity/manim/blob/97de34692de7442845f9b935c6d1481784a739d4/manim/__main__.py#L25-L43

If -f is set, open_media_file opens the folder.
https://github.com/ManimCommunity/manim/blob/9271ca88936b4723415df20f9f87e01c108152a5/manim/utils/file_ops.py#L56-L72

Thanks for reporting. I find it extremely weird that many flags seem to be failing lately. I was able to use -p only last week. There must be a PR that messed this up recently.

Another sign we need more tests. All the regressions are getting frustrating. We can't release v0.1 if -p can break at any point. I suggest we stop merging PRs without new tests added.
Yes, but how do you want to test -p and -f ? 
They're two of the most used flags, no?

On Sun, Sep 27, 2020, 11:26 AM Hugues Devimeux <notifications@github.com>
wrote:

> Yes, but how do you want to test -p and -f ?
>
> —
> You are receiving this because you commented.
> Reply to this email directly, view it on GitHub
> <https://github.com/ManimCommunity/manim/issues/484#issuecomment-699649185>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAILYAH6AWH4IN5AVAAMXZDSH5KQ5ANCNFSM4R3TQB5A>
> .
>

Yes, I think so. 
Works for me on Windows. So it is only for Linux. For contributors, the below code needs to be fixed.
https://github.com/ManimCommunity/manim/blob/9271ca88936b4723415df20f9f87e01c108152a5/manim/utils/file_ops.py#L56-L72
I couldn't make -fp work on Windows either. The problem is, open_media_file runs *once* regardless if -f or -p or both of them are given at that time. (ofc doesn't run if neither is given)
https://github.com/ManimCommunity/manim/blob/97de34692de7442845f9b935c6d1481784a739d4/manim/__main__.py#L25-L43

If -f is set, open_media_file opens the folder.
https://github.com/ManimCommunity/manim/blob/9271ca88936b4723415df20f9f87e01c108152a5/manim/utils/file_ops.py#L56-L72


Resolving patch:
diff --git a/manim/__main__.py b/manim/__main__.py
--- a/manim/__main__.py
+++ b/manim/__main__.py
@@ -40,7 +40,10 @@ def open_file_if_needed(file_writer):
             file_paths.append(file_writer.gif_file_path)
 
         for file_path in file_paths:
-            open_media_file(file_path, file_writer_config["show_in_file_browser"])
+            if file_writer_config["show_in_file_browser"]:
+                open_media_file(file_path, True)
+            if file_writer_config["preview"]:
+                open_media_file(file_path, False)
 
     if file_writer_config["verbosity"] != "DEBUG":
         sys.stdout.close()


Test patch: