Jump to content


Photo

Sessions and screens


  • Please log in to reply
12 replies to this topic

#1 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 11 May 2015 - 10:54

I get an error in code for a plugin to control programs running on box.

Traceback (most recent call last):
  File "/usr/lib/enigma2/python/Tools/BoundFunction.py", line 9, in __call__
  File "/usr/lib/enigma2/python/Components/Console.py", line 56, in finishedCB
  File "/usr/lib/enigma2/python/Plugins/SystemPlugins/ServiceManager/plugin.py", line 122, in runCmdFinished
    callback(result.strip())
  File "/usr/lib/enigma2/python/Plugins/SystemPlugins/ServiceManager/plugin.py", line 596, in installFinished
    self.session.open(MessageBox, _("Package installed."), MessageBox.TYPE_INFO, timeout = 5)
  File "/usr/lib/enigma2/python/mytest.py", line 280, in open
    raise RuntimeError("modal open are allowed only from a screen which is modal!")
RuntimeError: modal open are allowed only from a screen which is modal!
<299925.100412> (PyObject_CallObject(<Tools.BoundFunction.boundFunction instance at 0x32db0a8>,(0,)) failed)
<299927.098680> [gRC] main thread is non-idle! display spinner!

it comes up after code that opens some messageboxes. Which Is the way for creating a message without timeout and close or delete it when an action is done?

i tried this but .... error

self.msg = self.session.open(MessageBox, _("Installing package..."), MessageBox.TYPE_INFO, enable_input=False)
self.msg.setTitle(_("Package installer"))

............... other code 

self.msg.close(True) or self.msg.close() or self.msg.close(0)

thanks to all

 

 

 



Re: Sessions and screens #2 Dimitrij

  • PLi® Core member
  • 9,993 posts

+338
Excellent

Posted 12 May 2015 - 09:02

We need a little time out...

def _init_

eTimer --->run message

200 ms

 

def run message(self):

self.session.open(MessageBox, _("Installing package..."), MessageBox.TYPE_INFO, enable_input=False)


GigaBlue UHD Quad 4K /Lunix3-4K/Solo 4K


Re: Sessions and screens #3 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 12 May 2015 - 13:27

Ola Dimitrij

 

i suspected a problem of timing for the calls to messageboxes, i will try to insert a method to run the sequence of messages, cause the error

rises at exec of second message after the close of the first one. work in progress.....

 

so thanks



Re: Sessions and screens #4 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 12 May 2015 - 15:07

I added a func creating the messages (# old lines). Same problem. mmmhhh

Looking at the func open in mytest.py i think that the second message (session) is called before the first is totally destroyed.

Is it possible?

# Session.open:
# * push current active dialog ('current_dialog') onto stack
# * call execEnd for this dialog
#   * clear in_exec flag
#   * hide screen
# * instantiate new dialog into 'current_dialog'
#   * create screens, components
#   * read, apply skin
#   * create GUI for screen
# * call execBegin for new dialog
#   * set in_exec
#   * show gui screen
#   * call components' / screen's onExecBegin
# ... screen is active, until it calls 'close'...
# Session.close:
# * assert in_exec
# * save return value
# * start deferred close handler ('onClose')
# * execEnd
#   * clear in_exec
#   * hide screen
# .. a moment later:      <<<<<<<< is this the problem?????
# Session.doClose:
# * destroy screen

the code:

	def runMessage(self, text, msgtype, timeout=-1):
		self.msg = self.session.open(MessageBox, text, msgtype, timeout)
		self.msg.setTitle(_("Package installer"))

	def installFinished(self, data):
		if data:
			self.msg.close()
			self.checkServiceListStatus([self.installpkg])
			if self.installpkg['status']:
				text = _("Package %s installed.") % self.installpkg['name']
				self["status"].setText(text)
---->>> here raises error	self.runMessage(text, MessageBox.TYPE_INFO, 2)
#				self.msg = self.session.open(MessageBox, _("Package %s installed.") % self.installpkg['name'], MessageBox.TYPE_INFO, timeout=2)
#				self.msg.setTitle(_("Package installer"))

				self.getPkgInfo()		
				self.updateServiceListState()
				self.updateEntryList()
			else:
				text = _("Could not install %s package...") % self.installpkg['name']
				self.runMessage(text, MessageBox.TYPE_ERROR, 5)				
#				self.msg = self.session.open(MessageBox, _("Could not install %s package...") % self.installpkg['name'], MessageBox.TYPE_ERROR, timeout=4)
				#self.msg.setTitle(_("Package installer"))
#				self["status"].setText( _("Could not install %s package!") % self.installpkg['name'])
				self["status"].setText(text)
	def installConfirm(self, confirmed):
		if confirmed:
			text = _("Installling %s...") % self.installpkg['name']
			self["status"].setText(text)
#			self["status"].setText(_("Installling %s...") % self.installpkg['name'])
#			self.msg = self.session.open(MessageBox, _("Installing %s...") % self.installpkg['name'], MessageBox.TYPE_INFO, enable_input=False)
#			self.msg.setTitle(_("Package installer"))
			self.runMessage(text, MessageBox.TYPE_INFO)
			self.sc.runCmd("opkg install %s" % self["list"].getCurrent()[5]['package'], self.installFinished)

	def selectService(self):
		current = self["list"].getCurrent()[5]
		if current is not None:
			if not current['status']:
				self.installpkg = current
---->>>> start here		self.session.openWithCallback(self.installConfirm, MessageBox, _("Do you want to install %s package?") % current['name'], MessageBox.TYPE_YESNO, timeout = 10, default = False)
				return
			self.curstate = current['state']
			self.session.openWithCallback(self.stateCallback, ServiceControlPanel, current)



Re: Sessions and screens #5 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 12 May 2015 - 15:13

error:

[ServiceController] run cmd finished - result: 'Installing transmission (2.84-r0.1) on root.
Downloading http://downloads.pli-images.org/feeds/openpli-4/mips32el/transmission_2.84-r0.1_mips32el.ipk.
 Removing any system startup links for transmission ...
 Adding system startup for /etc/init.d/transmission.
Starting transmission-daemon
Configuring transmission.'
[ServiceManager] service 'Transmission'  status 'True'
Traceback (most recent call last):
  File "/usr/lib/enigma2/python/Tools/BoundFunction.py", line 9, in __call__
  File "/usr/lib/enigma2/python/Components/Console.py", line 56, in finishedCB
  File "/usr/lib/enigma2/python/Plugins/SystemPlugins/ServiceManager/plugin.py", line 122, in runCmdFinished
    callback(result.strip())
  File "/usr/lib/enigma2/python/Plugins/SystemPlugins/ServiceManager/plugin.py", line 604, in installFinished
    self.runMessage(text, MessageBox.TYPE_INFO, 2)
  File "/usr/lib/enigma2/python/Plugins/SystemPlugins/ServiceManager/plugin.py", line 594, in runMessage
    self.msg = self.session.open(MessageBox, text, msgtype, timeout)
  File "/usr/lib/enigma2/python/mytest.py", line 280, in open
    raise RuntimeError("modal open are allowed only from a screen which is modal!")
RuntimeError: modal open are allowed only from a screen which is modal!
<576722.346189> (PyObject_CallObject(<Tools.BoundFunction.boundFunction instance at 0x245e698>,(0,)) failed)
<576726.243976> [gRC] main thread is non-idle! display spinner!
<576732.368094> poll: unhandled POLLERR/HUP/NVAL for fd 56(16)



Re: Sessions and screens #6 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 12 May 2015 - 15:20

the plug :)

 

Attached File  1_0_1_E1E_708_C8_820000_0_0_0.jpg   78.46KB   13 downloads



Re: Sessions and screens #7 Dimitrij

  • PLi® Core member
  • 9,993 posts

+338
Excellent

Posted 12 May 2015 - 16:40

if self.installpkg['status']:
		from enigma import eTimer
		self.pausetimer = eTimer()
		self.pausetimer.callback.append(self.runMessage)
		self.pausetimer.start(500, True)

def runMessage(self):
	self.msg = self.session.open(MessageBox, ....)
	self.msg.setTitle(_("Package installer"))

Edited by Dimitrij, 12 May 2015 - 16:41.

GigaBlue UHD Quad 4K /Lunix3-4K/Solo 4K


Re: Sessions and screens #8 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 12 May 2015 - 19:31

Something changes: no crash, but no "installed pkg" message either :o . It did not appear at all.

.........................



Re: Sessions and screens #9 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 12 May 2015 - 21:00

At the end timer does the job, but i do not understand why.

Why?

	def checkInstall(self):
		self.checkServiceListStatus([self.installpkg])
		if self.installpkg['status']:
			text = _("Package %s installed.") % self.installpkg['name']
			self["status"].setText(text)
			message = self.session.open(MessageBox, text, MessageBox.TYPE_INFO, timeout=4)
			message.setTitle(_("Package installer"))
			self.getPkgInfo()
			self.updateServiceListState()
			self.updateEntryList()
		else:
			text = _("Could not install %s package...") % self.installpkg['name']
			self["status"].setText(text)
			message = self.session.open(MessageBox, text, MessageBox.TYPE_ERROR, timeout=4)
			message.setTitle(_("Package installer"))

	def installFinished(self, data):
		if data:
			self.msg.close()
			if self.check_install:
				from enigma import eTimer
				self.pausetimer = eTimer()
				self.pausetimer.callback.append(self.checkInstall)
				self.pausetimer.start(200, True)

	def installConfirm(self, confirmed):
		if confirmed:
			self.check_install = True
			text = _("Installling %s...") % self.installpkg['name']
			self["status"].setText(text)
			self.msg = self.session.open(MessageBox, text, MessageBox.TYPE_INFO)
			self.msg.setTitle(_("Package installer"))
			self.sc.runCmd("opkg install %s" % self["list"].getCurrent()[5]['package'], self.installFinished)

	def selectService(self):
		current = self["list"].getCurrent()[5]
		if current is not None:
			if not current['status']:
				self.check_install = False
				self.installpkg = current
				self.session.openWithCallback(self.installConfirm, MessageBox, _("Do you want to install %s package?") % current['name'], MessageBox.TYPE_YESNO, default = False)
			else:
				self.curstate = current['state']
				self.session.openWithCallback(self.stateCallback, ServiceControlPanel, current)

Timer set is 200 here, but is it correct anytime? If the install process takes more time, or another func..... bah do not like using timer.

Can't i play with sessions/screens directly?



Re: Sessions and screens #10 pcd

  • Senior Member
  • 759 posts

+88
Good

Posted 13 May 2015 - 01:54

When you get an error like :-

 

RuntimeError: modal open are allowed only from a screen which is modal!

 

It is cured if the start of the screen is changed from (for example):-

 

self.onLayoutFinish.append(self.openTest)

 

to :-

 

self.onShown.append(self.openTest)

 

Regards.



Re: Sessions and screens #11 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 13 May 2015 - 08:05

thanks for the help to pcd too

messagebox screen, not main screen ok?

if i eliminate the check install messagebox (either for "installed ok" or "installed error") all goes right, the problem raises at opening that screen

Before this critic messagebox screen i opened and close the message for install process, a console running opkg install command.

Perhaps this message changes anything, cause if i set a timeout for it, instead of close it with the callback of console, no green screen!

But in this case the 2 timeouts are out of control, no sense because i experienced the situation of first timeout ending after te second, so nonsense.

That's why i asked about the correct modality for closing messageboxes:

self.msg = self.session.open(MessageBox, _("Installing package..."), MessageBox.TYPE_INFO, enable_input=False)
self.msg.setTitle(_("Package installer"))

............... other code 

self.msg.close()

i do not find in  enigma2 code examples of this use of messagebox, only scart.py screen if i remember well now..........



Re: Sessions and screens #12 pcd

  • Senior Member
  • 759 posts

+88
Good

Posted 13 May 2015 - 15:23

I do not fully understand your problem. But you may find in pli Messagebox here :-

 

http://sourceforge.net/p/openpli/enigma2/ci/master/tree/lib/python/Screens/MessageBox.py

 

the closing option in __init__:-

 

def __init__(self, session, text, type=TYPE_YESNO, timeout=-1, close_on_any_key=False, default=True, enable_input=True, msgBoxID=None, picon=None, simple=False, list=[], timeout_default=None):
 



Re: Sessions and screens #13 tension

  • Senior Member
  • 117 posts

+4
Neutral

Posted 14 May 2015 - 15:55

the problem was green screen caused by the second messagebox, opened before the first was totally cleaned.

the answer was... another callback

	def checkInstall(self):
		self.checkServiceListStatus([self.installpkg])
		if self.installpkg['status']:
			text = _("Package %s installed.") % self.installpkg['name']
			self["status"].setText(text)
			message = self.session.open(MessageBox, text, MessageBox.TYPE_INFO, timeout=4)
			message.setTitle(_("Package installer"))
			self.getPkgInfo([self.installpkg])
			self.updateServiceListState(self.serviceList)
			self["list"].setIndex(self.index)						
		else:
			text = _("Could not install %s package...") % self.installpkg['name']
			self["status"].setText(text)
			message = self.session.open(MessageBox, text, MessageBox.TYPE_ERROR, timeout=4)
			message.setTitle(_("Package installer"))
		self.installpkg = None

	def installFinished(self, data):
		if data:
			self.msg.close()

	def installConfirm(self, confirmed):
		if confirmed:
			text = _("Installling %s...") % self.installpkg['name']
			self["status"].setText(text)
	>>>>>>		self.msg = self.session.openWithCallback(self.checkInstall, MessageBox, text, MessageBox.TYPE_INFO, enable_input=False)
			self.msg.setTitle(_("Package installer"))
			self.sc.runCmd("opkg install %s" % self["list"].getCurrent()[5]['package'], self.installFinished)

	def selectService(self):
		current = self["list"].getCurrent()[5]
		if current is not None:
			self.index = self["list"].getIndex()
			if not current['status']:
				self.installpkg = current
				self.session.openWithCallback(self.installConfirm, MessageBox, _("Do you want to install %s package?") % current['name'], MessageBox.TYPE_YESNO, default = False)

open the message with the callback of check install at its close.

so no need of timer and no more crash

install confirm-> message installing -> run opkg cmd -> callback -> close message installing -> callback -> checkinstall

do not know why i have not seen this way before

 

thanks to volunteers, Dimitrij and pcd!




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users