CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
hippyaddtobaddatafiles.KeepWhileOpenFile Class Reference
Inheritance diagram for hippyaddtobaddatafiles.KeepWhileOpenFile:
hippyaddtobaddatafiles.OneAtATime

Public Member Functions

def __enter__ (self)
 
def __exit__ (self, args)
 
def __init__ (self, name, message=None)
 
def __nonzero__ (self)
 
def wouldbevalid (self)
 

Public Attributes

 bool
 
 f
 
 fd
 
 filename
 
 pwd
 

Private Member Functions

def __open (self)
 

Private Attributes

 __message
 

Detailed Description

Definition at line 51 of file hippyaddtobaddatafiles.py.

Constructor & Destructor Documentation

◆ __init__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__init__ (   self,
  name,
  message = None 
)

Definition at line 52 of file hippyaddtobaddatafiles.py.

52  def __init__(self, name, message=None):
53  self.filename = name
54  self.__message = message
55  self.pwd = os.getcwd()
56  self.fd = self.f = None
57  self.bool = False
58 
def __init__(self, dataset, job_number, job_id, job_name, isDA, isMC, applyBOWS, applyEXTRACOND, extraconditions, runboundary, lumilist, intlumi, maxevents, gt, allFromGT, alignmentDB, alignmentTAG, apeDB, apeTAG, bowDB, bowTAG, vertextype, tracktype, refittertype, ttrhtype, applyruncontrol, ptcut, CMSSW_dir, the_dir)

Member Function Documentation

◆ __enter__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__enter__ (   self)

Definition at line 68 of file hippyaddtobaddatafiles.py.

References hippyaddtobaddatafiles.KeepWhileOpenFile.__message, hippyaddtobaddatafiles.KeepWhileOpenFile.__open(), hippyaddtobaddatafiles.KeepWhileOpenFile.bool, hippyaddtobaddatafiles.cd(), hippyaddtobaddatafiles.KeepWhileOpenFile.f, hippyaddtobaddatafiles.KeepWhileOpenFile.fd, hippyaddtobaddatafiles.KeepWhileOpenFile.pwd, and writeEcalDQMStatus.write.

68  def __enter__(self):
69  with cd(self.pwd):
70  try:
71  self.__open()
72  except OSError:
73  return None
74 
75  self.f = os.fdopen(self.fd, 'w')
76 
77  try:
78  if self.__message is not None:
79  self.f.write(self.__message+"\n")
80  except IOError:
81  pass
82  try:
83  self.f.close()
84  except IOError:
85  pass
86  self.bool = True
87  return True
88 

◆ __exit__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__exit__ (   self,
  args 
)

Definition at line 89 of file hippyaddtobaddatafiles.py.

References hippyaddtobaddatafiles.KeepWhileOpenFile.bool, hippyaddtobaddatafiles.cd(), hippyaddtobaddatafiles.KeepWhileOpenFile.f, hippyaddtobaddatafiles.KeepWhileOpenFile.fd, hippyaddtobaddatafiles.KeepWhileOpenFile.filename, dataset.DataFile.filename, and hippyaddtobaddatafiles.KeepWhileOpenFile.pwd.

89  def __exit__(self, *args):
90  if self:
91  try:
92  with cd(self.pwd):
93  os.remove(self.filename)
94  except OSError:
95  pass #ignore it
96  self.fd = self.f = None
97  self.bool = False
98 

◆ __nonzero__()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__nonzero__ (   self)

◆ __open()

def hippyaddtobaddatafiles.KeepWhileOpenFile.__open (   self)
private

Definition at line 65 of file hippyaddtobaddatafiles.py.

References hippyaddtobaddatafiles.KeepWhileOpenFile.fd, hippyaddtobaddatafiles.KeepWhileOpenFile.filename, and dataset.DataFile.filename.

Referenced by hippyaddtobaddatafiles.KeepWhileOpenFile.__enter__().

65  def __open(self):
66  self.fd = os.open(self.filename, os.O_CREAT | os.O_EXCL | os.O_WRONLY)
67 

◆ wouldbevalid()

def hippyaddtobaddatafiles.KeepWhileOpenFile.wouldbevalid (   self)

Definition at line 60 of file hippyaddtobaddatafiles.py.

References hippyaddtobaddatafiles.KeepWhileOpenFile.bool.

60  def wouldbevalid(self):
61  if self: return True
62  with self:
63  return bool(self)
64 

Member Data Documentation

◆ __message

hippyaddtobaddatafiles.KeepWhileOpenFile.__message
private

◆ bool

hippyaddtobaddatafiles.KeepWhileOpenFile.bool

◆ f

hippyaddtobaddatafiles.KeepWhileOpenFile.f

◆ fd

hippyaddtobaddatafiles.KeepWhileOpenFile.fd

◆ filename

hippyaddtobaddatafiles.KeepWhileOpenFile.filename

◆ pwd

hippyaddtobaddatafiles.KeepWhileOpenFile.pwd