summaryrefslogtreecommitdiffstats
path: root/src/sbin/bcfg2-build-reports
diff options
context:
space:
mode:
authorFabian Affolter <fabian@bernewireless.net>2010-06-07 11:03:09 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-06-07 08:42:52 -0500
commit0b5debac6873733685bc55fc1f88da6b5879a85f (patch)
treeef6fdc4c51ad1d86228707cfaccef6c6d7e0d072 /src/sbin/bcfg2-build-reports
parentd52c925dedfabc0f8ba0b3a137fcf977749a055e (diff)
downloadbcfg2-0b5debac6873733685bc55fc1f88da6b5879a85f.tar.gz
bcfg2-0b5debac6873733685bc55fc1f88da6b5879a85f.tar.bz2
bcfg2-0b5debac6873733685bc55fc1f88da6b5879a85f.zip
Updated files to match PEP 257
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5895 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/sbin/bcfg2-build-reports')
-rwxr-xr-xsrc/sbin/bcfg2-build-reports28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/sbin/bcfg2-build-reports b/src/sbin/bcfg2-build-reports
index 8ae8475a3..602735bc5 100755
--- a/src/sbin/bcfg2-build-reports
+++ b/src/sbin/bcfg2-build-reports
@@ -1,7 +1,8 @@
#!/usr/bin/env python
-'''bcfg2-build-reports Generates & distributes reports of statistic information
-for bcfg2'''
+"""bcfg2-build-reports Generates & distributes reports of statistic information
+for bcfg2"""
+
__revision__ = '$Revision$'
from ConfigParser import ConfigParser, NoSectionError, NoOptionError
@@ -10,8 +11,10 @@ from time import asctime, strptime
import copy, getopt, re, os, socket, sys
def generatereport(rspec, nrpt):
- '''generatereport creates and returns an ElementTree representation
- of a report adhering to the XML spec for intermediate reports'''
+ """
+ generatereport creates and returns an ElementTree representation
+ of a report adhering to the XML spec for intermediate reports.
+ """
reportspec = copy.deepcopy(rspec)
nodereprt = copy.deepcopy(nrpt)
@@ -19,7 +22,7 @@ def generatereport(rspec, nrpt):
reportmodified = reportspec.get("modified", default = 'Y')
current_date = asctime()[:10]
- '''build regex of all the nodes we are reporting about'''
+ """Build regex of all the nodes we are reporting about."""
pattern = re.compile( '|'.join([item.get("name") for item in reportspec.findall('Machine')]))
for node in nodereprt.findall('Node'):
@@ -51,7 +54,7 @@ def generatereport(rspec, nrpt):
return nodereprt
def mail(mailbody, confi):
- '''mail mails a previously generated report'''
+ """mail mails a previously generated report."""
try:
mailer = confi.get('statistics', 'sendmailpath')
@@ -66,8 +69,9 @@ def mail(mailbody, confi):
print "Exit code: %s" % exitcode
def rss(reportxml, delivery, report):
- '''rss appends a new report to the specified rss file
- keeping the last 9 articles'''
+ """rss appends a new report to the specified rss file
+ keeping the last 9 articles.
+ """
#check and see if rss file exists
for destination in delivery.findall('Destination'):
try:
@@ -105,7 +109,7 @@ def rss(reportxml, delivery, report):
fil.close()
def www(reportxml, delivery):
- '''www outputs report to'''
+ """www outputs report to"""
#this can later link to WWW report if one gets published simultaneously?
for destination in delivery.findall('Destination'):
@@ -115,7 +119,7 @@ def www(reportxml, delivery):
fil.close()
def fileout(reportxml, delivery):
- '''outputs to plain text file'''
+ """outputs to plain text file"""
for destination in delivery.findall('Destination'):
fil = open(destination.attrib['address'], 'w')
@@ -123,7 +127,7 @@ def fileout(reportxml, delivery):
fil.close()
def pretty_print(element, level=0):
- '''Produce a pretty-printed text representation of element'''
+ """Produce a pretty-printed text representation of element."""
if element.text:
fmt = "%s<%%s %%s>%%s</%%s>" % (level*" ")
data = (element.tag, (" ".join(["%s='%s'" % keyval for keyval in element.attrib.iteritems()])),
@@ -188,7 +192,7 @@ if __name__ == '__main__':
# os.system('GenerateHostInfo')#Generate HostInfo needs to be in path
- '''Reads Data & Config files'''
+ """Reads Data & Config files"""
try:
statsdata = XML(open(statpath).read())
except (IOError, XMLSyntaxError):