Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-20 07:58:58

0001 import subprocess
0002 
0003 from pandaharvester.harvestercore import core_utils
0004 
0005 from .base_cred_manager import BaseCredManager
0006 
0007 # logger
0008 _logger = core_utils.setup_logger("grid_cred_manager")
0009 
0010 
0011 # credential manager using grid-proxy
0012 class GridCredManager(BaseCredManager):
0013     # constructor
0014     def __init__(self, **kwarg):
0015         BaseCredManager.__init__(self, **kwarg)
0016 
0017     # check proxy
0018     def check_credential(self):
0019         # make logger
0020         mainLog = self.make_logger(_logger, method_name="check_credential")
0021         comStr = f"grid-proxy-info -exists -hours 72 -file {self.outCertFile}"
0022         mainLog.debug(comStr)
0023         try:
0024             p = subprocess.Popen(comStr.split(), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
0025             stdOut, stdErr = p.communicate()
0026             retCode = p.returncode
0027         except Exception:
0028             core_utils.dump_error_message(mainLog)
0029             return False
0030         mainLog.debug(f"retCode={retCode} stdOut={stdOut} stdErr={stdErr}")
0031         return retCode == 0
0032 
0033     # renew proxy
0034     def renew_credential(self):
0035         # make logger
0036         mainLog = self.make_logger(_logger, method_name="renew_credential")
0037         comStr = f"grid-proxy-init -out {self.outCertFile} -valid 96:00 -cert {self.inCertFile}"
0038         mainLog.debug(comStr)
0039         try:
0040             p = subprocess.Popen(comStr.split(), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
0041             stdOut, stdErr = p.communicate()
0042             retCode = p.returncode
0043             mainLog.debug(f"retCode={retCode} stdOut={stdOut} stdErr={stdErr}")
0044         except Exception:
0045             stdOut = ""
0046             stdErr = core_utils.dump_error_message(mainLog)
0047             retCode = -1
0048         return retCode == 0, f"{stdOut} {stdErr}"