CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
FrontierCondition_GT_autoExpress_cfi.Tier0Handler Class Reference
Inheritance diagram for FrontierCondition_GT_autoExpress_cfi.Tier0Handler:

Public Member Functions

def __init__ (self, uri, timeOut, retries, retryPeriod, proxy, debug)
 
def getFirstSafeRun (self)
 
def getGlobalTag (self, config)
 
def setDebug (self)
 
def setProxy (self, proxy)
 
def unsetDebug (self)
 

Private Member Functions

def _queryTier0DataSvc (self, url)
 

Private Attributes

 _debug
 
 _proxy
 
 _retries
 
 _retryPeriod
 
 _timeOut
 
 _uri
 

Detailed Description

Definition at line 52 of file FrontierCondition_GT_autoExpress_cfi.py.

Constructor & Destructor Documentation

def FrontierCondition_GT_autoExpress_cfi.Tier0Handler.__init__ (   self,
  uri,
  timeOut,
  retries,
  retryPeriod,
  proxy,
  debug 
)
Parameters:
uri: Tier0DataSvc URI;
timeOut: time out for Tier0DataSvc HTTPS calls;
retries: maximum retries for Tier0DataSvc HTTPS calls;
retryPeriod: sleep time between two Tier0DataSvc HTTPS calls;
proxy: HTTP proxy for accessing Tier0DataSvc HTTPS calls;
debug: if set to True, enables debug information.

Definition at line 54 of file FrontierCondition_GT_autoExpress_cfi.py.

54  def __init__( self, uri, timeOut, retries, retryPeriod, proxy, debug ):
55  """
56  Parameters:
57  uri: Tier0DataSvc URI;
58  timeOut: time out for Tier0DataSvc HTTPS calls;
59  retries: maximum retries for Tier0DataSvc HTTPS calls;
60  retryPeriod: sleep time between two Tier0DataSvc HTTPS calls;
61  proxy: HTTP proxy for accessing Tier0DataSvc HTTPS calls;
62  debug: if set to True, enables debug information.
63  """
64  self._uri = uri
65  self._timeOut = timeOut
66  self._retries = retries
67  self._retryPeriod = retryPeriod
68  self._proxy = proxy
69  self._debug = debug
70 
def __init__(self, uri, timeOut, retries, retryPeriod, proxy, debug)

Member Function Documentation

def FrontierCondition_GT_autoExpress_cfi.Tier0Handler._queryTier0DataSvc (   self,
  url 
)
private
Queries Tier0DataSvc.
url: Tier0DataSvc URL.
@returns: dictionary, from whence the required information must be retrieved according to the API call.
Raises if connection error, bad response, or timeout after retries occur.

Definition at line 80 of file FrontierCondition_GT_autoExpress_cfi.py.

References Logger._debug, hcaldqm::DQModule._debug, EcalMatacqAnalyzer._debug, FrontierCondition_GT_autoExpress_cfi.Tier0Handler._debug, EcalABAnalyzer._debug, tier0.Tier0Handler._debug, EcalLaserAnalyzer2._debug, uploads.uploader._debug, EcalLaserAnalyzer._debug, FrontierCondition_GT_autoExpress_cfi.Tier0Handler._proxy, tier0.Tier0Handler._proxy, FrontierCondition_GT_autoExpress_cfi.Tier0Handler._retries, tier0.Tier0Handler._retries, FrontierCondition_GT_autoExpress_cfi.Tier0Handler._timeOut, tier0.Tier0Handler._timeOut, join(), python.rootplot.root2matplotlib.replace(), and str.

Referenced by FrontierCondition_GT_autoExpress_cfi.Tier0Handler.getFirstSafeRun(), and FrontierCondition_GT_autoExpress_cfi.Tier0Handler.getGlobalTag().

80  def _queryTier0DataSvc( self, url ):
81  """
82  Queries Tier0DataSvc.
83  url: Tier0DataSvc URL.
84  @returns: dictionary, from whence the required information must be retrieved according to the API call.
85  Raises if connection error, bad response, or timeout after retries occur.
86  """
87 
88  userAgent = "User-Agent: DQMIntegration/2.0 python/%d.%d.%d PycURL/%s" % ( sys.version_info[ :3 ] + ( pycurl.version_info()[ 1 ], ) )
89 
90  proxy = ""
91  if self._proxy: proxy = ' --proxy %s ' % self._proxy
92 
93  debug = " -s -S "
94  if self._debug: debug = " -v "
95 
96  cmd = '/usr/bin/curl -k -L --user-agent "%s" %s --connect-timeout %i --retry %i %s %s ' % (userAgent, proxy, self._timeOut, self._retries, debug, url)
97 
98  process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
99  (stdoutdata, stderrdata) = process.communicate()
100  retcode = process.returncode
101 
102  if retcode != 0 or stderrdata:
103  msg = "looks like curl returned an error: retcode=%s" % (retcode,)
104  msg += ' msg = "'+str(stderrdata)+'"'
105  raise Tier0Error(msg)
106 
107  return json.loads( ''.join(stdoutdata).replace( "'", '"').replace(' None', ' "None"') )
108 
def replace(string, replacements)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
#define str(s)
def FrontierCondition_GT_autoExpress_cfi.Tier0Handler.getFirstSafeRun (   self)
Queries Tier0DataSvc to get the first condition safe run.
Parameters:
@returns: integer, the run number.
Raises if connection error, bad response, timeout after retries occur, or if the run number is not available.

Definition at line 109 of file FrontierCondition_GT_autoExpress_cfi.py.

References FrontierCondition_GT_autoExpress_cfi.Tier0Handler._proxy, tier0.Tier0Handler._proxy, FrontierCondition_GT_autoExpress_cfi.Tier0Handler._queryTier0DataSvc(), tier0.Tier0Handler._queryTier0DataSvc(), FrontierCondition_GT_autoExpress_cfi.Tier0Handler._uri, tier0.Tier0Handler._uri, createfilelist.int, and str.

109  def getFirstSafeRun( self ):
110  """
111  Queries Tier0DataSvc to get the first condition safe run.
112  Parameters:
113  @returns: integer, the run number.
114  Raises if connection error, bad response, timeout after retries occur, or if the run number is not available.
115  """
116  firstConditionSafeRunAPI = "firstconditionsaferun"
117  safeRunDict = self._queryTier0DataSvc( os.path.join( self._uri, firstConditionSafeRunAPI ) )
118  if safeRunDict is None:
119  errStr = """First condition safe run is not available in Tier0DataSvc from URL \"%s\" """ %( os.path.join( self._uri, firstConditionSafeRunAPI ), )
120  if self._proxy:
121  errStr += """ using proxy \"%s\".""" %( str( self._proxy ), )
122  raise Tier0Error( errStr )
123  return int(safeRunDict['result'][0])
124 
#define str(s)
def FrontierCondition_GT_autoExpress_cfi.Tier0Handler.getGlobalTag (   self,
  config 
)
Queries Tier0DataSvc to get the most recent Global Tag for a given workflow.
Parameters:
config: Tier0DataSvc API call for the workflow to be looked for;
@returns: a string with the Global Tag name.
Raises if connection error, bad response, timeout after retries occur, or if no Global Tags are available.

Definition at line 125 of file FrontierCondition_GT_autoExpress_cfi.py.

References FrontierCondition_GT_autoExpress_cfi.Tier0Handler._proxy, tier0.Tier0Handler._proxy, FrontierCondition_GT_autoExpress_cfi.Tier0Handler._queryTier0DataSvc(), tier0.Tier0Handler._queryTier0DataSvc(), FrontierCondition_GT_autoExpress_cfi.Tier0Handler._uri, tier0.Tier0Handler._uri, edm.print(), str, and FrontierCondition_GT_autoExpress_cfi.unique().

125  def getGlobalTag( self, config ):
126  """
127  Queries Tier0DataSvc to get the most recent Global Tag for a given workflow.
128  Parameters:
129  config: Tier0DataSvc API call for the workflow to be looked for;
130  @returns: a string with the Global Tag name.
131  Raises if connection error, bad response, timeout after retries occur, or if no Global Tags are available.
132  """
133  data = self._queryTier0DataSvc( os.path.join( self._uri, config ) )
134  gtnames = sorted(unique( [ str( di[ 'global_tag' ] ) for di in data['result'] if di[ 'global_tag' ] is not None ] ))
135  try:
136  recentGT = gtnames[-1]
137  return recentGT
138  except IndexError:
139  errStr = """No Global Tags for \"%s\" are available in Tier0DataSvc from URL \"%s\" """ %( config, os.path.join( self._uri, config ) )
140  if self._proxy:
141  errStr += """ using proxy \"%s\".""" %( str( self._proxy ), )
142  raise Tier0Error( errStr )
143 
#define str(s)
def FrontierCondition_GT_autoExpress_cfi.Tier0Handler.setDebug (   self)
def FrontierCondition_GT_autoExpress_cfi.Tier0Handler.setProxy (   self,
  proxy 
)
def FrontierCondition_GT_autoExpress_cfi.Tier0Handler.unsetDebug (   self)

Member Data Documentation

FrontierCondition_GT_autoExpress_cfi.Tier0Handler._debug
private
FrontierCondition_GT_autoExpress_cfi.Tier0Handler._proxy
private
FrontierCondition_GT_autoExpress_cfi.Tier0Handler._retries
private
FrontierCondition_GT_autoExpress_cfi.Tier0Handler._retryPeriod
private

Definition at line 67 of file FrontierCondition_GT_autoExpress_cfi.py.

FrontierCondition_GT_autoExpress_cfi.Tier0Handler._timeOut
private
FrontierCondition_GT_autoExpress_cfi.Tier0Handler._uri
private