1389 computer's time. |
1389 computer's time. |
1390 |
1390 |
1391 @param quiet flag indicating to not show a message |
1391 @param quiet flag indicating to not show a message |
1392 @type bool |
1392 @type bool |
1393 """ |
1393 """ |
1394 try: |
1394 if self.__device and self.__device.hasTimeCommands(): |
1395 self.__interface.syncTime() |
1395 try: |
1396 |
1396 self.__interface.syncTime(self.__device.getDeviceType()) |
1397 if not quiet: |
1397 |
1398 with E5OverridenCursor(): |
1398 if not quiet: |
1399 E5MessageBox.information( |
1399 with E5OverridenCursor(): |
1400 self, |
1400 E5MessageBox.information( |
1401 self.tr("Synchronize Time"), |
1401 self, |
1402 self.tr("<p>The time of the connected device was" |
1402 self.tr("Synchronize Time"), |
1403 " synchronized with the local time.</p>") + |
1403 self.tr("<p>The time of the connected device was" |
1404 self.__getDeviceTime() |
1404 " synchronized with the local time.</p>") + |
1405 ) |
1405 self.__getDeviceTime() |
1406 except Exception as exc: |
1406 ) |
1407 self.__showError("syncTime()", str(exc)) |
1407 except Exception as exc: |
|
1408 self.__showError("syncTime()", str(exc)) |
1408 |
1409 |
1409 def __getDeviceTime(self): |
1410 def __getDeviceTime(self): |
1410 """ |
1411 """ |
1411 Private method to get a string containing the date and time of the |
1412 Private method to get a string containing the date and time of the |
1412 connected device. |
1413 connected device. |
1413 |
1414 |
1414 @return date and time of the connected device |
1415 @return date and time of the connected device |
1415 @rtype str |
1416 @rtype str |
1416 """ |
1417 """ |
1417 try: |
1418 if self.__device and self.__device.hasTimeCommands(): |
1418 dateTimeString = self.__interface.getTime() |
|
1419 try: |
1419 try: |
1420 date, time = dateTimeString.strip().split(None, 1) |
1420 dateTimeString = self.__interface.getTime() |
1421 return self.tr( |
1421 try: |
1422 "<h3>Device Date and Time</h3>" |
1422 date, time = dateTimeString.strip().split(None, 1) |
1423 "<table>" |
1423 return self.tr( |
1424 "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
1424 "<h3>Device Date and Time</h3>" |
1425 "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
1425 "<table>" |
1426 "</table>" |
1426 "<tr><td><b>Date</b></td><td>{0}</td></tr>" |
1427 ).format(date, time) |
1427 "<tr><td><b>Time</b></td><td>{1}</td></tr>" |
1428 except ValueError: |
1428 "</table>" |
1429 return self.tr( |
1429 ).format(date, time) |
1430 "<h3>Device Date and Time</h3>" |
1430 except ValueError: |
1431 "<p>{0}</p>" |
1431 return self.tr( |
1432 ).format(dateTimeString.strip()) |
1432 "<h3>Device Date and Time</h3>" |
1433 except Exception as exc: |
1433 "<p>{0}</p>" |
1434 self.__showError("getTime()", str(exc)) |
1434 ).format(dateTimeString.strip()) |
|
1435 except Exception as exc: |
|
1436 self.__showError("getTime()", str(exc)) |
|
1437 return "" |
|
1438 else: |
1435 return "" |
1439 return "" |
1436 |
1440 |
1437 @pyqtSlot() |
1441 @pyqtSlot() |
1438 def __showDeviceTime(self): |
1442 def __showDeviceTime(self): |
1439 """ |
1443 """ |