Revisión 90
Añadido por Manu Mora Gordillo hace alrededor de 14 años
controlies/Utils/avahiClient.py | ||
---|---|---|
import dbus, gobject, avahi
|
||
from dbus import DBusException
|
||
from dbus.mainloop.glib import DBusGMainLoop
|
||
import threading
|
||
|
||
class avahiClient(object):
|
||
class avahiClient(threading.Thread):
|
||
|
||
names = []
|
||
|
||
def __init__ (self):
|
||
def __init__(self):
|
||
threading.Thread.__init__(self)
|
||
|
||
def run(self):
|
||
|
||
loop = DBusGMainLoop()
|
||
bus = dbus.SystemBus(mainloop=loop)
|
||
|
||
... | ... | |
|
||
self.loop = gobject.MainLoop()
|
||
self.loop.run()
|
||
|
||
|
||
|
||
def service_resolved(self,*args):
|
||
#print args
|
||
print 'service resolved'
|
||
print 'name:', args[2]
|
||
print 'address:', args[7]
|
||
print 'port:', args[8]
|
||
#print args
|
||
#print args
|
||
self.names.append(args[2])
|
||
|
||
#self.loop.quit()
|
controlies/Plugins/Hosts.py | ||
---|---|---|
|
||
def getLTSPStatus (self):
|
||
from Utils.avahiClient import avahiClient
|
||
import threading
|
||
|
||
a = avahiClient()
|
||
a = avahiClient()
|
||
a.start()
|
||
time.sleep(1000)
|
||
a.cancel()
|
||
names = a.getList()
|
||
print names
|
||
|
||
"""a = avahiClient()
|
||
time.sleep(1000)
|
||
names = a.getList()
|
||
print names
|
||
a.kill()
|
||
a.kill()"""
|
||
return names
|
||
|
||
# def wakeup(self):
|
Exportar a: Unified diff
Intentando avahi con threads