diff --git a/ConfigurationSystem/test/Test_agentOptions.py b/ConfigurationSystem/test/Test_agentOptions.py index 0d65c52b2ac..f9fcac4b0ac 100644 --- a/ConfigurationSystem/test/Test_agentOptions.py +++ b/ConfigurationSystem/test/Test_agentOptions.py @@ -14,9 +14,9 @@ ('DIRAC.ConfigurationSystem.Agent.VOMS2CSAgent', {'IgnoreOptions': ['VO']}), ('DIRAC.DataManagementSystem.Agent.FTS3Agent', {}), ('DIRAC.FrameworkSystem.Agent.CAUpdateAgent', {}), - ('DIRAC.FrameworkSystem.Agent.MyProxyRenewalAgent', {'IgnoreOptions': ['MinValidity', 'ValidityPeriod', - 'MinimumLifeTime', - 'RenewedLifeTime']}), + ('DIRAC.FrameworkSystem.Agent.MyProxyRenewalAgent', {'IgnoreOptions': ['MinValidity', 'ValidityPeriod', + 'MinimumLifeTime', + 'RenewedLifeTime']}), ('DIRAC.RequestManagementSystem.Agent.CleanReqDBAgent', {'IgnoreOptions': ['KickLimit', 'KickGraceHours', 'DeleteGraceDays']}), ('DIRAC.RequestManagementSystem.Agent.RequestExecutingAgent', {'IgnoreOptions': ['MaxProcess', diff --git a/FrameworkSystem/Agent/MyProxyRenewalAgent.py b/FrameworkSystem/Agent/MyProxyRenewalAgent.py index 9e150f17682..61017bce941 100644 --- a/FrameworkSystem/Agent/MyProxyRenewalAgent.py +++ b/FrameworkSystem/Agent/MyProxyRenewalAgent.py @@ -9,58 +9,59 @@ from DIRAC.FrameworkSystem.DB.ProxyDB import ProxyDB from DIRAC.Core.Utilities.ThreadPool import ThreadPool + class MyProxyRenewalAgent(AgentModule): def initialize(self): - requiredLifeTime = self.am_getOption( "MinimumLifeTime", 3600 ) - renewedLifeTime = self.am_getOption( "RenewedLifeTime", 54000 ) - self.proxyDB = ProxyDB( useMyProxy = True ) + requiredLifeTime = self.am_getOption("MinimumLifeTime", 3600) + renewedLifeTime = self.am_getOption("RenewedLifeTime", 54000) + self.proxyDB = ProxyDB(useMyProxy=True) - gLogger.info( "Minimum Life time : %s" % requiredLifeTime ) - gLogger.info( "Life time on renew : %s" % renewedLifeTime ) - gLogger.info( "MyProxy server : %s" % self.proxyDB.getMyProxyServer() ) - gLogger.info( "MyProxy max proxy time : %s" % self.proxyDB.getMyProxyMaxLifeTime() ) + gLogger.info("Minimum Life time : %s" % requiredLifeTime) + gLogger.info("Life time on renew : %s" % renewedLifeTime) + gLogger.info("MyProxy server : %s" % self.proxyDB.getMyProxyServer()) + gLogger.info("MyProxy max proxy time : %s" % self.proxyDB.getMyProxyMaxLifeTime()) - self.__threadPool = ThreadPool( 1, 10 ) + self.__threadPool = ThreadPool(1, 10) return S_OK() - def __renewProxyForCredentials( self, userDN, userGroup ): - lifeTime = self.am_getOption( "RenewedLifeTime", 54000 ) - gLogger.info( "Renewing for %s@%s %s secs" % ( userDN, userGroup, lifeTime ) ) - retVal = self.proxyDB.renewFromMyProxy( userDN, - userGroup, - lifeTime = lifeTime ) - if not retVal[ 'OK' ]: - gLogger.error( "Failed to renew proxy", "for %s@%s : %s" %( userDN, userGroup, retVal[ 'Message' ] ) ) + def __renewProxyForCredentials(self, userDN, userGroup): + lifeTime = self.am_getOption("RenewedLifeTime", 54000) + gLogger.info("Renewing for %s@%s %s secs" % (userDN, userGroup, lifeTime)) + retVal = self.proxyDB.renewFromMyProxy(userDN, + userGroup, + lifeTime=lifeTime) + if not retVal['OK']: + gLogger.error("Failed to renew proxy", "for %s@%s : %s" % (userDN, userGroup, retVal['Message'])) else: - gLogger.info( "Renewed proxy for %s@%s" % ( userDN, userGroup ) ) + gLogger.info("Renewed proxy for %s@%s" % (userDN, userGroup)) - def __treatRenewalCallback( self, oTJ, exceptionList ): - gLogger.exception( lException = exceptionList ) + def __treatRenewalCallback(self, oTJ, exceptionList): + gLogger.exception(lException=exceptionList) def execute(self): """ The main agent execution method """ self.proxyDB.purgeLogs() - gLogger.info( "Purging expired requests" ) + gLogger.info("Purging expired requests") retVal = self.proxyDB.purgeExpiredRequests() - if retVal[ 'OK' ]: - gLogger.info( " purged %s requests" % retVal[ 'Value' ] ) - gLogger.info( "Purging expired proxies" ) + if retVal['OK']: + gLogger.info(" purged %s requests" % retVal['Value']) + gLogger.info("Purging expired proxies") retVal = self.proxyDB.purgeExpiredProxies() - if retVal[ 'OK' ]: - gLogger.info( " purged %s proxies" % retVal[ 'Value' ] ) - retVal = self.proxyDB.getCredentialsAboutToExpire( self.am_getOption( "MinimumLifeTime" , 3600 ) ) - if not retVal[ 'OK' ]: + if retVal['OK']: + gLogger.info(" purged %s proxies" % retVal['Value']) + retVal = self.proxyDB.getCredentialsAboutToExpire(self.am_getOption("MinimumLifeTime", 3600)) + if not retVal['OK']: return retVal - data = retVal[ 'Value' ] - gLogger.info( "Renewing %s proxies..." % len( data ) ) + data = retVal['Value'] + gLogger.info("Renewing %s proxies..." % len(data)) for record in data: userDN = record[0] userGroup = record[1] - self.__threadPool.generateJobAndQueueIt( self.__renewProxyForCredentials, - args = ( userDN, userGroup ), - oExceptionCallback = self.__treatRenewalCallback ) + self.__threadPool.generateJobAndQueueIt(self.__renewProxyForCredentials, + args=(userDN, userGroup), + oExceptionCallback=self.__treatRenewalCallback) self.__threadPool.processAllResults() - return S_OK() \ No newline at end of file + return S_OK() diff --git a/FrameworkSystem/DB/ProxyDB.py b/FrameworkSystem/DB/ProxyDB.py index 97f42cd3ad0..e340ec57fe9 100755 --- a/FrameworkSystem/DB/ProxyDB.py +++ b/FrameworkSystem/DB/ProxyDB.py @@ -3,13 +3,10 @@ __RCSID__ = "$Id$" -import os -import glob import time from six.moves.urllib.request import urlopen import random import hashlib -import commands from DIRAC import gConfig, gLogger, S_OK, S_ERROR from DIRAC.Core.Base.DB import DB diff --git a/FrameworkSystem/scripts/dirac-monitoring-get-components-status.py b/FrameworkSystem/scripts/dirac-monitoring-get-components-status.py index 3b8ad64259b..f2ca0b45b14 100755 --- a/FrameworkSystem/scripts/dirac-monitoring-get-components-status.py +++ b/FrameworkSystem/scripts/dirac-monitoring-get-components-status.py @@ -25,13 +25,13 @@ fieldLengths.append(len(param)) for record in records: - for i in range(len(record)): + for i, _ in enumerate(record): if paramNames[i] in fieldsToShow: fieldLengths[i] = max(fieldLengths[i], len(str(record[i]))) # Print time! line = [] sepLine = [] -for i in range(len(paramNames)): +for i, _ in enumerate(paramNames): param = paramNames[i] if param in fieldsToShow: line.append("%s%s" % (param, " " * (fieldLengths[i] - len(param)))) @@ -41,9 +41,8 @@ print(sepLine) for record in records: line = [] - for i in range(len(record)): + for i, _ in enumerate(record): if paramNames[i] in fieldsToShow: val = str(record[i]) line.append("%s%s" % (val, " " * (fieldLengths[i] - len(val)))) print("|".join(line)) - # print sepLine diff --git a/tests/Jenkins/utilities.sh b/tests/Jenkins/utilities.sh index 49de6ffe480..d142b11c286 100644 --- a/tests/Jenkins/utilities.sh +++ b/tests/Jenkins/utilities.sh @@ -297,7 +297,7 @@ function getCFGFile(){ #################################################### -# This installs the DIRAC client +# This installs the DIRAC client, considering the alternative modules # it needs a $DIRAC_RELEASE env var defined # it also wants the env variables DIRACSETUP and CSURLS #