CMS 3D CMS Logo

Functions
producerFileCleanner Namespace Reference

Functions

def getDirSize (path)
 
def getDiskUsage (path)
 
def logme (msg, args)
 
def sendmail (body="Hello from producerFileCleanner", subject="Hello!")
 

Function Documentation

def producerFileCleanner.getDirSize (   path)

Definition at line 41 of file producerFileCleanner.py.

Referenced by sendmail().

41 def getDirSize(path):
42  import stat
43  size=os.stat(path).st_blksize
44  for directory,subdirs,files in os.walk(path):
45  dStats=os.lstat(directory)
46  size+=(dStats[stat.ST_NLINK]-1)*dStats[stat.ST_SIZE]
47  for f in files:
48  fStats=os.lstat("%s/%s" % (directory,f))
49  fSize=fStats[stat.ST_SIZE]
50  size+=fSize
51 
52  return size
53 
def producerFileCleanner.getDiskUsage (   path)

Definition at line 33 of file producerFileCleanner.py.

References objects.autophobj.float.

Referenced by sendmail().

33 def getDiskUsage(path):
34  fsStats=os.statvfs(path)
35  size=fsStats.f_bsize*fsStats.f_blocks
36  available=fsStats.f_bavail*fsStats.f_bsize
37  used=size-available
38  usedPer=float(used)/size
39  return (size,available,used,usedPer)
40 
def producerFileCleanner.logme (   msg,
  args 
)

Definition at line 29 of file producerFileCleanner.py.

References edm.print().

Referenced by sendmail().

29 def logme(msg, *args):
30  procid = "[%s/%d]" % (__file__.rsplit("/", 1)[-1], os.getpid())
31  print(datetime.now(), procid, msg % args)
32 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65
def producerFileCleanner.sendmail (   body = "Hello from producerFileCleanner",
  subject = "Hello!" 
)

Definition at line 54 of file producerFileCleanner.py.

References getDirSize(), getDiskUsage(), and logme().

54 def sendmail(body="Hello from producerFileCleanner",subject= "Hello!"):
55  scall = Popen("%s -t" % SENDMAIL, shell=True, stdin=PIPE)
56  scall.stdin.write("To: %s\n" % EMAIL)
57  scall.stdin.write("Subject: producerFileCleaner problem on server %s\n" %
58  HOSTNAME)
59  scall.stdin.write("\n") # blank line separating headers from body
60  scall.stdin.write("%s\n" % body)
61  scall.stdin.close()
62  rc = scall.wait()
63  if rc != 0:
64  logme("ERROR: Sendmail exit with status %s", rc)
65 
66 # --------------------------------------------------------------------
def sendmail(body="Hello from producerFileCleanner", subject="Hello!")