--- a/eric6/MicroPython/MicroPythonWidget.py Wed Aug 21 16:31:03 2019 +0200 +++ b/eric6/MicroPython/MicroPythonWidget.py Thu Aug 22 15:47:14 2019 +0200 @@ -847,7 +847,8 @@ if self.__interface.connectToDevice(port): self.__setConnected(True) - if Preferences.getMicroPython("SyncTimeAfterConnect"): + if (Preferences.getMicroPython("SyncTimeAfterConnect") and + self.__device.hasTimeCommands()): self.__synchronizeTime(quiet=True) else: E5MessageBox.warning( @@ -1107,16 +1108,18 @@ act = self.__superMenu.addAction( self.tr("Show Device Time"), self.__showDeviceTime) act.setEnabled(self.__connected) - self.__superMenu.addAction( - self.tr("Show Local Time"), self.__showLocalTime) - self.__superMenu.addSeparator() + self.__superMenu.addAction( + self.tr("Show Local Time"), self.__showLocalTime) + self.__superMenu.addSeparator() if not Globals.isWindowsPlatform(): - self.__superMenu.addAction( + available = self.__mpyCrossAvailable() + act = self.__superMenu.addAction( self.tr("Compile Python File"), self.__compileFile2Mpy) + act.setEnabled(available) act = self.__superMenu.addAction( self.tr("Compile Current Editor"), self.__compileEditor2Mpy) aw = e5App().getObject("ViewManager").activeWindow() - act.setEnabled(bool(aw)) + act.setEnabled(available and bool(aw)) self.__superMenu.addSeparator() if self.__device: self.__device.addDeviceMenuEntries(self.__superMenu) @@ -1275,6 +1278,25 @@ " device.</p><p>Method: {0}</p><p>Message: {1}</p>") .format(method, error)) + def __mpyCrossAvailable(self): + """ + Private method to check the availability of mpy-cross. + + @return flag indicating the availability of mpy-cross + @rtype bool + """ + available = False + program = Preferences.getMicroPython("MpyCrossCompiler") + if not program: + program = "mpy-cross" + if Utilities.isinpath(program): + available = True + else: + if Utilities.isExecutable(program): + available = True + + return available + def __crossCompile(self, pythonFile="", title=""): """ Private method to cross compile a Python file to a .mpy file.