Skip to content

Commit

Permalink
Added iCondition attribute/implementation to QtIfwOnFinishedDetachedE…
Browse files Browse the repository at this point in the history
…xec. Still ironing out some logic details with it for certain contexts, however...
  • Loading branch information
BuvinJ committed Jan 9, 2021
1 parent 2140fb9 commit 81e90be
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
34 changes: 22 additions & 12 deletions distbuilder/qt_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3336,11 +3336,17 @@ def __genFinishedClickedCallbackBody( self ):
prepend += (
(2*TAB) +
(SBLK
if ex.event == QtIfwOnFinishedCheckbox.ON_BOTH
if ex.event == QtIfwOnFinishedDetachedExec.ON_BOTH
else _QtIfwScript.ifInstalling( isNegated =
ex.event==QtIfwOnFinishedCheckbox.ON_UNINSTALL,
ex.event==QtIfwOnFinishedDetachedExec.ON_UNINSTALL,
isMultiLine=True ) ) +
ex._action +
(3*TAB) +
(SBLK
if ex.ifCondition is None
else _QtIfwScript.ifCondition( ex.ifCondition,
isMultiLine=True ) ) +
ex._action +
(3*TAB) + EBLK +
(2*TAB) + EBLK )
prepend += EBLK

Expand Down Expand Up @@ -6750,16 +6756,20 @@ def __init__( self, name, event=None,
runProgram=None, argList=None,
shellCmd=None, script=None,
openViaOsPath=None,
isReboot=False, rebootDelaySecs=2 ):
isReboot=False, rebootDelaySecs=2,
ifCondition=None ):

self.name = name
self.event =( QtIfwOnFinishedDetachedExec.ON_INSTALL if event is None
else event )
self.runProgram = None
self.argList = None
self.script = None
self.isReboot = isReboot
self._action = None
self.name = name
self.event =( QtIfwOnFinishedDetachedExec.ON_INSTALL if event is None
else event )

self.runProgram = None
self.argList = None
self.script = None
self.isReboot = isReboot

self.ifCondition = ifCondition
self._action = None

if isReboot: self.__setAsReboot( rebootDelaySecs )
elif isinstance( ifwPackage, QtIfwPackage ):
Expand Down
11 changes: 8 additions & 3 deletions examples/hello_dynamic_finish/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def customizeFinishedPage( cfg, tkPkg, cliPkg ):
'<br /><br />Thank you installing the <b>Tk Example</b>!' )
CLI_INSTALLED_MSG = Script.quote(
'<br /><br />Thank you installing the <b>CLI Example</b>!' )
LAUNCH_PY_PI_KEY = "launchPyPi"

# helper function
def showIfInstalled( checkbox, pkg, isChecked=True ):
Expand All @@ -192,6 +193,8 @@ def showIfInstalled( checkbox, pkg, isChecked=True ):
Script.setText( MSG_LBL, Script.getText( MSG_LBL ) +
CONCAT + CLI_INSTALLED_MSG,
varNames=False, isAutoQuote=False ) +
Script.setBoolValue(
LAUNCH_PY_PI_KEY, Script.isComponentInstalled( tkPkg ) ) +
showIfInstalled( runTkCheckbox, tkPkg ) +
showIfInstalled( runCliCheckbox, cliPkg ) +
openOnlineManualViaOsCheckbox.setChecked( True ) +
Expand All @@ -207,11 +210,13 @@ def showIfInstalled( checkbox, pkg, isChecked=True ):
rebootCheckbox.setVisible( True )
)

# Add detached executions invoked unconditionally upon the
# completion of the uninstaller.
# Add an automatic, but conditional, detached execution
# invoked post uninstallation.
openPyPiPageViaOsExec = QtIfwOnFinishedDetachedExec(
"openPyPiPageViaOs", QtIfwOnFinishedDetachedExec.ON_UNINSTALL,
openViaOsPath="https://pypi.org/project/distbuilder/" )
openViaOsPath="https://pypi.org/project/distbuilder/",
#ifCondition=Script.lookupBoolValue( LAUNCH_PY_PI_KEY ),
ifCondition=Script.toBool(True) )

cfg.controlScript.onFinishedDetachedExecutions = [
openPyPiPageViaOsExec
Expand Down

0 comments on commit 81e90be

Please sign in to comment.