lpcmanager

Parents 46652508c9b4
Children a35ef79f2019
Firmware update : don't handle connection on its own, just use the one from controller
--- a/LPCProjectController.py Thu Aug 09 09:38:15 2018 +0200
+++ b/LPCProjectController.py Tue Aug 21 10:02:06 2018 +0200
@@ -208,48 +208,7 @@
self.logger.write(_("Chunks size : %d KiB\n") % chunksSize)
self.logger.write(_("Reboot after update : %s\n") % ("Yes" if reboot else "No"))
- # Get the target PLC URI
- # Check if an uri is already configured in the Beremiz project
- uri = self.BeremizRoot.getURI_location()
- if uri is not None and uri != "":
- self.logger.write(_("PLC URI configured in the Beremiz project will be used: %s\n") % uri)
- else:
- # PLC URI is not configured in the Beremiz project
- # Launch Service Discovery dialog
- self.logger.write(_("PLC URI is not configured in the Beremiz project. Launching the Discover dialog\n"))
- dialog = DiscoveryDialog(self.AppFrame)
- answer = dialog.ShowModal()
- uri = dialog.GetURI()
- dialog.Destroy()
-
- # Nothing choosed or cancel button
- if uri is None or answer == wx.ID_CANCEL:
- self.logger.write_error(_("Connection canceled!\n"))
- self.logger.write_error(_("Firmware update canceled!\n"))
- self.firmwareUpadateIsRunning = False
- return
-
- # Get connector from uri
- self._connector = None
- try:
- self._SetConnector(connectors.ConnectorFactory(uri, self))
- except Exception:
- self.logger.write_error(_("Exception while connecting %s!\n") % uri)
- self.logger.write_error(traceback.format_exc())
- self.logger.write_error(_("Firmware update canceled!\n"))
- self.firmwareUpadateIsRunning = False
- return
-
- # Did connection success ?
- if self._connector is None:
- # Oups.
- self.logger.write_error(_("Connection failed to %s!\n") % uri)
- self.logger.write_error(_("Firmware update canceled!\n"))
- self.firmwareUpadateIsRunning = False
- return
- else:
- self.logger.write(_("Connected.\n"))
-
+
# Last confirmation before firmware update
answer = wx.MessageBox(_('Are you sure to launch the firmware update for the selected PLC?'),
_('Firmware Update'), wx.YES_NO | wx.CENTRE | wx.NO_DEFAULT,
@@ -258,6 +217,14 @@
self.logger.write_error(_("Firmware update canceled!\n"))
self.firmwareUpadateIsRunning = False
return
+
+ # do we still have a connection ?
+ if self._connector is None:
+ # Oups.
+ self.logger.write_error(_("Firmware update canceled because connection lost!\n"))
+ self.firmwareUpadateIsRunning = False
+ return
+
# Some cosmetics
self.AppFrame.Refresh()
self.AppFrame.Update()