mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-07 15:02:40 +00:00
Fix handling of filename command line argument
This commit is contained in:
parent
480392b881
commit
b948b7b6e5
3 changed files with 26 additions and 11 deletions
|
@ -301,6 +301,9 @@ class OptionParser (object):
|
||||||
|
|
||||||
self.options = options
|
self.options = options
|
||||||
|
|
||||||
|
self.__remaining_args = []
|
||||||
|
self.__entries.append ((gobject.OPTION_REMAINING, "\0", 0, "", "",))
|
||||||
|
|
||||||
def add_option (self, long_name, short_name = None, description = None,
|
def add_option (self, long_name, short_name = None, description = None,
|
||||||
arg_name = None, arg_parser = None, hidden = False):
|
arg_name = None, arg_parser = None, hidden = False):
|
||||||
|
|
||||||
|
@ -326,6 +329,10 @@ class OptionParser (object):
|
||||||
|
|
||||||
def __handle_option (self, option, arg, group):
|
def __handle_option (self, option, arg, group):
|
||||||
|
|
||||||
|
if option == gobject.OPTION_REMAINING:
|
||||||
|
self.__remaining_args.append (arg)
|
||||||
|
return
|
||||||
|
|
||||||
for entry in self.__entries:
|
for entry in self.__entries:
|
||||||
long_name, short_name = entry[:2]
|
long_name, short_name = entry[:2]
|
||||||
arg_name = entry[-1]
|
arg_name = entry[-1]
|
||||||
|
@ -340,6 +347,7 @@ class OptionParser (object):
|
||||||
else:
|
else:
|
||||||
value = arg
|
value = arg
|
||||||
self.options[attr] = value
|
self.options[attr] = value
|
||||||
|
break
|
||||||
|
|
||||||
def parse (self, argv):
|
def parse (self, argv):
|
||||||
|
|
||||||
|
@ -353,13 +361,13 @@ class OptionParser (object):
|
||||||
except gobject.GError, exc:
|
except gobject.GError, exc:
|
||||||
raise OptionError (exc.message)
|
raise OptionError (exc.message)
|
||||||
|
|
||||||
self.handle_parse_complete ()
|
self.handle_parse_complete (self.__remaining_args)
|
||||||
|
|
||||||
def get_parameter_string (self):
|
def get_parameter_string (self):
|
||||||
|
|
||||||
raise NotImplementedError ("derived classes must override this method")
|
raise NotImplementedError ("derived classes must override this method")
|
||||||
|
|
||||||
def handle_parse_complete (self):
|
def handle_parse_complete (self, remaining_args):
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -474,6 +482,6 @@ def main (option_parser = None, gettext_domain = None, paths = None):
|
||||||
_init_logging (log_level)
|
_init_logging (log_level)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
options["main"] ()
|
options["main"] (options)
|
||||||
finally:
|
finally:
|
||||||
logging.shutdown ()
|
logging.shutdown ()
|
||||||
|
|
|
@ -1524,18 +1524,22 @@ class TestParsingPerformance (object):
|
||||||
print "time spent in user mode: %.2f s" % (rusage.ru_utime,)
|
print "time spent in user mode: %.2f s" % (rusage.ru_utime,)
|
||||||
print "time spent in system mode: %.2f s" % (rusage.ru_stime,)
|
print "time spent in system mode: %.2f s" % (rusage.ru_stime,)
|
||||||
|
|
||||||
def main ():
|
def main (options):
|
||||||
|
|
||||||
if len (sys.argv) > 1 and sys.argv[1] == "benchmark":
|
args = options["args"]
|
||||||
test = TestParsingPerformance (sys.argv[2])
|
|
||||||
|
if len (args) > 1 and args[0] == "benchmark":
|
||||||
|
test = TestParsingPerformance (args[1])
|
||||||
test.start ()
|
test.start ()
|
||||||
return
|
return
|
||||||
|
|
||||||
app = App ()
|
app = App ()
|
||||||
|
|
||||||
|
# TODO: Once we support more than one window, open one window for each
|
||||||
|
# supplied filename.
|
||||||
window = app.windows[0]
|
window = app.windows[0]
|
||||||
if len (sys.argv) > 1:
|
if len (args) > 0:
|
||||||
window.set_log_file (sys.argv[-1])
|
window.set_log_file (args[0])
|
||||||
|
|
||||||
app.run ()
|
app.run ()
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ Common = GstDebugViewer.Common
|
||||||
|
|
||||||
GETTEXT_DOMAIN = "gst-debug-viewer"
|
GETTEXT_DOMAIN = "gst-debug-viewer"
|
||||||
|
|
||||||
def main_version ():
|
def main_version (options):
|
||||||
|
|
||||||
from GstDebugViewer import version
|
from GstDebugViewer import version
|
||||||
|
|
||||||
|
@ -44,14 +44,15 @@ class OptionParser (Common.Main.LogOptionParser):
|
||||||
Common.Main.LogOptionParser.__init__ (self, options)
|
Common.Main.LogOptionParser.__init__ (self, options)
|
||||||
|
|
||||||
options["main"] = None
|
options["main"] = None
|
||||||
|
options["args"] = []
|
||||||
|
|
||||||
self.add_option ("version", None, _("Display version and exit"))
|
self.add_option ("version", None, _("Display version and exit"))
|
||||||
|
|
||||||
def get_parameter_string (self):
|
def get_parameter_string (self):
|
||||||
|
|
||||||
return _("- Display and analyze debug log files")
|
return _("[FILENAME] - Display and analyze debug log files")
|
||||||
|
|
||||||
def handle_parse_complete (self):
|
def handle_parse_complete (self, remaining_args):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
version = self.options["version"]
|
version = self.options["version"]
|
||||||
|
@ -65,6 +66,8 @@ class OptionParser (Common.Main.LogOptionParser):
|
||||||
import GUI
|
import GUI
|
||||||
self.options["main"] = GUI.main
|
self.options["main"] = GUI.main
|
||||||
|
|
||||||
|
self.options["args"][:] = remaining_args
|
||||||
|
|
||||||
def main ():
|
def main ():
|
||||||
|
|
||||||
options = {}
|
options = {}
|
||||||
|
|
Loading…
Reference in a new issue