def isCredentialRequired(credObj): """ The logic to decide if a given invalid credential should trigger the deactivation of Ganga internal services. """ from Ganga.Runtime import Workspace_runtime from Ganga.Runtime import Repository_runtime if getName(credObj) == "AfsToken": return Workspace_runtime.requiresAfsToken() or Repository_runtime.requiresAfsToken() if getName(credObj) == "GridProxy": if Repository_runtime.requiresGridProxy() or Workspace_runtime.requiresGridProxy(): return True from Ganga.GPI import jobs, typename from Ganga.GPIDev.Base.Proxy import stripProxy for j in jobs: ji = stripProxy(j) if ji.status in ["submitted", "running", "completing"]: if getName(ji.backend) == "LCG": return True return False log.warning("Unknown credential object : %s" % credObj)
def isCredentialRequired(credObj): """ The logic to decide if a given invalid credential should trigger the deactivation of Ganga internal services. """ from Ganga.Runtime import Workspace_runtime from Ganga.Runtime import Repository_runtime if getName(credObj) == 'AfsToken': return Workspace_runtime.requiresAfsToken() or Repository_runtime.requiresAfsToken() if getName(credObj) == 'GridProxy': from Ganga.Core.GangaRepository import getRegistryProxy from Ganga.Runtime.GPIFunctions import typename from Ganga.GPIDev.Base.Proxy import stripProxy from Ganga.GPIDev.Lib.Job.Job import lazyLoadJobBackend, lazyLoadJobStatus for j in getRegistryProxy('jobs'): ji = stripProxy(j) this_status = lazyLoadJobStatus(ji) if this_status in ['submitted', 'running', 'completing']: this_backend = lazyLoadJobBackend(ji) if getName(this_backend) == 'LCG': return True return False log.warning("Unknown credential object : %s" % credObj)
def isCredentialRequired(credObj): """ The logic to decide if a given invalid credential should trigger the deactivation of Ganga internal services. """ from Ganga.Runtime import Workspace_runtime from Ganga.Runtime import Repository_runtime if getName(credObj) == 'AfsToken': return Workspace_runtime.requiresAfsToken( ) or Repository_runtime.requiresAfsToken() if getName(credObj) == 'GridProxy': from Ganga.Core.GangaRepository import getRegistryProxy from Ganga.Runtime.GPIFunctions import typename from Ganga.GPIDev.Base.Proxy import stripProxy from Ganga.GPIDev.Lib.Job.Job import lazyLoadJobBackend, lazyLoadJobStatus for j in getRegistryProxy('jobs'): ji = stripProxy(j) this_status = lazyLoadJobStatus(ji) if this_status in ['submitted', 'running', 'completing']: this_backend = lazyLoadJobBackend(ji) if getName(this_backend) == 'LCG': return True return False log.warning("Unknown credential object : %s" % credObj)
def isCredentialRequired(credObj): """ The logic to decide if a given invalid credential should trigger the deactivation of Ganga internal services. """ from Ganga.Runtime import Workspace_runtime from Ganga.Runtime import Repository_runtime if getName(credObj) == 'AfsToken': return Workspace_runtime.requiresAfsToken() or Repository_runtime.requiresAfsToken() if getName(credObj) == 'GridProxy': if Repository_runtime.requiresGridProxy() or Workspace_runtime.requiresGridProxy(): return True from Ganga.GPI import jobs, typename from Ganga.GPIDev.Base.Proxy import stripProxy for j in jobs: ji = stripProxy(j) if ji.status in ['submitted', 'running', 'completing']: if ji.getNodeIndexCache() is not None and 'display:backend' in ji.getNodeIndexCache().keys(): if ji.getNodeIndexCache()['display:backend'] == 'LCG': return True else: if getName(ji.backend) == 'LCG': return True return False log.warning("Unknown credential object : %s" % credObj)
def isCredentialRequired (credObj): """ The logic to decide if a given invalid credential should trigger the deactivation of Ganga internal services. """ from Ganga.Runtime import Workspace_runtime from Ganga.Runtime import Repository_runtime if credObj.__class__.__name__ == 'AfsToken': return Workspace_runtime.requiresAfsToken() or Repository_runtime.requiresAfsToken() if credObj.__class__.__name__ == 'GridProxy': if Repository_runtime.requiresGridProxy() or Workspace_runtime.requiresGridProxy(): return True from Ganga.GPI import jobs,typename return bool([j for j in jobs if typename(j.backend)=='LCG' and j.status in ['submitted','running','completing']]) log.warning("Unknown credential object : %s" % credObj)
def isAvailable( self ): if self.cell: available = True else: available = False if not available: # gangadir = fullpath( getConfig( "Configuration" )[ "gangadir" ] ) # if ( 0 == gangadir.find( "/afs" ) ): # available = True available = Repository_runtime.requiresAfsToken() if available: infoCommand = self.command.info.split()[ 0 ] available = False try: pathList = os.environ[ "PATH" ].split( os.pathsep ) except KeyError: pathList = [] for searchDir in pathList: try: fileList = os.listdir( searchDir ) except OSError: fileList = [] if infoCommand in fileList: available = True break if available: logger.debug( "Command '%s' found in directory '%s'" % \ ( infoCommand, searchDir ) ) else: logger.debug( "Unable to find command '%s'" % infoCommand ) if available: timeleft = self.timeleft() if not timeleft: available = False return available
def isAvailable(self): if self.cell: available = True else: available = False if not available: available = Repository_runtime.requiresAfsToken() if available: infoCommand = self.command.info.split()[0] available = False try: pathList = os.environ["PATH"].split(os.pathsep) except KeyError: pathList = [] for searchDir in pathList: try: fileList = os.listdir(searchDir) except OSError: fileList = [] if infoCommand in fileList: available = True break if available: logger.debug("Command '%s' found in directory '%s'" % (infoCommand, searchDir)) else: logger.debug("Unable to find command '%s'" % infoCommand) if available: timeleft = self.timeleft() if not timeleft: available = False return available