~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to bin/pitivi.in

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-04-05 15:28:16 UTC
  • mfrom: (6.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20140405152816-6lijoax4cngiz5j5
Tags: 0.93-3
* debian/control:
  + Depend on python-gi (>= 3.10), older versions do not work
    with pitivi (Closes: #732813).
  + Add missing dependency on gir1.2-clutter-gst-2.0 (Closes: #743692).
  + Add suggests on gir1.2-notify-0.7 and gir1.2-gnomedesktop-3.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python
2
 
# PiTiVi , Non-linear video editor
 
1
#!/usr/bin/env python2
 
2
# Pitivi video editor
3
3
#
4
4
#       pitivi
5
5
#
26
26
import locale
27
27
import gettext
28
28
 
29
 
# variables
30
29
CONFIGURED_PYTHONPATH = '@CONFIGURED_PYTHONPATH@'
 
30
CONFIGURED_GI_TYPELIB_PATH = '@CONFIGURED_GI_TYPELIB_PATH@'
31
31
CONFIGURED_LD_LIBRARY_PATH = '@CONFIGURED_LD_LIBRARY_PATH@'
32
32
CONFIGURED_GST_PLUGIN_PATH = '@CONFIGURED_GST_PLUGIN_PATH@'
33
33
LIBDIR = '@LIBDIR@'
34
 
 
35
34
localedir = ""
36
35
 
37
 
# Check if we're in development or installed version
38
 
# Add the path of pitivi stuff
39
 
# TODO : change it when it's finally in cvs
40
36
 
41
37
def _prepend_env_path(name, value):
42
38
    os.environ[name] = os.pathsep.join(value +
43
39
            os.environ.get(name, "").split(os.pathsep))
44
40
 
 
41
 
45
42
def jump_through_hoops():
46
43
    os.environ["JUMP_THROUGH_HOOPS"] = "1"
47
44
    os.execv(sys.argv[0], sys.argv)
48
45
 
 
46
 
 
47
# Check if we're in development or installed version and set paths properly
 
48
def _in_devel():
 
49
    return False
 
50
 
 
51
 
49
52
def _add_pitivi_path():
50
53
    global localedir
51
54
    dir = os.path.dirname(os.path.abspath(__file__))
52
 
    root = os.path.join(LIBDIR, 'pitivi', 'python')
53
 
    localedir = "@DATADIR@/locale"
 
55
    root = None
 
56
    if _in_devel():
 
57
        root = os.path.split(dir)[0]
 
58
        sys.path.insert(0, os.path.join(root, "pitivi", "coptimizations",
 
59
                    ".libs"))
 
60
        localedir = os.path.join(os.path.split(dir)[0], 'locale')
 
61
    else:
 
62
        root = os.path.join(LIBDIR, 'pitivi', 'python')
 
63
        localedir = "@DATADIR@/locale"
54
64
 
55
65
    if not root in sys.path:
56
66
        sys.path.insert(0, root)
67
77
        locale.setlocale(locale.LC_ALL, '')
68
78
        locale.bindtextdomain('pitivi', localedir)
69
79
        locale.textdomain('pitivi')
70
 
 
 
80
    except:
 
81
        print "Couldn't set locale."
 
82
    try:
71
83
        gettext.bindtextdomain('pitivi', localedir)
72
84
        gettext.textdomain('pitivi')
73
85
    except:
74
 
        print "Couldn't set locale !, reverting to C locale"
 
86
        print "Couldn't set the gettext domain. Translations will not work."
75
87
 
76
88
    if CONFIGURED_LD_LIBRARY_PATH or CONFIGURED_GST_PLUGIN_PATH:
77
89
        _prepend_env_path("LD_LIBRARY_PATH", [CONFIGURED_LD_LIBRARY_PATH])
81
93
            # ld caches LD_LIBRARY_PATH at startup so we need to execv() here. LALA.
82
94
            jump_through_hoops()
83
95
 
84
 
def _init_gobject_gtk_gst():
85
 
    global localedir
86
 
    try:
87
 
        import pygtk
88
 
        pygtk.require("2.0")
89
 
 
90
 
        import gtk
91
 
 
92
 
        import gobject
93
 
        gobject.threads_init()
94
 
    except ImportError, e:
95
 
        raise SystemExit("PyGTK couldn't be found !", str(e))
96
 
 
97
 
    gobject.threads_init()
98
 
 
99
 
    try:
100
 
        import pygst
101
 
        pygst.require('0.10')
102
 
 
103
 
        args, sys.argv[:] = sys.argv[:], sys.argv[0:1]
104
 
        import gst
105
 
        sys.argv = args
106
 
    except ImportError:
107
 
        raise SystemExit("Gst-Python couldn't be found!")
 
96
    if CONFIGURED_GI_TYPELIB_PATH:
 
97
        _prepend_env_path("GI_TYPELIB_PATH", [CONFIGURED_GI_TYPELIB_PATH])
 
98
 
 
99
 
 
100
def _initialize_modules():
 
101
    from pitivi.check import initialize_modules
 
102
    try:
 
103
        initialize_modules()
 
104
    except Exception, e:
 
105
        print "Failed to initialize modules: ", e
 
106
 
 
107
 
 
108
def _check_requirements():
 
109
    from pitivi.check import check_requirements
 
110
 
 
111
    if not check_requirements():
 
112
        sys.exit(2)
108
113
 
109
114
def _run_pitivi():
110
115
    import pitivi.application as ptv
114
119
        print 'Starting Pitivi with no GUI.'
115
120
        ptv.GuiPitivi._showGui = lambda *args, **kargs : None
116
121
 
 
122
    # Start the real Pitivi, with given arguments.
117
123
    sys.exit(ptv.main(sys.argv))
118
124
 
119
 
try:
120
 
    _add_pitivi_path()
121
 
    _init_gobject_gtk_gst()
122
 
    _run_pitivi()
123
 
except KeyboardInterrupt:
124
 
    print "Interrupted by user!"
 
125
 
 
126
if __name__ == "__main__":
 
127
    try:
 
128
        _add_pitivi_path()
 
129
        _initialize_modules()
 
130
        # Dep checks really have to happen here, not in application.py. Otherwise,
 
131
        # as soon as application.py starts, it will try importing all the code and
 
132
        # the classes in application.py will not even have the opportunity to run.
 
133
        # We do these checks on every startup (even outside the dev environment, for
 
134
        # soft deps); doing imports and gst registry checks has near-zero cost.
 
135
        _check_requirements()
 
136
        _run_pitivi()
 
137
    except KeyboardInterrupt:
 
138
        print "\tPitivi stopped by user with KeyboardInterrupt!"