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,16 +36,15 @@ 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 None
|
||||
return
|
||||
self.releaseDevices()
|
||||
def getInputEvent(self):
|
||||
|
||||
if not self.hasIDevices():
|
||||
time.sleep(0.008) # dont flood CPU
|
||||
return None
|
||||
|
||||
event = None
|
||||
r, w, x = select(self.iDevices, [], [], self.env['runtime']['settingsManager'].getSettingAsFloat('screen', 'screenUpdateDelay'))
|
||||
if r != []:
|
||||
@ -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,30 +203,39 @@ class driver():
|
||||
# #'/dev/uinput'
|
||||
# )
|
||||
# dev.grab()
|
||||
|
||||
def releaseDevices(self):
|
||||
def removeDevice(self,fd):
|
||||
try:
|
||||
self.iDevices[fd].ungrab()
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
self.iDevices[fd].close()
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
self.uDevices[fd].close()
|
||||
except:
|
||||
pass
|
||||
def hasIDevices(self):
|
||||
if not self._initialized:
|
||||
return None
|
||||
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:
|
||||
try:
|
||||
self.iDevices[fd].ungrab()
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
self.iDevices[fd].close()
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
self.uDevices[fd].close()
|
||||
except:
|
||||
pass
|
||||
|
||||
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()
|
||||
|
||||
obj = bus.get_object(progname, objpath)
|
||||
inf = dbus.Interface(obj, intfname)
|
||||
meth = inf.get_dbus_method(methname)
|
||||
|
||||
sessions = meth()
|
||||
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')
|
||||
|
||||
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