Skip to content

Commit

Permalink
[Console] revert last commits
Browse files Browse the repository at this point in the history
  • Loading branch information
koivo committed Apr 24, 2019
1 parent 618d3d6 commit 5c47c71
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions lib/python/Screens/Console.py
Expand Up @@ -3,7 +3,6 @@
from Components.ActionMap import ActionMap
from Components.ScrollLabel import ScrollLabel
from Components.Sources.StaticText import StaticText
from Screens.MessageBox import MessageBox

class Console(Screen):
def __init__(self, session, title = "Console", cmdlist = None, finishedCallback = None, closeOnSuccess = False):
Expand All @@ -19,7 +18,7 @@ def __init__(self, session, title = "Console", cmdlist = None, finishedCallback
self["summary_description"] = StaticText("")
self["actions"] = ActionMap(["ColorActions", "WizardActions", "DirectionActions"],
{
"ok": self.ok,
"ok": self.cancel,
"back": self.cancel,
"up": self["text"].pageUp,
"down": self["text"].pageDown,
Expand All @@ -28,8 +27,7 @@ def __init__(self, session, title = "Console", cmdlist = None, finishedCallback

self.cmdlist = cmdlist
self.newtitle = title
self.cancel_cnt = 0
self.cancel_msg = None

self.onShown.append(self.updateTitle)

self.container = eConsoleAppContainer()
Expand All @@ -53,14 +51,16 @@ def runFinished(self, retval):
self.errorOcurred = True
self.run += 1
if self.run != len(self.cmdlist):
if self.doExec(self.cmdlist[self.run]): #start of container application failed...
if self.container.execute(self.cmdlist[self.run]): #start of container application failed...
self.runFinished(-1) # so we must call runFinished manual
else:
if self.cancel_msg:
self.cancel_msg.close()
lastpage = self["text"].isAtLastPage()
self["text"].appendText('\n' + _("Execution finished!!"))
self["summary_description"].setText('\n' + _("Execution finished!!"))
str = self["text"].getText()
str += _("\nExecution finished!!")
self["summary_description"].setText(_("\nExecution finished!!"))
self["text"].setText(str)
if lastpage:
self["text"].lastPage()
if self.finishedCallback is not None:
self.finishedCallback()
if not self.errorOcurred and self.closeOnSuccess:
Expand Down Expand Up @@ -94,26 +94,11 @@ def yellow(self):
self.show()
self.Shown = True

def ok(self):
def cancel(self):
if self.run == len(self.cmdlist):
self.cancel()

def cancel(self, force = False):
if self.cancel_msg is not None:
self.cancel_cnt = 0
self.cancel_msg = None
if not force:
return
self.cancel_cnt += 1
if force or self.run == len(self.cmdlist):
self.close()
self.container.appClosed.remove(self.runFinished)
self.container.dataAvail.remove(self.dataAvail)
if self.run != len(self.cmdlist):
self.container.kill()
elif self.cancel_cnt >= 3:
self.cancel_msg = self.session.openWithCallback(self.cancel, MessageBox, _("Cancel the Script?"), type=MessageBox.TYPE_YESNO, default=False)
self.cancel_msg.show()

def dataAvail(self, str):
lastpage = self["text"].isAtLastPage()
Expand Down

0 comments on commit 5c47c71

Please sign in to comment.