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
|
import subprocess
def dbus(kuwii, *args):
data = args[0]
try:
object = session_bus.get_object (data['name'], data['object'])
except Exception, e:
print "Couldn't retrieve object %s from %s: %s" \
% (data['object'], data['name'], e)
return
try:
method = getattr (object, data['method'])
except Exception, e:
print "Failed to get required method %s: %s" % (data['method'], e)
return
try:
args = data['args']
kwargs = data['kwargs']
ret = method (*args, **kwargs)
if ret:
print ret
except Exception, e:
print "Failed to run %s method: %s" % (data['method'], e)
return
def cmd(kuwii, *command):
subprocess.Popen(command)
def echo(kuwii, *strlist):
print " ".join(strlist)
def key(kuwii, *keylist):
if not kuwii.bridge:
print "Key actions are not supported on your system"
else:
kuwii.bridge.press (keylist)
kuwii.bridge.release (keylist)
def quit(kuwii, *args):
kuwii.wiimote.disconnect()
try:
import dbus as dbus_module
session_bus = dbus_module.SessionBus()
except Exception, e:
print "Failed to connect to dbus Session Bus: %s" % e
dbus = None
|