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@'
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
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))
45
42
def jump_through_hoops():
46
43
os.environ["JUMP_THROUGH_HOOPS"] = "1"
47
44
os.execv(sys.argv[0], sys.argv)
47
# Check if we're in development or installed version and set paths properly
49
52
def _add_pitivi_path():
51
54
dir = os.path.dirname(os.path.abspath(__file__))
52
root = os.path.join(LIBDIR, 'pitivi', 'python')
53
localedir = "@DATADIR@/locale"
57
root = os.path.split(dir)[0]
58
sys.path.insert(0, os.path.join(root, "pitivi", "coptimizations",
60
localedir = os.path.join(os.path.split(dir)[0], 'locale')
62
root = os.path.join(LIBDIR, 'pitivi', 'python')
63
localedir = "@DATADIR@/locale"
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')
81
print "Couldn't set locale."
71
83
gettext.bindtextdomain('pitivi', localedir)
72
84
gettext.textdomain('pitivi')
74
print "Couldn't set locale !, reverting to C locale"
86
print "Couldn't set the gettext domain. Translations will not work."
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()
84
def _init_gobject_gtk_gst():
93
gobject.threads_init()
94
except ImportError, e:
95
raise SystemExit("PyGTK couldn't be found !", str(e))
97
gobject.threads_init()
101
pygst.require('0.10')
103
args, sys.argv[:] = sys.argv[:], sys.argv[0:1]
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])
100
def _initialize_modules():
101
from pitivi.check import initialize_modules
105
print "Failed to initialize modules: ", e
108
def _check_requirements():
109
from pitivi.check import check_requirements
111
if not check_requirements():
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
122
# Start the real Pitivi, with given arguments.
117
123
sys.exit(ptv.main(sys.argv))
121
_init_gobject_gtk_gst()
123
except KeyboardInterrupt:
124
print "Interrupted by user!"
126
if __name__ == "__main__":
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()
137
except KeyboardInterrupt:
138
print "\tPitivi stopped by user with KeyboardInterrupt!"