def OnButtonClickEditFile(self, event): selectedRowIndex = self.m_gridData.SelectedRows[0] itemID = int(self.m_gridData.GetCellValue(selectedRowIndex, 0)) name = self.m_gridData.GetCellValue(selectedRowIndex, 3) businessLogic = bl.BusinessLogic() if len(name) > 0: podFileShortcut = businessLogic.RetrievePodFileShortcutByPodFileShortcutID( itemID)['podfileshortcuts'][0] if True == self.LockPodForWriting(podFileShortcut["PodID"]): podFileId = podFileShortcut["PodFileID"] filename = podFileShortcut["Filename"] businessLogic = bl.BusinessLogic() podFileId = businessLogic.RetrieveTopRevisionFilePodIDByExistingPodFileIDFamily( podFileId)['podfileid'] uniquefolderid = str(uuid.uuid1()) os.mkdir(self.mainWindow.sandboxPath + '/' + uniquefolderid) self.mainWindow.transferEngine.DownloadFileAndWaitForCompletion( podFileId, filename, self.mainWindow.sandboxPath + '/' + uniquefolderid) localDal = dalsqlite.DalSqlite() podFile = businessLogic.RetrievePodFileByPodFileID( podFileId)['podfile'] podInformation = businessLogic.RetrieveFilePodInformation( podFileShortcut["PodID"]) localDal.AddFileInEdit(filename, uniquefolderid, podFile["PodParentFolderID"], podFileShortcut["PodID"], podInformation["pods"][0]["Name"]) if sys.platform == "win32": os.startfile(self.mainWindow.sandboxPath + '/' + uniquefolderid + '/' + filename) elif sys.platform == "darwin": subprocess.call([ 'open', self.mainWindow.sandboxPath + '/' + uniquefolderid + '/' + filename ]) else: subprocess.call([ "xdg-open", self.mainWindow.sandboxPath + '/' + uniquefolderid + '/' + filename ]) self.UnlockPod(podFileShortcut["PodID"])
def OnButtonClickCancelEditing(self, event): localdal = dalsqlite.DalSqlite() selectedRowIndex = self.m_gridData.SelectedRows[0] FileInEditID = self.m_gridData.GetCellValue(selectedRowIndex, 0) localdal.DeleteFileInEdit(FileInEditID) self.loadGridData()
def OnButtonClickEditingComplete(self, event): localdal = dalsqlite.DalSqlite() selectedRowIndex = self.m_gridData.SelectedRows[0] FileInEditID = self.m_gridData.GetCellValue(selectedRowIndex, 0) fileInEdit = localdal.RetrieveFileInEdit(FileInEditID)[0] podID = fileInEdit[4] parentFolderID = fileInEdit[3] uniquefolderid = fileInEdit[2] filename = fileInEdit[1] businessLogic = bl.BusinessLogic() folder = businessLogic.RetrieveFolderByFolderId(parentFolderID) if folder['IsDeleted'] == 0: self.mainWindow.transferEngine.UploadFileAndWaitForCompletion( podID, parentFolderID, self.mainWindow.sandboxPath + '/' + uniquefolderid + '/' + filename) localdal.DeleteFileInEdit(FileInEditID) self.loadGridData() wx.MessageBox( 'Your file has been re uploaded to its original file pod location', 'Leopard Data filePODS', wx.OK | wx.ICON_INFORMATION) else: recoveryDir = str(uuid.uuid1()) os.makedirs(self.mainWindow.recoveryPath + "/" + recoveryDir) shutil.move( self.mainWindow.sandboxPath + "/" + uniquefolderid + "/" + filename, self.mainWindow.recoveryPath + "/" + recoveryDir + "/" + filename) localdal.DeleteFileInEdit(FileInEditID) self.loadGridData() wx.MessageBox( 'The folder your file was originally part of has been deleted, we have moved your edited file to ' + self.mainWindow.recoveryPath + "/" + recoveryDir + "/" + filename + ", please go to this location on your computer to recover your file", 'Leopard Data filePODS', wx.OK | wx.ICON_INFORMATION)
def loadGridData(self): localdal = dalsqlite.DalSqlite() filesInEdit = localdal.RetrieveAllFilesInEdit() self.m_buttonEditingComplete.Disable() self.m_buttonCancelEditing.Disable() if (self.m_gridData.GetNumberRows() > 0): self.m_gridData.DeleteRows(0, 100000) self.m_gridData.AppendRows(len(filesInEdit)) for index, fileInEdit in enumerate(filesInEdit): self.m_gridData.SetCellValue(index, 0, str(fileInEdit[0])) self.m_gridData.SetCellValue(index, 1, fileInEdit[1]) self.m_gridData.SetCellValue(index, 2, fileInEdit[5]) self.m_gridData.SetSelectionMode(wx.grid.Grid.wxGridSelectRows) self.m_gridData.HideCol(0)