New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent GStreamer from completely hijacking --help #95

Closed
adamcik opened this Issue May 7, 2011 · 6 comments

Comments

2 participants
@adamcik
Member

adamcik commented May 7, 2011

c7ccd0c broke mopidy in the sense that only GStreamers --help output is shown. In my opinion GStreamer's help being shown now is a good thing, despite not being an intended change. However, it is not a good thing that only GStreamers help is shown, so this needs to be fixed before 0.5.

@ghost ghost assigned adamcik May 7, 2011

@adamcik

This comment has been minimized.

Member

adamcik commented May 7, 2011

https://bugzilla.gnome.org/show_bug.cgi?id=625211 might be relevant. However, current suggested workaround until this is fixed seems to be to simply import gst after optparse is done. Unfortunately, this also implies that --gst-debug-level and other gst options can not be given to mopidy.

@jodal

This comment has been minimized.

Member

jodal commented May 7, 2011

@jodal

This comment has been minimized.

Member

jodal commented May 7, 2011

One possible solution, which allows --gst* arguments to be left for GStreamer:

diff --git a/mopidy/core.py b/mopidy/core.py
index d0f2a66..ce6ad5b 100644
--- a/mopidy/core.py
+++ b/mopidy/core.py
@@ -1,6 +1,12 @@
 import logging
 import optparse
 import time
+import sys
+
+all_args = sys.argv[1:]
+gst_args = filter(lambda arg: arg.startswith('--gst'), all_args)
+mopidy_args = filter(lambda arg: not arg.startswith('--gst'), all_args)
+sys.argv[1:] = gst_args

 from pykka.registry import ActorRegistry

@@ -45,7 +51,7 @@ def parse_options():
     parser.add_option('--list-settings',
         action='callback', callback=list_settings_optparse_callback,
         help='list current settings')
-    return parser.parse_args()[0]
+    return parser.parse_args(args=mopidy_args)[0]

 def setup_settings():
     get_or_create_folder('~/.mopidy/')
@adamcik

This comment has been minimized.

Member

adamcik commented May 7, 2011

Looks reasonable, assuming you add some nice comment explaining why this needs to be done in the code. Would need to test what output of --help is though.

@ghost ghost assigned jodal May 7, 2011

@adamcik

This comment has been minimized.

Member

adamcik commented May 8, 2011

Supporting --help-gst in addition to --gst* might be an idea? Other than that minor thing the fix seems good.

jodal added a commit that referenced this issue May 9, 2011

@jodal

This comment has been minimized.

Member

jodal commented May 9, 2011

I added support for --help-gst and listed --help-gst in --help. Merged into develop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment