-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpossum.py
52 lines (36 loc) · 1.4 KB
/
possum.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
#!/usr/bin/env python
import subprocess
from possum_common import *
from time_module import PossumTime
from system_module import PossumSystem
from network_module import PossumNetwork
class Possum_DBus(dbus.service.Object):
def __init__(self):
bus_name = dbus.service.BusName('com.viero.possum', bus=dbus.SystemBus())
dbus.service.Object.__init__(self, bus_name, '/main')
# Interface and Method
@dbus.service.method('org.me.test1')
def session_bus_message1(self, strcmd):
print "lol1", strcmd
print subprocess.check_output(strcmd.split())
return "Server Bus 1"
# Different Interface and different Method
# The method must not have not the same name as the first
@dbus.service.method('org.me.test2')
def session_bus_message2(self):
print "lol2"
return "Server Bus 2"
# Method with arguments
@dbus.service.method('org.me.test2')
def session_bus_strings(self, string1, string2):
return string1 + " " + string2
DBusGMainLoop(set_as_default=True)
bus_name = dbus.service.BusName('com.viero.possum', bus=dbus.SystemBus())
PossumTime(bus_name)
PossumSystem(bus_name)
PossumNetwork(bus_name)
try:
GLib.MainLoop().run()
except KeyboardInterrupt:
print("\nPossum will exit...")
GLib.MainLoop().quit()