speed up dbus logind interface creation
This commit is contained in:
parent
92691d5ae4
commit
4075cd78b4
@ -35,8 +35,8 @@ class fenrir():
|
||||
self.shutdown()
|
||||
|
||||
def handleProcess(self):
|
||||
#startTime = time.time()
|
||||
eventReceived = self.environment['runtime']['inputManager'].getInputEvent()
|
||||
startTime = time.time()
|
||||
if eventReceived:
|
||||
self.prepareCommand()
|
||||
if not (self.wasCommand or self.environment['generalInformation']['tutorialMode']) or self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
@ -65,7 +65,7 @@ class fenrir():
|
||||
self.environment['runtime']['commandManager'].executeDefaultTrigger('onScreenUpdate')
|
||||
#self.environment['runtime']['outputManager'].brailleText(flush=False)
|
||||
self.handleCommands()
|
||||
#print(time.time()-startTime)
|
||||
print(time.time()-startTime)
|
||||
|
||||
def prepareCommand(self):
|
||||
if self.environment['runtime']['screenManager'].isSuspendingScreen():
|
||||
@ -84,7 +84,6 @@ class fenrir():
|
||||
|
||||
self.environment['runtime']['commandManager'].queueCommand(command)
|
||||
|
||||
|
||||
def handleCommands(self):
|
||||
if not self.environment['runtime']['commandManager'].isCommandQueued():
|
||||
return
|
||||
|
@ -36,14 +36,13 @@ class driver():
|
||||
self.getInputDevices()
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
def getInputEvent(self):
|
||||
if not self._initialized:
|
||||
time.sleep(0.005) # dont flood CPU
|
||||
return None
|
||||
if not self.iDevices:
|
||||
return None
|
||||
if self.iDevices == {}:
|
||||
return
|
||||
self.releaseDevices()
|
||||
def getInputEvent(self):
|
||||
|
||||
if not self.hasIDevices():
|
||||
time.sleep(0.008) # dont flood CPU
|
||||
return None
|
||||
|
||||
event = None
|
||||
@ -54,7 +53,7 @@ class driver():
|
||||
event = self.iDevices[fd].read_one()
|
||||
except:
|
||||
#print('jow')
|
||||
del(self.iDevices[fd])
|
||||
self.removeDevice(fd)
|
||||
return None
|
||||
foreward = False
|
||||
while(event):
|
||||
@ -146,7 +145,7 @@ class driver():
|
||||
|
||||
def getLedState(self, led = 0):
|
||||
if not self._initialized:
|
||||
return None
|
||||
return False
|
||||
# 0 = Numlock
|
||||
# 1 = Capslock
|
||||
# 2 = Rollen
|
||||
@ -168,7 +167,7 @@ class driver():
|
||||
self.ledDevices[i].set_led(led , 1)
|
||||
def grabDevices(self):
|
||||
if not self._initialized:
|
||||
return None
|
||||
return
|
||||
for fd in self.iDevices:
|
||||
try:
|
||||
self.uDevices[fd] = UInput.from_device(self.iDevices[fd].fn)
|
||||
@ -204,11 +203,7 @@ class driver():
|
||||
# #'/dev/uinput'
|
||||
# )
|
||||
# dev.grab()
|
||||
|
||||
def releaseDevices(self):
|
||||
if not self._initialized:
|
||||
return None
|
||||
for fd in self.iDevices:
|
||||
def removeDevice(self,fd):
|
||||
try:
|
||||
self.iDevices[fd].ungrab()
|
||||
except:
|
||||
@ -221,13 +216,26 @@ class driver():
|
||||
self.uDevices[fd].close()
|
||||
except:
|
||||
pass
|
||||
def hasIDevices(self):
|
||||
if not self._initialized:
|
||||
return False
|
||||
if not self.iDevices:
|
||||
return False
|
||||
if len(self.iDevices) == 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def releaseDevices(self):
|
||||
if not self.hasIDevices():
|
||||
return
|
||||
for fd in self.iDevices:
|
||||
self.removeDevice(fd)
|
||||
self.iDevices.clear()
|
||||
self.uDevices.clear()
|
||||
|
||||
def __del__(self):
|
||||
if not self._initialized:
|
||||
return None
|
||||
self.releaseDevices()
|
||||
return
|
||||
self.shutdown()
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@ from utils import screen_utils
|
||||
class driver():
|
||||
def __init__(self):
|
||||
self.vcsaDevicePath = '/dev/vcsa'
|
||||
self.ListSessions = None
|
||||
def initialize(self, environment):
|
||||
self.env = environment
|
||||
def shutdown(self):
|
||||
@ -62,24 +63,18 @@ class driver():
|
||||
return
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut(str(e),debug.debugLevel.ERROR)
|
||||
return
|
||||
|
||||
def getSessionInformation(self):
|
||||
progname = 'org.freedesktop.login1'
|
||||
objpath = '/org/freedesktop/login1'
|
||||
intfname = 'org.freedesktop.login1.Manager'
|
||||
methname = 'ListSessions'
|
||||
|
||||
bus = dbus.SystemBus()
|
||||
if not self.ListSessions:
|
||||
obj = bus.get_object('org.freedesktop.login1', '/org/freedesktop/login1')
|
||||
inf = dbus.Interface(obj, 'org.freedesktop.login1.Manager')
|
||||
self.ListSessions = inf.get_dbus_method('ListSessions')
|
||||
|
||||
obj = bus.get_object(progname, objpath)
|
||||
inf = dbus.Interface(obj, intfname)
|
||||
meth = inf.get_dbus_method(methname)
|
||||
|
||||
sessions = meth()
|
||||
sessions = self.ListSessions()
|
||||
self.env['screenData']['autoIgnoreScreens'] = []
|
||||
for session in sessions:
|
||||
obj = bus.get_object(progname, session[4])
|
||||
obj = bus.get_object('org.freedesktop.login1', session[4])
|
||||
inf = dbus.Interface(obj, 'org.freedesktop.DBus.Properties')
|
||||
sessionType = inf.Get('org.freedesktop.login1.Session', 'Type')
|
||||
screen = str(inf.Get('org.freedesktop.login1.Session', 'TTY'))
|
||||
|
Loading…
Reference in New Issue
Block a user