CMS 3D CMS Logo

Classes | Functions | Variables
hippyaddtobaddatafiles Namespace Reference

Classes

class  KeepWhileOpenFile
 
class  OneAtATime
 

Functions

def abspath (path)
 
def cd (newdir)
 
def cdtemp ()
 
def runcfg (cfgfile, badfilelist)
 

Variables

 args = p.parse_args()
 
 badfilelist = args.badfilelist
 
 default
 
 nargs
 
 p = argparse.ArgumentParser()
 
 type
 

Function Documentation

◆ abspath()

def hippyaddtobaddatafiles.abspath (   path)

Definition at line 8 of file hippyaddtobaddatafiles.py.

8  def abspath(path):
9  if not os.path.exists(path): raise ValueError(path+" does not exist")
10  return os.path.abspath(path)
11 

◆ cd()

def hippyaddtobaddatafiles.cd (   newdir)
http://stackoverflow.com/a/24176022/5228524

Definition at line 40 of file hippyaddtobaddatafiles.py.

Referenced by hippyaddtobaddatafiles.KeepWhileOpenFile.__enter__(), hippyaddtobaddatafiles.KeepWhileOpenFile.__exit__(), SiStripTFile.addDevice(), plotting.Frame.adjustMarginLeft(), plotting.FrameRatio.adjustMarginLeft(), plotting.Frame.adjustMarginRight(), plotting.FrameRatio.adjustMarginRight(), plotting.FrameTGraph2D.adjustMarginRight(), plotscripts.bellcurves(), plotTTrigFromHistos.compareDiff(), plotT0FromHistos.compareDiff(), plotscripts.corrections2D(), HtrXmlPatternTool.createHists(), plotscripts.DBdiff(), HtrXmlPattern.do_hand_fill(), edm::eventsetup::EventSetupRecord.doGet(), DisplayManager.DisplayManager.Draw(), TkAlMap.TkAlMap.draw_cms_prelim(), TkAlMap.TkAlMap.draw_color_bar(), TkAlMap.TkAlMap.draw_event_info(), TkAlMap.TkAlMap.draw_text(), TkAlMap.TkAlMap.draw_title(), TkAlMap.TkAlMap.draw_TPL(), eventloop.Module.endJob(), HtrXmlPatternTool.Fill(), SensitiveDetector.FinalStepPosition(), CACell.haveSimilarCurvature(), SensitiveDetector.InitialStepPosition(), edm::service::MessageLoggerDefaults.limit(), DQMGenericClient.makeCumulativeDist(), FWColorPopup.PlacePopup(), python.rootplot.core.plot_hists_root(), plotResidualsPerLayer.plotFromFile(), plotscripts.plotmedians(), plotscripts.polynomials(), edm::PrintEventSetupContent.print(), HcalTestAnalysis.qieAnalysis(), HcalTB04Analysis.qieAnalysis(), plotting.FrameRatio.redrawAxis(), edm::service::MessageLoggerDefaults.reportEvery(), histoStyle.savePlots(), plotscripts.segdiff(), plotscripts.segdiff_xalign(), SiHitDigitizer.setChargeCollectionDrifter(), SiHitDigitizer.setChargeDivider(), SiHitDigitizer.setInduceChargeOnStrips(), edm::service::MessageLoggerDefaults.sev_limit(), edm::service::MessageLoggerDefaults.sev_reportEvery(), edm::service::MessageLoggerDefaults.sev_timespan(), edm::service::MessageLoggerDefaults.timespan(), output.OutputTree.write(), HMassResolutionVSPart.Write(), DQMIO2histo.DQMIO.write_to_file(), and HtrXmlPatternTool.writeXML().

40 def cd(newdir):
41  """http://stackoverflow.com/a/24176022/5228524"""
42  prevdir = os.getcwd()
43  os.chdir(os.path.expanduser(newdir))
44  try:
45  yield
46  finally:
47  os.chdir(prevdir)
48 

◆ cdtemp()

def hippyaddtobaddatafiles.cdtemp ( )

Definition at line 49 of file hippyaddtobaddatafiles.py.

Referenced by hippyaddtobaddatafiles.OneAtATime.__enter__().

49 def cdtemp(): return cd(tempfile.mkdtemp())
50 

◆ runcfg()

def hippyaddtobaddatafiles.runcfg (   cfgfile,
  badfilelist 
)

Definition at line 17 of file hippyaddtobaddatafiles.py.

References watchdog.group, join(), print(), and submitPVValidationJobs.split().

17 def runcfg(cfgfile, badfilelist):
18  try:
19  subprocess.check_output(["cmsRun", cfgfile], stderr=subprocess.STDOUT)
20  except subprocess.CalledProcessError as e:
21  if "FallbackFileOpenError" in e.output:
22  output = e.output.split("An exception of category 'FallbackFileOpenError' occurred while")[1]
23  filename = re.search("Failed to open the file '[^']*(/store/.*[.]root)", output).group(1)
24  with OneAtATime(badfilelist+".tmp", 2) as f:
25  with open(badfilelist) as f:
26  contents = set(f.read().split())
27  if filename in contents:
28  raise RuntimeError(filename+"\nis already in\n"+badfilelist+"\n\nExiting to avoid an infinite loop. Maybe you have this running on the same cfg file multiple times?")
29  contents.add(filename)
30  contents = sorted(contents)
31  with open(badfilelist, "w") as f:
32  f.write("\n".join(contents)+"\n")
33  print("found and added a bad file:\n"+filename)
34  else:
35  raise
36  return runcfg(cfgfile, badfilelist)
37  print("all files left are good")
38 
39 @contextlib.contextmanager
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def runcfg(cfgfile, badfilelist)
static std::string join(char **cmd)
Definition: RemoteFile.cc:21

Variable Documentation

◆ args

hippyaddtobaddatafiles.args = p.parse_args()

Definition at line 15 of file hippyaddtobaddatafiles.py.

◆ badfilelist

hippyaddtobaddatafiles.badfilelist = args.badfilelist

Definition at line 123 of file hippyaddtobaddatafiles.py.

◆ default

hippyaddtobaddatafiles.default

Definition at line 14 of file hippyaddtobaddatafiles.py.

◆ nargs

hippyaddtobaddatafiles.nargs

Definition at line 14 of file hippyaddtobaddatafiles.py.

◆ p

hippyaddtobaddatafiles.p = argparse.ArgumentParser()

Definition at line 12 of file hippyaddtobaddatafiles.py.

◆ type

hippyaddtobaddatafiles.type

Definition at line 13 of file hippyaddtobaddatafiles.py.