Skip to content

Commit

Permalink
fixed: PackageManager crashes when reinitializing database
Browse files Browse the repository at this point in the history
  • Loading branch information
kwindrem committed Aug 14, 2023
1 parent 73cf6ea commit bb4f5b6
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 46 deletions.
14 changes: 4 additions & 10 deletions FileSets/PageSettingsPackageManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ MbPage {
property string settingsPrefix: "com.victronenergy.settings/Settings/PackageManager"
property string servicePrefix: "com.victronenergy.packageManager"
property string bindVrmloggerPrefix: "com.victronenergy.logger"
VBusItem { id: downloadStatus; bind: Utils.path(servicePrefix, "/GitHubUpdateStatus") }
VBusItem { id: installStatus; bind: Utils.path(servicePrefix, "/InstallStatus") }
VBusItem { id: pmStatus; bind: Utils.path(servicePrefix, "/PmStatus") }
VBusItem { id: mediaStatus; bind: Utils.path(servicePrefix, "/MediaUpdateStatus") }
VBusItem { id: actionNeeded; bind: Utils.path(servicePrefix, "/ActionNeeded") }
VBusItem { id: editAction; bind: Utils.path(servicePrefix, "/GuiEditAction") }
property bool showInstallStatus: installStatus.valid && installStatus.value != ""
property bool showMediaStatus: mediaStatus.valid && mediaStatus.value != ""
property bool showControls: installStatus.valid
property bool showControls: pmStatus.valid

model: VisibleItemModel
{
Expand All @@ -27,15 +25,11 @@ MbPage {
text:
{
if (! showControls)
return"Package manager not running"
else if (installStatus.valid && installStatus.value != "")
return installStatus.value
return "Package manager not running"
else if (mediaStatus.valid && mediaStatus.value != "")
return mediaStatus.value
else if (downloadStatus.valid && downloadStatus.value != "")
return downloadStatus.value
else
return "idle"
return pmStatus.value
}
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
Expand Down
2 changes: 0 additions & 2 deletions FileSets/PageSettingsPmInitialize.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ MbPage {
property string settingsPrefix: "com.victronenergy.settings/Settings/PackageManager"
property bool pmRunning: installStatus.valid

property VBusItem editAction: VBusItem { bind: Utils.path(servicePrefix, "/GuiEditAction") }
VBusItem { id: installStatus; bind: Utils.path(servicePrefix, "/InstallStatus") }
property bool showInProgress: false

onPmRunningChanged: { showInProgress = false }
Expand Down
56 changes: 24 additions & 32 deletions PackageManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,7 @@
#
# /GuiEditStatus a text message to report edit status to the GUI
#
# /GitHubUpdateStatus as above for automatic GitHub update
#
# /InstallStatus as above for automatic install/uninstall
# /PmStatus as above for main Package Manager status
#
# /MediaUpdateStatus as above for SD/USB media transfers
#
Expand Down Expand Up @@ -450,7 +448,7 @@

def PushAction (command=None, source=None):
parts = command.split (":")
queue = None
theQueue = None
if len (parts) >= 1:
action = parts[0]
else:
Expand All @@ -465,18 +463,18 @@ def PushAction (command=None, source=None):
if package != None:
package.DownloadPending = True
DbusIf.UNLOCK ()
queue = DownloadGitHub.DownloadQueue
theQueue = DownloadGitHub.DownloadQueue
queueText = "Download"
elif action == 'install' or action == 'uninstall':
DbusIf.LOCK ()
package = PackageClass.LocatePackage (packageName)
if package != None:
package.InstallPending = True
DbusIf.UNLOCK ()
queue = InstallPackages.InstallQueue
theQueue = InstallPackages.InstallQueue
queueText = "Install"
elif action == 'add' or action == 'remove':
queue = AddRemove.AddRemoveQueue
theQueue = AddRemove.AddRemoveQueue
queueText = "AddRemove"
elif action == 'reboot':
logging.warning ( "received Reboot request from " + source)
Expand All @@ -503,13 +501,13 @@ def PushAction (command=None, source=None):
logging.error ("PushAction received unrecognized command: " + command)
return

if queue != None:
if theQueue != None:
try:
queue.put ( (command, source), block=False )
theQueue.put ( (command, source), block=False )
except queue.Full:
logging.error ("command " + command + " from " + source + " lost - " + ququeText + " - queue full")
logging.error ("command " + command + " from " + source + " lost - " + queueText + " - queue full")
except:
logging.error ("command " + command + " from " + source + " lost - " + ququeText + " - other queue error")
logging.error ("command " + command + " from " + source + " lost - " + queueText + " - other queue error")
# end PushAction


Expand Down Expand Up @@ -651,7 +649,7 @@ class AddRemoveClass (threading.Thread):

def __init__(self):
threading.Thread.__init__(self)
self.AddRemoveQueue = queue.Queue (maxsize = 10)
self.AddRemoveQueue = queue.Queue (maxsize = 50)
self.threadRunning = True


Expand Down Expand Up @@ -924,8 +922,7 @@ def TransferOldDbusPackageInfo (cls):
# updates the status when the operation completes
# the GUI provides three different areas to show status
# where specifies which of these are updated
# 'Download'
# 'Install'
# 'PmStatus'
# 'Editor'
# 'Media'
# which determines where status is sent
Expand All @@ -947,10 +944,8 @@ def UpdateStatus ( self, message=None, where=None, logLevel=0 ):

if where == 'Editor':
DbusIf.SetEditStatus ( message )
elif where == 'Install':
DbusIf.SetInstallStatus ( message )
elif where == 'Download':
DbusIf.SetGitHubUpdateStatus (message)
elif where == 'PmStatus':
DbusIf.SetPmStatus ( message )
elif where == 'Media':
DbusIf.SetMediaStatus (message)

Expand Down Expand Up @@ -986,10 +981,8 @@ def GetAutoInstall (self):
return self.DbusSettings['autoInstall']
def SetAutoInstall (self, value):
self.DbusSettings['autoInstall'] = value
def SetGitHubUpdateStatus (self, value):
self.DbusService['/GitHubUpdateStatus'] = value
def SetInstallStatus (self, value):
self.DbusService['/InstallStatus'] = value
def SetPmStatus (self, value):
self.DbusService['/PmStatus'] = value
def SetMediaStatus (self, value):
self.DbusService['/MediaUpdateStatus'] = value

Expand Down Expand Up @@ -1174,8 +1167,7 @@ def __init__(self):
processname = 'PackageManager', processversion = 1.0, connection = 'none',
deviceinstance = 0, productid = 1, productname = 'Package Manager',
firmwareversion = 1, hardwareversion = 0, connected = 1)
self.DbusService.add_path ( '/GitHubUpdateStatus', "", writeable = True )
self.DbusService.add_path ( '/InstallStatus', "", writeable = True )
self.DbusService.add_path ( '/PmStatus', "", writeable = True )
self.DbusService.add_path ( '/MediaUpdateStatus', "", writeable = True )
self.DbusService.add_path ( '/GuiEditStatus', "", writeable = True )

Expand Down Expand Up @@ -2325,7 +2317,7 @@ def GitHubDownload (self, packageName= None, source=None):
if source == 'GUI':
where = 'Editor'
elif source == 'AUTO':
where = 'Download'
where = 'PmStatus'
else:
where = None

Expand Down Expand Up @@ -2565,7 +2557,7 @@ class InstallPackagesClass (threading.Thread):

def __init__(self):
threading.Thread.__init__(self)
DbusIf.SetInstallStatus ("")
DbusIf.SetPmStatus ("")
self.threadRunning = True
self.InstallQueue = queue.Queue (maxsize = 10)

Expand Down Expand Up @@ -2596,7 +2588,7 @@ def InstallPackage ( self, packageName=None, source=None , direction='install' )
package.UpdateDoNotInstall (True)
logging.warning (packageName + " was manually installed - allowing auto install for that package")
elif source == 'AUTO':
sendStatusTo = 'Install'
sendStatusTo = 'PmStatus'

packageDir = "/data/" + packageName
if not os.path.isdir (packageDir):
Expand Down Expand Up @@ -3573,11 +3565,11 @@ def mainLoop():
DbusIf.SetActionNeeded ('')

if statusMessage != "":
DbusIf.UpdateStatus ( statusMessage, where='Download' )
DbusIf.UpdateStatus ( statusMessage, where='PmStatus' )
elif actionMessage != "":
DbusIf.UpdateStatus ( actionMessage, where='Download' )
DbusIf.UpdateStatus ( actionMessage, where='PmStatus' )
else:
DbusIf.UpdateStatus ( idleMessage, where='Download' )
DbusIf.UpdateStatus ( idleMessage, where='PmStatus' )

elapsedTime = time.time() - startTime
# enable the following line to report execution time of main loop
Expand Down Expand Up @@ -3803,7 +3795,7 @@ def main():

# auto uninstall triggered by AUTO_UNINSTALL_PACKAGES flag file on removable media
if MediaScan.AutoUninstall:
DbusIf.UpdateStatus ( message="UNINSTALLING ALL PACKAGES & REBOOTING ...", where='Download')
DbusIf.UpdateStatus ( message="UNINSTALLING ALL PACKAGES & REBOOTING ...", where='PmStatus')
DbusIf.UpdateStatus ( message="UNINSTALLING ALL PACKAGES & REBOOTING ...", where='Editor' )
logging.warning (">>>> UNINSTALLING ALL PACKAGES & REBOOTING...")

Expand All @@ -3813,7 +3805,7 @@ def main():
SetupHelperUninstall = removeAllPackages ()

elif SystemReboot:
DbusIf.UpdateStatus ( message="REBOOTING ...", where='Download')
DbusIf.UpdateStatus ( message="REBOOTING ...", where='PmStatus')
DbusIf.UpdateStatus ( message="REBOOTING ...", where='Editor' )
logging.warning (">>>> REBOOTING: to complete package installation")

Expand Down
2 changes: 1 addition & 1 deletion blindInstall/SetupHelperVersion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v4.42
v4.43
4 changes: 4 additions & 0 deletions changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v4.43:
fixed: PackageManager crashes when reinitializing database
fixed stuck Package Manager status messages

v4.42:
fixed: updated services are not always restarted
add ExtTransferSwitch to default package list
Expand Down
Binary file modified venus-data.UninstallPackages.tgz
Binary file not shown.
Binary file modified venus-data.tgz
Binary file not shown.
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v4.42
v4.43

0 comments on commit bb4f5b6

Please sign in to comment.