def getSelectedTracks(self): """ This returns a list of track model instances corresponding to the track nodes that are currently selected. To achieve this, it first runs a remote script to get a list of track UIDs from the selected Maya track nodes. A list of the corresponding track models is then returned. """ conn = nimble.getConnection() result = conn.runPythonModule(GetSelectedUidList, runInMaya=True ) # Check to see if the remote command execution was successful if not result.success: PyGlassBasicDialogManager.openOk( self, 'Failed UID Query', 'Unable to get selected UID list from Maya', 'Error') return None # from this UID list, create the corresponding track list selectedUidList = result.payload['selectedUidList'] if len(selectedUidList) == 0: return None tracks = list() for uid in selectedUidList: track = self.getTrackByUid(uid) if track: track.updateFromNode() tracks.append(track) return tracks
def _handleAddApp(self): defaultPath = self.appConfig.get('LAST_APP_PATH', OsUtils.getDocumentsPath()) path = PyGlassBasicDialogManager.browseForDirectory( parent=self, caption=StringUtils.dedent(""" Specify the root path to a PyGlass application, in which a resource folder resides"""), defaultPath=defaultPath) if not path: return label = PyGlassBasicDialogManager.openTextQuery( parent=self, header='Enter Application Name', message='Specify the name of this application for display within Alembic Migrator', defaultText=os.path.basename(path.rstrip(os.sep)) ) apps = self.appConfig.get('APPLICATIONS', dict()) appData = { 'label':label, 'path':path, 'databases':dict(), 'id':TimeUtils.getUidTimecode('App', StringUtils.slugify(label))} apps[appData['id']] = appData self.appConfig.set('APPLICATIONS', apps) self.refresh() resultItem = self.appsListWidget.findItems(appData['id'], QtCore.Qt.MatchExactly) if resultItem: resultItem[0].setSelected(True)
def getSelectedTokenUids(self): """ This returns a list of URL of the currently selected tokens, or None. """ conn = nimble.getConnection() result = conn.runPythonModule(GetSelectedUidList, runInMaya=True) # Check to see if the remote command execution was successful if not result.success: PyGlassBasicDialogManager.openOk( self, 'Failed UID Query', 'Unable to get selected UID list from Maya', 'Error') return None selectedUidList = result.payload['selectedUidList'] if len(selectedUidList) == 0: return None # return those UIDs corresponding to proxies or tokens tokenUidList = list() for uid in selectedUidList: if uid.endswith('_proxy') or uid.endswith('_token'): tokenUidList.append(uid) return tokenUidList
def getSelectedTokenUid(self): """ This returns the URL of the currently selected token, or None. """ conn = nimble.getConnection() result = conn.runPythonModule(GetSelectedUidList, runInMaya=True) # Check to see if the remote command execution was successful if not result.success: PyGlassBasicDialogManager.openOk( self, 'Failed UID Query', 'Unable to get selected UID list from Maya', 'Error') return None selectedUidList = result.payload['selectedUidList'] if len(selectedUidList) == 0: return None # check to see if it really is a proxy or token that was selected uid = selectedUidList[0] if uid.endswith('_proxy') or uid.endswith('_token'): return uid else: return None
def _handleInitializeSceneClick(self): conn = nimble.getConnection() result = conn.runPythonModule(InitializeTrackwayScene) if not result.success: header = u'Failed' message = u'Unable to initialize your Maya scene' PyGlassBasicDialogManager.openOk( self.mainWindow, header, message, u'Initialize Scene') self._iniBtn.setText(u'Reinitialize')
def _handleTrackNodesCreated(self, event): result = event.target.output if not result.success: PyGlassBasicDialogManager.openOk( parent=self, header=u'Load Error', message=u'Unable to load tracks') else: PyGlassBasicDialogManager.openOk( parent=self, header=str(event.target.userData['count']) + ' Tracks Created') self.mainWindow.hideLoading(self)
def _handleDeploymentExecutionComplete(self, event): self._serverThread.completeSignal.signal.disconnect(self._handleDeploymentExecutionComplete) self._serverThread.logSignal.signal.disconnect(self._handleLogData) self._serverThread = None if not event.target.success: PyGlassBasicDialogManager.openOk( parent=self, header=u'Deployment Failed', message=u'An error caused the site deployment to fail') self.mainWindow.updateStatusBar(u'Deployment FAILED') else: self.mainWindow.updateStatusBar(u'Deployment SUCCESS') self._closeBtn.setEnabled(True)
def _handleImportSitemaps(self): self.mainWindow.showLoading( self, u'Browsing for Sitemap File', u'Choose the Sitemap CSV file to import into the database') path = PyGlassBasicDialogManager.browseForFileOpen( parent=self, caption=u'Select CSV File to Import', defaultPath=self.mainWindow.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH) ) self.mainWindow.hideLoading(self) if not path or not StringUtils.isStringType(path): self.mainWindow.toggleInteractivity(True) return # Store directory location as the last active directory self.mainWindow.appConfig.set( UserConfigEnum.LAST_BROWSE_PATH, FileUtils.getDirectoryOf(path) ) self.mainWindow.showStatus( self, u'Importing Sitemaps', u'Reading sitemap information into database') SitemapImporterRemoteThread( parent=self, path=path ).execute( callback=self._sitemapImportComplete, logCallback=self._handleImportStatusUpdate)
def _handleUpdateLinks(self): result = PyGlassBasicDialogManager.openYesNo( self, u'Confirm Linkages Reset', u'Are you sure you want to reset the selected trackway linkages?', False) if not result: return session = Tracks_Track.MASTER.createSession() entries = self._getFilteredTracks(session) self.mainWindow.showStatus( self, u'Resetting Linkages', u'Updating linkages to their default values') thread = TrackLinkageRemoteThread( parent=self, session=session, tracks=entries) thread.userData = session thread.execute( callback=self._handleLinkagesComplete, logCallback=self._handleLinkagesStatusUpdate)
def _handleLocatePath(self): self.refreshGui() path = PyGlassBasicDialogManager.browseForDirectory( parent=self, caption=u'Specify Static Flow Project Path') if path: self._pathLineEdit.setText(path)
def _handleImportComplete(self, event): actionType = 'Export' if isinstance(self._thread, TrackExporterRemoteThread) else 'Import' if not event.target.success: print('ERROR: %s Failed' % actionType) print(' OUTPUT:', event.target.output) print(' ERROR:', event.target.error) PyGlassBasicDialogManager.openOk( parent=self, header='ERROR', message='%s operation failed' % actionType) else: PyGlassBasicDialogManager.openOk( parent=self, header='Success', message='%s operation complete' % actionType) self.mainWindow.showStatusDone(self)
def _handleInitializeDatabase(self): self.mainWindow.showLoading(self) self.refreshGui() if AlembicUtils.initializeDatabase( databaseUrl=self.currentDatabaseUrl, resourcesPath=self.currentAppResourcesPath, localResourcesPath=self.currentLocalAppResourcesPath): PyGlassBasicDialogManager.openOk( self, 'Initialization Complete', 'Alembic migration environment created.') else: PyGlassBasicDialogManager.openOk( self, 'Initialization Aborted', 'Alembic migration already exists.') self.mainWindow.hideLoading(self)
def _handleCompileEvent(self, event): if event.id == ANECompileThread.STAGE_COMPLETE: response = PyGlassBasicDialogManager.openYesNo( self, event.get('type') + ' Notification (Paused)', event.get('message') + '\nContinue to next step?') if response: event.target.resumeQueueProcessing() else: event.target.abortQueueProcessing()
def getUidList(self): """ Returns a list of the UIDs of all track nodes currently loaded into Maya. """ conn = nimble.getConnection() result = conn.runPythonModule(GetUidList, runInMaya=True) # and check to see if the remote command execution was successful if not result.success: PyGlassBasicDialogManager.openOk( parent=self, header='ERROR', message='Unable to get UID list from Maya') self.closeSession() return None self.closeSession() return result.payload['uidList']
def _handleResetDeployInfo(self): result = PyGlassBasicDialogManager.openYesNo( parent=self, header=u'Reset Deploy Information', message=u'Are you sure you want to reset the deployment information fields?', defaultToYes=False) if not result: return settings = SettingsConfig(CompilerDeckEnvironment.projectSettingsPath, pretty=True) settings.remove(['DEPLOY', 'STORED'])
def _handleCreate(self): self.mainWindow.showLoading(self) self.refreshGui() mainWidget = self.mainWindow.getWidgetFromID('main') AlembicUtils.createRevision( databaseUrl=mainWidget.currentDatabaseUrl, message=self.migrationTitle, resourcesPath=mainWidget.currentAppResourcesPath, localResourcesPath=mainWidget.currentLocalAppResourcesPath, info=self.migrationInfo) PyGlassBasicDialogManager.openOk( parent=self, header='New Revision Created', message='New migration revision file has been created.') self.mainWindow.hideLoading(self) mainWidget.refresh() self.mainWindow.setActiveWidget('main')
def _handleRemoteDeploy(self): result = PyGlassBasicDialogManager.openYesNo( self, u'Confirm Remote Deploy', u'Are you sure you want to deploy this project?', False) if not result: return print u'Beginning Remote Deployment...' self._executeDeployment(DeploymentTypeEnum.REMOTE_DEPLOY)
def _handleRemoveDatabase(self): result = PyGlassBasicDialogManager.openYesNo( parent=self, header='Confirm Delete', message='Are you sure you want to remove the "%s" database from this app?' % self.currentDatabaseName, defaultToYes=False) if not result: return apps = self.appConfig.get('APPLICATIONS') appData = apps[self.currentAppID] databases = appData['databases'] del databases[self.currentDatabaseID] self.appConfig.set('APPLICATIONS', apps) self._refreshAppDisplay()
def _handleExport(self): self.mainWindow.showLoading( self, u'Browsing for Exporting File', u'Choose the file location to save the export') defaultPath = self.mainWindow.appConfig.get(UserConfigEnum.LAST_SAVE_PATH) if not defaultPath: defaultPath = self.mainWindow.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH) path = PyGlassBasicDialogManager.browseForFileSave( parent=self, caption=u'Specify Export File', defaultPath=defaultPath) self.mainWindow.hideLoading(self) if not path: self.mainWindow.toggleInteractivity(True) return # Store directory location as the last save directory self.mainWindow.appConfig.set( UserConfigEnum.LAST_SAVE_PATH, FileUtils.getDirectoryOf(path) ) if not path.endswith('.json'): path += '.json' self.mainWindow.showStatus( self, u'Exporting Tracks', u'Writing track information from database') self._thread = TrackExporterRemoteThread( self, path=path, pretty=self.exportPrettyCheck.isChecked(), compressed=self.exportCompressCheck.isChecked(), difference=self.exportDiffCheck.isChecked()) self._thread.execute( callback=self._handleImportComplete, logCallback=self._handleImportStatusUpdate)
def _handleRemoveApp(self): item = self.currentAppItem if not item: return result = PyGlassBasicDialogManager.openYesNo( parent=self, header='Remove Application?', message='Are you sure you want to remove the "%s" app?' % self.currentAppName, defaultToYes=False) if not result: return apps = self.appConfig.get('APPLICATIONS', dict()) for appID, appData in apps.items(): if appID == item.ident: del apps[appID] break self.appConfig.set('APPLICATIONS', apps) self.refresh()
def _handleAddDatabase(self): result = PyGlassBasicDialogManager.openTextQuery( parent=self, header='Enter Database Name', message='Enter the name of the database as it would appear in the Database URL, e.g. ' +'"activity" or "employees/artists"') if not result: return data = { 'id':TimeUtils.getUidTimecode('DATABASE', StringUtils.slugify(result)), 'label':StringUtils.toText(result).title(), 'name':result } apps = self.appConfig.get('APPLICATIONS') app = apps[self.currentAppID] app['databases'][data['id']] = data self.appConfig.set('APPLICATIONS', apps) self._refreshAppDisplay() resultItem = self.databasesListWidget.findItems(result, QtCore.Qt.MatchExactly) if resultItem: resultItem[0].setSelected(True)
def _handleImport(self): label = u'CSV' importType = TrackImporterRemoteThread.CSV self.mainWindow.showLoading( self, u'Browsing for Track File', u'Choose the %s file to import into the database' % label) path = PyGlassBasicDialogManager.browseForFileOpen( parent=self, caption=u'Select %s File to Import' % label, defaultPath=self.mainWindow.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH) ) self.mainWindow.hideLoading(self) if not path or not StringUtils.isStringType(path): self.mainWindow.toggleInteractivity(True) return # Store directory location as the last active directory self.mainWindow.appConfig.set( UserConfigEnum.LAST_BROWSE_PATH, FileUtils.getDirectoryOf(path) ) self.mainWindow.showStatus( self, u'Importing Tracks', u'Reading track information into database') TrackImporterRemoteThread( parent=self, path=path, verbose=self.verboseDisplayCheck.isChecked(), importType=importType, compressed=False ).execute( callback=self._handleImportComplete, logCallback=self._handleImportStatusUpdate )
def _handleReplaceDatabase(self): self.mainWindow.showLoading( self, u'Browsing for Database File', u'Choose a valid database (*.vcd) file') defaultPath = self.appConfig.get(UserConfigEnum.DATABASE_IMPORT_PATH) if not defaultPath: defaultPath = self.appConfig.get(UserConfigEnum.LAST_BROWSE_PATH) path = PyGlassBasicDialogManager.browseForFileOpen( parent=self, caption=u'Select Database File', defaultPath=defaultPath) self.mainWindow.hideLoading(self) if not path: self.mainWindow.toggleInteractivity(True) return # Store directory for later use self.appConfig.set( UserConfigEnum.DATABASE_IMPORT_PATH, FileUtils.getDirectoryOf(path) ) self.mainWindow.showStatus( self, u'Replacing Database File', u'Removing existing database file and replacing it with selection') sourcePath = getattr(Tracks_Track, 'URL')[len(u'sqlite:'):].lstrip(u'/') if not OsUtils.isWindows(): sourcePath = u'/' + sourcePath savePath = '%s.store' % sourcePath try: if os.path.exists(savePath): SystemUtils.remove(savePath, throwError=True) except Exception as err: self.mainWindow.appendStatus( self, u'<span style="color:#CC3333">ERROR: Unable to access database save location.</span>') self.mainWindow.showStatusDone(self) return try: SystemUtils.move(sourcePath, savePath) except Exception as err: self.mainWindow.appendStatus( self, u'<span style="color:#CC3333;">ERROR: Unable to modify existing database file.</span>') self.mainWindow.showStatusDone(self) return try: SystemUtils.copy(path, sourcePath) except Exception as err: SystemUtils.move(savePath, sourcePath) self.mainWindow.appendStatus( self, u'<span style="color:#CC3333;">ERROR: Unable to copy new database file.</span>') self.mainWindow.showStatusDone(self) return if os.path.exists(savePath): SystemUtils.remove(savePath) self.mainWindow.appendStatus(self, u'<span style="color:#33CC33;">Database Replaced</span>') self.mainWindow.showStatusDone(self)