validate-scenario: fix g-i warning in annotation
[platform/upstream/gstreamer.git] / subprojects / gst-devtools / debug-viewer / gst-debug-viewer
1 #!/usr/bin/env python3
2 # -*- coding: utf-8; mode: python; -*-
3 #
4 #  GStreamer Debug Viewer - View and analyze GStreamer debug log files
5 #
6 #  Copyright (C) 2007 RenĂ© Stadler <mail@renestadler.de>
7 #
8 #  This program is free software; you can redistribute it and/or modify it
9 #  under the terms of the GNU General Public License as published by the Free
10 #  Software Foundation; either version 3 of the License, or (at your option)
11 #  any later version.
12 #
13 #  This program is distributed in the hope that it will be useful, but WITHOUT
14 #  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 #  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
16 #  more details.
17 #
18 #  You should have received a copy of the GNU General Public License along with
19 #  this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 """GStreamer Debug Viewer program invocation."""
22
23
24 def main():
25
26     import sys
27     import os.path
28
29     def substituted(s):
30         if s.startswith("@") and s.endswith("@"):
31             return None
32         else:
33             return s
34
35     # These "$"-enclosed strings are substituted at install time by a custom
36     # distutils extension (see setup.py).  If you don't see any dollar signs at
37     # all, you are looking at an installed version of this file.
38     data_dir = substituted("@DATADIR@")
39     lib_dir = substituted("@LIBDIR@")
40
41     if data_dir:
42         installed = True
43     else:
44         # Substitution has not been run, we are running within a development
45         # environment:
46         lib_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
47         installed = False
48
49     if lib_dir:
50         if not os.path.normpath(lib_dir) in [os.path.normpath(p)
51                                              for p in sys.path]:
52             sys.path.insert(0, lib_dir)
53
54     try:
55         import GstDebugViewer
56     except ImportError as exc:
57         print(str(exc), file=sys.stderr)
58         sys.exit(1)
59     else:
60         if installed:
61             GstDebugViewer.Paths.setup_installed(data_dir)
62         else:
63             # Assume that we reside inside the source dist.
64             source_dir = os.path.dirname(os.path.realpath(sys.argv[0]))
65             GstDebugViewer.Paths.setup_devenv(source_dir)
66
67     GstDebugViewer.run()
68
69
70 if __name__ == "__main__":
71     main()