-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_signal_emit.py
87 lines (66 loc) · 2.29 KB
/
run_signal_emit.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
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import os
import sys
import time
SCARLETT_DEBUG = None
if SCARLETT_DEBUG:
# Setting GST_DEBUG_DUMP_DOT_DIR environment variable enables us to have a
# dotfile generated
os.environ[
"GST_DEBUG_DUMP_DOT_DIR"] = "/home/pi/dev/bossjones-github/scarlett-dbus-poc/_debug"
os.putenv('GST_DEBUG_DUMP_DIR_DIR',
'/home/pi/dev/bossjones-github/scarlett-dbus-poc/_debug')
import argparse
import pprint
pp = pprint.PrettyPrinter(indent=4)
import gi
gi.require_version('Gst', '1.0')
# from gi.repository import GObject
# from gi.repository import GLib
# import threading
# from gettext import gettext as _
from pydbus import SessionBus
valid_signals = ['failed',
'ready',
'kw-rec',
'cmd-rec',
'cancel',
'cmd-rec']
from IPython.core.debugger import Tracer # NOQA
from IPython.core import ultratb
import generator_utils
import logging
logger = logging.getLogger('scarlettlogger')
sys.excepthook = ultratb.FormattedTB(mode='Verbose',
color_scheme='Linux',
call_pdb=True,
ostream=sys.__stdout__)
def main(ss, args):
if args.signal == 'failed':
ss.emitSttFailedSignal()
if args.signal == 'ready':
ss.emitListenerReadySignal()
if args.signal == 'kw-rec':
ss.emitKeywordRecognizedSignal()
if args.signal == 'cmd-rec':
ss.emitCommandRecognizedSignal('what time is it')
if args.signal == 'cancel':
ss.emitListenerCancelSignal()
if __name__ == '__main__':
from pydbus import SessionBus
bus = SessionBus()
ss = bus.get("org.scarlett", object_path='/org/scarlett/Listener')
time.sleep(0.5)
parser = argparse.ArgumentParser(description='Test emit signal.')
parser.add_argument('-s',
'--signal',
help='signal to carry out. Can be one of:\n'
'failed\n'
'ready\n'
'kw-rec\n'
'cancel\n'
'cmd-rec',
choices=valid_signals)
args = parser.parse_args()
main(ss, args)