CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 40 of file producerFileCleanner.py.

Referenced by sendmail().

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

Definition at line 32 of file producerFileCleanner.py.

References objects.autophobj.float.

Referenced by sendmail().

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

Definition at line 28 of file producerFileCleanner.py.

Referenced by sendmail().

28 def logme(msg, *args):
29  procid = "[%s/%d]" % (__file__.rsplit("/", 1)[-1], os.getpid())
30  print datetime.now(), procid, msg % args
31 
def producerFileCleanner.sendmail (   body = "Hello from producerFileCleanner",
  subject = "Hello!" 
)

Definition at line 53 of file producerFileCleanner.py.

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

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