diff options
author | Fabian Affolter <fabian@bernewireless.net> | 2010-06-07 11:03:09 +0000 |
---|---|---|
committer | Sol Jerome <solj@ices.utexas.edu> | 2010-06-07 08:42:52 -0500 |
commit | 0b5debac6873733685bc55fc1f88da6b5879a85f (patch) | |
tree | ef6fdc4c51ad1d86228707cfaccef6c6d7e0d072 /src/sbin | |
parent | d52c925dedfabc0f8ba0b3a137fcf977749a055e (diff) | |
download | bcfg2-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')
-rwxr-xr-x | src/sbin/bcfg2 | 10 | ||||
-rwxr-xr-x | src/sbin/bcfg2-admin | 6 | ||||
-rwxr-xr-x | src/sbin/bcfg2-build-reports | 28 | ||||
-rwxr-xr-x | src/sbin/bcfg2-info | 46 | ||||
-rwxr-xr-x | src/sbin/bcfg2-ping-sweep | 7 | ||||
-rwxr-xr-x | src/sbin/bcfg2-repo-validate | 6 | ||||
-rwxr-xr-x | src/sbin/bcfg2-reports | 16 | ||||
-rwxr-xr-x | src/sbin/bcfg2-server | 2 |
8 files changed, 66 insertions, 55 deletions
diff --git a/src/sbin/bcfg2 b/src/sbin/bcfg2 index 13ecf1886..a856a2c76 100755 --- a/src/sbin/bcfg2 +++ b/src/sbin/bcfg2 @@ -1,6 +1,6 @@ #!/usr/bin/env python -'''Bcfg2 Client''' +"""Bcfg2 Client""" __revision__ = '$Revision$' import logging @@ -31,7 +31,7 @@ DECISION_LIST = Bcfg2.Options.Option('Decision List', default=False, class Client: - ''' The main bcfg2 client class ''' + """The main bcfg2 client class""" def __init__(self): self.toolset = None @@ -106,7 +106,7 @@ class Client: raise SystemExit(1) def run_probe(self, probe): - '''Execute probe''' + """Execute probe""" name = probe.get('name') self.logger.info("Running probe %s" % name) ret = Bcfg2.Client.XML.Element("probe-data", @@ -132,12 +132,12 @@ class Client: return ret def fatal_error(self, message): - '''Signal a fatal error''' + """Signal a fatal error""" self.logger.error("Fatal error: %s" % (message)) raise SystemExit(1) def run(self): - ''' Perform client execution phase ''' + """Perform client execution phase""" times = {} # begin configuration diff --git a/src/sbin/bcfg2-admin b/src/sbin/bcfg2-admin index 2d6ba4f5a..49c9452bc 100755 --- a/src/sbin/bcfg2-admin +++ b/src/sbin/bcfg2-admin @@ -1,5 +1,5 @@ #!/usr/bin/env python -'''bcfg2-admin is a script that helps to administrate a bcfg2 deployment''' +"""bcfg2-admin is a script that helps to administrate a Bcfg2 deployment.""" from optparse import OptionParser from StringIO import StringIO @@ -13,14 +13,14 @@ log = logging.getLogger('bcfg2-admin') import Bcfg2.Server.Admin def mode_import(modename): - '''Load Bcfg2.Server.Admin.<mode>''' + """Load Bcfg2.Server.Admin.<mode>""" modname = modename.capitalize() mod = getattr(__import__("Bcfg2.Server.Admin.%s" % (modname)).Server.Admin, modname) return getattr(mod, modname) def get_modes(): - """Get all available modes, except for the base mode""" + """Get all available modes, except for the base mode.""" return [x.lower() for x in Bcfg2.Server.Admin.__all__ if x != 'mode'] def create_description(): 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): diff --git a/src/sbin/bcfg2-info b/src/sbin/bcfg2-info index 00d07d0c8..7a724d19b 100755 --- a/src/sbin/bcfg2-info +++ b/src/sbin/bcfg2-info @@ -1,5 +1,6 @@ #!/usr/bin/python -'''This tool loads the Bcfg2 core into an interactive debugger''' + +"""This tool loads the Bcfg2 core into an interactive debugger""" __revision__ = '$Revision$' from code import InteractiveConsole @@ -31,7 +32,7 @@ class dummyError(Exception): pass class FileNotBuilt(Exception): - ''' Thrown when File entry contains no content''' + """Thrown when File entry contains no content.""" def __init__(self, value): Exception.__init__(self) self.value = value @@ -39,7 +40,7 @@ class FileNotBuilt(Exception): return repr(self.value) def printTabular(rows): - '''print data in tabular format''' + """print data in tabular format.""" cmax = tuple([max([len(str(row[index])) for row in rows]) + 1 \ for index in range(len(rows[0]))]) fstring = (" %%-%ss |" * len(cmax)) % cmax @@ -55,8 +56,9 @@ def displayTrace(trace, num=80, sort=('time', 'calls')): stats.print_stats(200) def write_config_file(outputdir, cfg): - '''Store file content of an <ConfigFile name='/path/to/file' ...>...</ConfigFile> entry - in the appropriate directory under the output directory.''' + """Store file content of an <ConfigFile name='/path/to/file' ...>...</ConfigFile> entry + in the appropriate directory under the output directory. + """ name = cfg.get('name') # directory creation @@ -135,8 +137,10 @@ class infoCore(cmd.Cmd, Bcfg2.Server.Core.Core): sh.interact() def do_quit(self, _): - """Exit program. -Usage: [quit|exit]""" + """ + Exit program. + Usage: [quit|exit] + """ for plugin in self.plugins.values(): plugin.shutdown() os._exit(0) @@ -145,7 +149,7 @@ Usage: [quit|exit]""" do_exit = do_quit def do_help(self, _): - '''print out usage info''' + """Print out usage info""" print 'Commands:' print 'build <hostname> <filename> - build config for hostname, writing to filename' print 'builddir <hostname> <dirname> - build config for hostname, writing separate files to dirname' @@ -168,15 +172,15 @@ Usage: [quit|exit]""" def do_update(self, _): - '''Process pending fs events''' + """Process pending fs events""" self.fam.handle_events_in_interval(0.1) def do_version(self, _): - '''print out code version''' + """Print out code version""" print(__revision__) def do_build(self, args): - '''build client configuration''' + """Build client configuration""" alist = args.split() path_force = False if '-f' in args: @@ -197,7 +201,7 @@ Usage: [quit|exit]""" print('Usage: build [-f] <hostname> <output file>') def help_builddir(self): - '''Display help for builddir command''' + """Display help for builddir command.""" print('Usage: builddir [-f] <hostname> <output dir>') print('') print('Generates a config for client <hostname> and writes the') @@ -212,7 +216,7 @@ Usage: [quit|exit]""" print('bcfg2 client itself.') def do_builddir(self, args): - '''build client configuration as separate files within a dir''' + """Build client configuration as separate files within a dir.""" alist = args.split() path_force = False if '-f' in args: @@ -257,7 +261,7 @@ Usage: [quit|exit]""" self.do_build("%s %s/%s.xml" % (client, args, client)) def do_buildfile(self, args): - '''build a config file for client''' + """Build a config file for client.""" if len(args.split()) == 2: fname, client = args.split() entry = lxml.etree.Element('Path', type='file', name=fname) @@ -268,7 +272,7 @@ Usage: [quit|exit]""" print('Usage: buildfile filename hostname') def do_bundles(self, _): - '''print out group/bundle info''' + """Print out group/bundle info.""" data = [('Group', 'Bundles')] groups = list(self.metadata.groups.keys()) groups.sort() @@ -278,7 +282,7 @@ Usage: [quit|exit]""" printTabular(data) def do_clients(self, _): - '''print out client info''' + """Print out client info.""" data = [('Client', 'Profile')] clist = list(self.metadata.clients.keys()) clist.sort() @@ -287,12 +291,12 @@ Usage: [quit|exit]""" printTabular(data) def do_generators(self, _): - '''print out generator info''' + """Print out generator info.""" for generator in self.generators: print(generator.__version__) def do_showentries(self, args): - '''show abstract configuration entries for a given host''' + """Show abstract configuration entries for a given host.""" arglen = len(args.split()) if arglen not in [2, 3]: print("Usage: showentries <hostname> <type>") @@ -318,7 +322,7 @@ Usage: [quit|exit]""" printTabular(output) def do_groups(self, _): - '''print out group info''' + """Print out group info.""" data = [("Groups", "Profile", "Category", "Contains")] grouplist = list(self.metadata.groups.keys()) grouplist.sort() @@ -338,7 +342,7 @@ Usage: [quit|exit]""" printTabular(data) def do_showclient(self, args): - ''' print host metadata''' + """Print host metadata.""" data = [('Client', 'Profile', "Groups", "Bundles")] if not len(args): print("Usage:\nshowclient <client> ... <clientN>") @@ -367,7 +371,7 @@ Usage: [quit|exit]""" print "=" * 80 def do_mappings(self, args): - '''print out mapping info''' + """Print out mapping info.""" # dump all mappings unless type specified data = [('Plugin', 'Type', 'Name')] arglen = len(args.split()) diff --git a/src/sbin/bcfg2-ping-sweep b/src/sbin/bcfg2-ping-sweep index 88d8bd782..c1beac312 100755 --- a/src/sbin/bcfg2-ping-sweep +++ b/src/sbin/bcfg2-ping-sweep @@ -1,11 +1,14 @@ #!/usr/bin/env python #GenerateHostInfo - Joey Hagedorn - hagedorn@mcs.anl.gov -'''Generates hostinfo.xml at a regular interval''' +"""Generates hostinfo.xml at a regular interval""" + __revision__ = '$Revision$' from os import dup2, execl, fork, uname, wait -import lxml.etree, sys, time +import sys +import time +import lxml.etree import Bcfg2.Options diff --git a/src/sbin/bcfg2-repo-validate b/src/sbin/bcfg2-repo-validate index 47015f4ec..1bdcf4180 100755 --- a/src/sbin/bcfg2-repo-validate +++ b/src/sbin/bcfg2-repo-validate @@ -1,9 +1,9 @@ #!/usr/bin/env python -''' +""" bcfg2-repo-validate checks all xml files in Bcfg2 -repos against their respective XML schemas -''' +repos against their respective XML schemas. +""" __revision__ = '$Revision$' import glob diff --git a/src/sbin/bcfg2-reports b/src/sbin/bcfg2-reports index 35c72f9d7..337a2480f 100755 --- a/src/sbin/bcfg2-reports +++ b/src/sbin/bcfg2-reports @@ -1,5 +1,5 @@ #! /usr/bin/env python -'''Query reporting system for client status''' +"""Query reporting system for client status""" __revision__ = '$Revision$' import os @@ -21,16 +21,16 @@ import datetime import fileinput def timecompare(client1, client2): - '''compares two clients by their timestamps''' + """Compares two clients by their timestamps""" return cmp(client1.current_interaction.timestamp, \ client2.current_interaction.timestamp) def namecompare(client1, client2): - '''compares two clients by their names''' + """Compares two clients by their names""" return cmp(client1.name, client2.name) def statecompare(client1, client2): - '''compares two clients by their states''' + """Compares two clients by their states""" clean1 = client1.current_interaction.isclean() clean2 = client2.current_interaction.isclean() @@ -42,7 +42,7 @@ def statecompare(client1, client2): return 0 def crit_compare(criterion, client1, client2): - '''compares two clients by the criteria provided in criterion''' + """Compares two clients by the criteria provided in criterion""" for crit in criterion: comp = 0 if crit == 'name': @@ -58,10 +58,10 @@ def crit_compare(criterion, client1, client2): return 0 def print_fields(fields, cli, max_name, entrydict): - ''' - prints the fields specified in fields of cli, max_name + """ + Prints the fields specified in fields of cli, max_name specifies the column width of the name column - ''' + """" fmt = '' for field in fields: if field == 'name': diff --git a/src/sbin/bcfg2-server b/src/sbin/bcfg2-server index 73802965e..62bad7633 100755 --- a/src/sbin/bcfg2-server +++ b/src/sbin/bcfg2-server @@ -1,6 +1,6 @@ #!/usr/bin/env python -'''The XML-RPC Bcfg2 Server''' +"""The XML-RPC Bcfg2 Server""" __revision__ = '$Revision$' import logging |