263 self.filetypeByFlag = False |
263 self.filetypeByFlag = False |
264 self.noName = "" |
264 self.noName = "" |
265 self.project = ericApp().getObject("Project") |
265 self.project = ericApp().getObject("Project") |
266 self.setFileName(fn) |
266 self.setFileName(fn) |
267 |
267 |
268 self.__remotefsInterface = ericApp().getObject( |
268 self.__remotefsInterface = ( |
269 "EricServer" |
269 ericApp().getObject("EricServer").getServiceInterface("FileSystem") |
270 ).getServiceInterface("FileSystem") |
270 ) |
271 |
271 |
272 # clear some variables |
272 # clear some variables |
273 self.lastHighlight = None # remember the last highlighted line |
273 self.lastHighlight = None # remember the last highlighted line |
274 self.lastErrorMarker = None # remember the last error line |
274 self.lastErrorMarker = None # remember the last error line |
275 self.lastCurrMarker = None # remember the last current line |
275 self.lastCurrMarker = None # remember the last current line |
3773 if not fpath.suffix: |
3772 if not fpath.suffix: |
3774 ex = selectedFilter.split("(*")[1].split(")")[0] |
3773 ex = selectedFilter.split("(*")[1].split(")")[0] |
3775 if ex: |
3774 if ex: |
3776 fpath = fpath.with_suffix(ex) |
3775 fpath = fpath.with_suffix(ex) |
3777 if ( |
3776 if ( |
3778 ( |
3777 FileSystemUtilities.isRemoteFileName(str(fpath)) |
3779 FileSystemUtilities.isRemoteFileName(str(fpath)) |
3778 and self.__remotefsInterface.exists(str(fpath)) |
3780 and self.__remotefsInterface.exists(str(fpath)) |
3779 ) or (FileSystemUtilities.isPlainFileName(str(fpath)) and fpath.exists()): |
3781 ) |
|
3782 or (FileSystemUtilities.isPlainFileName(str(fpath)) and fpath.exists()) |
|
3783 ): |
|
3784 res = EricMessageBox.yesNo( |
3780 res = EricMessageBox.yesNo( |
3785 self, |
3781 self, |
3786 title, |
3782 title, |
3787 self.tr( |
3783 self.tr( |
3788 "<p>The file <b>{0}</b> already exists. Overwrite it?</p>" |
3784 "<p>The file <b>{0}</b> already exists. Overwrite it?</p>" |
6513 self.coverageShowAnnotationMenuAct.setEnabled( |
6509 self.coverageShowAnnotationMenuAct.setEnabled( |
6514 coEnable and len(self.notcoveredMarkers) == 0 |
6510 coEnable and len(self.notcoveredMarkers) == 0 |
6515 ) |
6511 ) |
6516 self.coverageHideAnnotationMenuAct.setEnabled(len(self.notcoveredMarkers) > 0) |
6512 self.coverageHideAnnotationMenuAct.setEnabled(len(self.notcoveredMarkers) > 0) |
6517 |
6513 |
6518 # disable actions not supporting eric-ide server |
|
6519 self.codeMetricsAct.setEnabled( |
|
6520 False if fn is None else FileSystemUtilities.isPlainFileName(fn) |
|
6521 ) |
|
6522 |
|
6523 # TODO: disable action in Radon plugin for server files |
6514 # TODO: disable action in Radon plugin for server files |
6524 self.showMenu.emit("Show", self.menuShow, self) |
6515 self.showMenu.emit("Show", self.menuShow, self) |
6525 |
6516 |
6526 @pyqtSlot() |
6517 @pyqtSlot() |
6527 def __showContextMenuGraphics(self): |
6518 def __showContextMenuGraphics(self): |
7054 fn = coverageFile if bool(coverageFile) else self.__getCodeCoverageFile() |
7045 fn = coverageFile if bool(coverageFile) else self.__getCodeCoverageFile() |
7055 self.__coverageFile = fn |
7046 self.__coverageFile = fn |
7056 |
7047 |
7057 if fn: |
7048 if fn: |
7058 if FileSystemUtilities.isRemoteFileName(fn): |
7049 if FileSystemUtilities.isRemoteFileName(fn): |
7059 coverageInterface = ericApp().getObject( |
7050 coverageInterface = ( |
7060 "EricServer" |
7051 ericApp().getObject("EricServer").getServiceInterface("Coverage") |
7061 ).getServiceInterface("Coverage") |
7052 ) |
7062 ok, error = coverageInterface.loadCoverageData(fn) |
7053 ok, error = coverageInterface.loadCoverageData(fn) |
7063 if not ok and not silent: |
7054 if not ok and not silent: |
7064 EricMessageBox.critical( |
7055 EricMessageBox.critical( |
7065 self, |
7056 self, |
7066 self.tr("Load Coverage Data"), |
7057 self.tr("Load Coverage Data"), |
8315 |
8306 |
8316 @param bForce True to force change, False to only update and emit |
8307 @param bForce True to force change, False to only update and emit |
8317 signal if there was an attribute change. |
8308 signal if there was an attribute change. |
8318 @type bool |
8309 @type bool |
8319 """ |
8310 """ |
8320 if self.fileName == "" or FileSystemUtilities.isDeviceFileName( |
8311 if self.fileName == "" or FileSystemUtilities.isDeviceFileName(self.fileName): |
8321 self.fileName |
|
8322 ): |
|
8323 return |
8312 return |
8324 |
8313 |
8325 readOnly = self.checkReadOnly() |
8314 readOnly = self.checkReadOnly() |
8326 if not bForce and (readOnly == self.isReadOnly()): |
8315 if not bForce and (readOnly == self.isReadOnly()): |
8327 return |
8316 return |
8346 and not os.access(self.fileName, os.W_OK) |
8335 and not os.access(self.fileName, os.W_OK) |
8347 ) |
8336 ) |
8348 or ( |
8337 or ( |
8349 FileSystemUtilities.isRemoteFileName(self.fileName) |
8338 FileSystemUtilities.isRemoteFileName(self.fileName) |
8350 and not self.__remotefsInterface.access( |
8339 and not self.__remotefsInterface.access( |
8351 FileSystemUtilities.plainFileName(self.fileName), "write") |
8340 FileSystemUtilities.plainFileName(self.fileName), "write" |
|
8341 ) |
8352 ) |
8342 ) |
8353 or self.isReadOnly() |
8343 or self.isReadOnly() |
8354 ) |
8344 ) |
8355 |
8345 |
8356 @pyqtSlot() |
8346 @pyqtSlot() |
8436 FileSystemUtilities.isRemoteFileName(filename) |
8426 FileSystemUtilities.isRemoteFileName(filename) |
8437 and not self.dbs.isDebugging |
8427 and not self.dbs.isDebugging |
8438 ): |
8428 ): |
8439 plainFilename = FileSystemUtilities.plainFileName(filename) |
8429 plainFilename = FileSystemUtilities.plainFileName(filename) |
8440 if self.__remotefsInterface.exists(plainFilename): |
8430 if self.__remotefsInterface.exists(plainFilename): |
8441 mtime = self.__remotefsInterface.stat( |
8431 mtime = self.__remotefsInterface.stat(plainFilename, ["st_mtime"])[ |
8442 plainFilename, ["st_mtime"] |
8432 "st_mtime" |
8443 )["st_mtime"] |
8433 ] |
8444 return mtime != self.lastModified |
8434 return mtime != self.lastModified |
8445 |
8435 |
8446 elif ( |
8436 elif ( |
8447 FileSystemUtilities.isPlainFileName(filename) |
8437 FileSystemUtilities.isPlainFileName(filename) |
8448 and pathlib.Path(filename).exists() |
8438 and pathlib.Path(filename).exists() |