CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
helperFunctions Namespace Reference

Functions

def castorDirExists
 
def getCommandOutput2
 
def replaceByMap
 — Helpers —############################ More...
 

Function Documentation

def helperFunctions.castorDirExists (   path)
This function checks if the directory given by `path` exists.

Arguments:
- `path`: Path to castor directory

Definition at line 47 of file helperFunctions.py.

References getCommandOutput2().

47 
48 def castorDirExists(path):
49  """This function checks if the directory given by `path` exists.
50 
51  Arguments:
52  - `path`: Path to castor directory
53  """
54 
55  if path[-1] == "/":
56  path = path[:-1]
57  containingPath = os.path.join( *path.split("/")[:-1] )
58  dirInQuestion = path.split("/")[-1]
59  try:
60  rawLines = getCommandOutput2("rfdir /"+containingPath).splitlines()
61  except RuntimeError:
62  return False
63  for line in rawLines:
64  if line.split()[0][0] == "d":
65  if line.split()[8] == dirInQuestion:
66  return True
67  return False
def helperFunctions.getCommandOutput2 (   command)
This function executes `command` and returns it output.

Arguments:
- `command`: Shell command to be invoked by this function.

Definition at line 32 of file helperFunctions.py.

Referenced by castorDirExists(), and validateAlignments.ValidationJob.runJob().

32 
33 def getCommandOutput2(command):
34  """This function executes `command` and returns it output.
35 
36  Arguments:
37  - `command`: Shell command to be invoked by this function.
38  """
39 
40  child = os.popen(command)
41  data = child.read()
42  err = child.close()
43  if err:
44  raise RuntimeError, '%s failed w/ exit code %d' % (command, err)
45  return data
46 
def helperFunctions.replaceByMap (   target,
  the_map 
)

— Helpers —############################

This function replaces `.oO[key]Oo.` by `the_map[key]` in target.

Arguments:
- `target`: String which contains symbolic tags of the form `.oO[key]Oo.`
- `the_map`: Dictionary which has to contain the `key`s in `target` as keys

Definition at line 5 of file helperFunctions.py.

Referenced by offlineValidation.OfflineValidation.appendToMerge(), trackSplittingValidation.TrackSplittingValidation.createConfiguration(), monteCarloValidation.MonteCarloValidation.createConfiguration(), zMuMuValidation.ZMuMuValidation.createConfiguration(), offlineValidation.OfflineValidation.createConfiguration(), geometryComparison.GeometryComparison.createConfiguration(), offlineValidation.OfflineValidationParallel.createConfiguration(), validateAlignments.createExtendedValidationScript(), validateAlignments.createMergeScript(), validateAlignments.createOfflineJobsMergeScript(), validateAlignments.createParallelMergeScript(), trackSplittingValidation.TrackSplittingValidation.createScript(), monteCarloValidation.MonteCarloValidation.createScript(), zMuMuValidation.ZMuMuValidation.createScript(), offlineValidation.OfflineValidation.createScript(), geometryComparison.GeometryComparison.createScript(), offlineValidation.OfflineValidationParallel.createScript(), validateAlignments.createTrackSplitPlotScript(), alignment.Alignment.getConditions(), trackSplittingValidation.TrackSplittingValidation.getRepMap(), monteCarloValidation.MonteCarloValidation.getRepMap(), and offlineValidation.OfflineValidation.getRepMap().

5 
6 def replaceByMap(target, the_map):
7  """This function replaces `.oO[key]Oo.` by `the_map[key]` in target.
8 
9  Arguments:
10  - `target`: String which contains symbolic tags of the form `.oO[key]Oo.`
11  - `the_map`: Dictionary which has to contain the `key`s in `target` as keys
12  """
13 
14  result = target
15  for key in the_map:
16  lifeSaver = 10e3
17  iteration = 0
18  while ".oO[" in result and "]Oo." in result:
19  for key in the_map:
20  result = result.replace(".oO["+key+"]Oo.",the_map[key])
21  iteration += 1
22  if iteration > lifeSaver:
23  problematicLines = ""
24  for line in result.splitlines():
25  if ".oO[" in result and "]Oo." in line:
26  problematicLines += "%s\n"%line
27  msg = ("Oh Dear, there seems to be an endless loop in "
28  "replaceByMap!!\n%s\nrepMap"%problematicLines)
29  raise AllInOneError(msg)
30  return result
31 
def replaceByMap
— Helpers —############################