forked from teltek/Galicaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_galicaster.py
executable file
·74 lines (61 loc) · 2.12 KB
/
run_galicaster.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Galicaster, Multistream Recorder and Player
#
# run_galicaster
#
# Copyright (c) 2011, Teltek Video Research <galicaster@teltek.es>
#
# This work is licensed under the Creative Commons Attribution-
# NonCommercial-ShareAlike 3.0 Unported License. To view a copy of
# this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
# or send a letter to Creative Commons, 171 Second Street, Suite 300,
# San Francisco, California, 94105, USA.
import sys
# debug
# import traceback
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstPbutils', '1.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk # noqa: ignore=E402
from gi.repository import GLib # noqa: ignore=E402
from gi.repository import Gst # noqa: ignore=E402
from galicaster.core import core # noqa: ignore=E402
def main(args):
def usage():
sys.stderr.write("usage: %s\n" % args[0])
return 1
if len(args) != 1:
return usage()
try:
Gst.init(None)
gc = core.Main()
# Bug with Gtk.main() not raising a KeyboardInterrupt(SIGINT) exception
# https://bugzilla.gnome.org/show_bug.cgi?id=622084
# Calling GObject.MainLoop.run() instead could be an option.
# Sadly, Gtk.main_quit() does not work with it.
# This workaround will stay until a better solution
# is found or the bug is fixed.
def handler(gc):
print("SIGINT sent. Interrupted by user!")
gc.quit()
GLib.unix_signal_add(GLib.PRIORITY_HIGH, 2, handler, gc) # 2 = SIGINT
Gtk.main()
except KeyboardInterrupt:
gc.emit_quit()
print("Interrupted by user!")
except Exception as exc:
# debug
# print traceback.format_exc()
msg = "Error starting Galicaster: {0}".format(exc)
print(msg)
from galicaster.core import context
logger = context.get_logger()
logger and logger.error(msg)
d = context.get_dispatcher()
d.emit("quit")
return -1
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))