summaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorFabian Affolter <fabian@bernewireless.net>2010-06-07 10:55:15 +0000
committerSol Jerome <solj@ices.utexas.edu>2010-06-07 08:42:52 -0500
commitd52c925dedfabc0f8ba0b3a137fcf977749a055e (patch)
treecba4ec4d0da8d5d55b2999cded97a22f6edfe659 /src/lib
parent673eab34d1aa60b2a159bd8371f4449564fbb8cd (diff)
downloadbcfg2-d52c925dedfabc0f8ba0b3a137fcf977749a055e.tar.gz
bcfg2-d52c925dedfabc0f8ba0b3a137fcf977749a055e.tar.bz2
bcfg2-d52c925dedfabc0f8ba0b3a137fcf977749a055e.zip
Updated files to match PEP 257
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5894 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Server/Admin/Init.py25
-rw-r--r--src/lib/Server/Admin/Minestruct.py3
-rw-r--r--src/lib/Server/Admin/Pull.py13
-rw-r--r--src/lib/Server/Admin/Tidy.py2
-rw-r--r--src/lib/Server/Admin/Viz.py2
-rw-r--r--src/lib/Server/Admin/__init__.py14
6 files changed, 29 insertions, 30 deletions
diff --git a/src/lib/Server/Admin/Init.py b/src/lib/Server/Admin/Init.py
index d674db1bd..d43f4c767 100644
--- a/src/lib/Server/Admin/Init.py
+++ b/src/lib/Server/Admin/Init.py
@@ -87,7 +87,7 @@ default_plugins = ['SSHbase', 'Cfg', 'Pkgmgr', 'Rules',
'Metadata', 'Base', 'Bundler']
def gen_password(length):
- """Generates a random alphanumeric password with length characters"""
+ """Generates a random alphanumeric password with length characters."""
chars = string.letters + string.digits
newpasswd = ''
for i in range(length):
@@ -95,7 +95,7 @@ def gen_password(length):
return newpasswd
def create_key(hostname, keypath, certpath):
- """Creates a bcfg2.key at the directory specifed by keypath"""
+ """Creates a bcfg2.key at the directory specifed by keypath."""
kcstr = "openssl req -batch -x509 -nodes -subj '/C=US/ST=Illinois/L=Argonne/CN=%s' -days 1000 -newkey rsa:2048 -keyout %s -noout" % (hostname, keypath)
subprocess.call((kcstr), shell=True)
ccstr = "openssl req -batch -new -subj '/C=US/ST=Illinois/L=Argonne/CN=%s' -key %s | openssl x509 -req -days 1000 -signkey %s -out %s" % (hostname, keypath, keypath, certpath)
@@ -121,7 +121,7 @@ def create_conf(confpath, confdata):
class Init(Bcfg2.Server.Admin.Mode):
- __shorthelp__ = ("Interactively initialize a new repository")
+ __shorthelp__ = ("Interactively initialize a new repository.")
__longhelp__ = __shorthelp__ + "\n\nbcfg2-admin init"
__usage__ = "bcfg2-admin init"
options = {
@@ -137,7 +137,7 @@ class Init(Bcfg2.Server.Admin.Mode):
Bcfg2.Server.Admin.Mode.__init__(self, configfile)
def _set_defaults(self):
- """Set default parameters"""
+ """Set default parameters."""
self.configfile = self.opts['configfile']
self.repopath = self.opts['repo']
self.password = gen_password(8)
@@ -164,7 +164,7 @@ class Init(Bcfg2.Server.Admin.Mode):
self.init_repo()
def _prompt_hostname(self):
- '''Ask for the server hostname'''
+ """Ask for the server hostname."""
data = raw_input("What is the server's hostname: [%s]" % socket.getfqdn())
if data != '':
self.shostname = data
@@ -172,14 +172,14 @@ class Init(Bcfg2.Server.Admin.Mode):
self.shostname = socket.getfqdn()
def _prompt_config(self):
- """Ask for the configuration file path"""
+ """Ask for the configuration file path."""
newconfig = raw_input("Store bcfg2 configuration in [%s]: " %
self.configfile)
if newconfig != '':
self.configfile = newconfig
def _prompt_repopath(self):
- """Ask for the repository path"""
+ """Ask for the repository path."""
while True:
newrepo = raw_input("Location of bcfg2 repository [%s]: " %
self.repopath)
@@ -194,7 +194,7 @@ class Init(Bcfg2.Server.Admin.Mode):
break
def _prompt_password(self):
- """Ask for a password or generate one if none is provided"""
+ """Ask for a password or generate one if none is provided."""
newpassword = getpass.getpass(
"Input password used for communication verification "
"(without echoing; leave blank for a random): ").strip()
@@ -202,13 +202,13 @@ class Init(Bcfg2.Server.Admin.Mode):
self.password = newpassword
def _prompt_server(self):
- """Ask for the server name"""
+ """Ask for the server name."""
newserver = raw_input("Input the server location [%s]: " % self.server_uri)
if newserver != '':
self.server_uri = newserver
def _prompt_groups(self):
- """Create the groups.xml file"""
+ """Create the groups.xml file."""
prompt = '''Input base Operating System for clients:\n'''
for entry in os_list:
prompt += "%d: %s\n" % (os_list.index(entry) + 1, entry[0])
@@ -236,7 +236,7 @@ class Init(Bcfg2.Server.Admin.Mode):
break
def _init_plugins(self):
- # Initialize each plugin-specific portion of the repository
+ """Initialize each plugin-specific portion of the repository."""
for plugin in self.plugins:
if plugin == 'Metadata':
Bcfg2.Server.Plugins.Metadata.Metadata.init_repo(self.repopath, groups, self.os_sel, clients)
@@ -250,8 +250,7 @@ class Init(Bcfg2.Server.Admin.Mode):
print 'Plugin setup for %s failed: %s\n Check that dependencies are installed?' % (plugin, e)
def init_repo(self):
- '''Setup a new repo'''
- # Create the contents of the configuration file
+ """Setup a new repo and create the content of the configuration file."""
keypath = os.path.dirname(os.path.abspath(self.configfile))
confdata = config % (
self.repopath,
diff --git a/src/lib/Server/Admin/Minestruct.py b/src/lib/Server/Admin/Minestruct.py
index f1ffa129a..02edf2b75 100644
--- a/src/lib/Server/Admin/Minestruct.py
+++ b/src/lib/Server/Admin/Minestruct.py
@@ -1,4 +1,3 @@
-'''Minestruct Admin Mode'''
import getopt
import lxml.etree
import sys
@@ -6,7 +5,7 @@ import sys
import Bcfg2.Server.Admin
class Minestruct(Bcfg2.Server.Admin.StructureMode):
- '''Pull extra entries out of statistics'''
+ """Pull extra entries out of statistics."""
__shorthelp__ = "Extract extra entry lists from statistics"
__longhelp__ = (__shorthelp__ +
"\n\nbcfg2-admin minestruct [-f filename] "
diff --git a/src/lib/Server/Admin/Pull.py b/src/lib/Server/Admin/Pull.py
index 993dbc0c5..d6dfa9e5a 100644
--- a/src/lib/Server/Admin/Pull.py
+++ b/src/lib/Server/Admin/Pull.py
@@ -2,10 +2,9 @@ import getopt
import Bcfg2.Server.Admin
class Pull(Bcfg2.Server.Admin.MetadataCore):
- '''
- Pull mode retrieves entries from clients and
- integrates the information into the repository
- '''
+ """Pull mode retrieves entries from clients and
+ integrates the information into the repository.
+ """
__shorthelp__ = ("Integrate configuration information "
"from clients into the server repository")
__longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin pull [-v] [-f][-I] "
@@ -46,7 +45,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
self.PullEntry(gargs[0], gargs[1], gargs[2])
def BuildNewEntry(self, client, etype, ename):
- '''construct a new full entry for given client/entry from statistics'''
+ """Construct a new full entry for given client/entry from statistics."""
new_entry = {'type':etype, 'name':ename}
for plugin in self.bcore.pull_sources:
try:
@@ -71,7 +70,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
return new_entry
def Choose(self, choices):
- '''Determine where to put pull data'''
+ """Determine where to put pull data."""
if self.mode == 'interactive':
for choice in choices:
print "Plugin returned choice:"
@@ -94,7 +93,7 @@ class Pull(Bcfg2.Server.Admin.MetadataCore):
return choices[0]
def PullEntry(self, client, etype, ename):
- '''Make currently recorded client state correct for entry'''
+ """Make currently recorded client state correct for entry."""
new_entry = self.BuildNewEntry(client, etype, ename)
meta = self.bcore.build_metadata(client)
diff --git a/src/lib/Server/Admin/Tidy.py b/src/lib/Server/Admin/Tidy.py
index 3e51d9d75..c02ddf110 100644
--- a/src/lib/Server/Admin/Tidy.py
+++ b/src/lib/Server/Admin/Tidy.py
@@ -37,7 +37,7 @@ class Tidy(Bcfg2.Server.Admin.Mode):
print name
def buildTidyList(self):
- '''Clean up unused or unusable files from the repository'''
+ """Clean up unused or unusable files from the repository."""
hostmatcher = re.compile('.*\.H_(\S+)$')
to_remove = []
good = []
diff --git a/src/lib/Server/Admin/Viz.py b/src/lib/Server/Admin/Viz.py
index f49df37e8..245ca8398 100644
--- a/src/lib/Server/Admin/Viz.py
+++ b/src/lib/Server/Admin/Viz.py
@@ -67,7 +67,7 @@ class Viz(Bcfg2.Server.Admin.MetadataCore):
def Visualize(self, repopath, hosts=False,
bundles=False, key=False, output=False):
- '''Build visualization of groups file'''
+ """Build visualization of groups file."""
if output:
format = output.split('.')[-1]
else:
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index 99f52bda4..e46a2e40c 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -15,7 +15,7 @@ class ModeOperationError(Exception):
pass
class Mode(object):
- '''Help message has not yet been added for mode'''
+ """Help message has not yet been added for mode."""
__shorthelp__ = 'Shorthelp not defined yet'
__longhelp__ = 'Longhelp not defined yet'
__args__ = []
@@ -42,7 +42,7 @@ class Mode(object):
raise SystemExit(1)
def get_repo_path(self):
- '''return repository path'''
+ """Return repository path"""
return self.cfp.get('server', 'repository')
def load_stats(self, client):
@@ -61,16 +61,18 @@ class Mode(object):
vdelim - vertical delimiter between columns
padding - # of spaces around the longest element in the column
justify - may be left,center,right
+
"""
hdelim = "="
justify = {'left':str.ljust,
'center':str.center,
'right':str.rjust}[justify.lower()]
- '''
- calculate column widths (longest item in each column
+ """
+ Calculate column widths (longest item in each column
plus padding on both sides)
- '''
+
+ """
cols = list(zip(*rows))
colWidths = [max([len(str(item))+2*padding for \
item in col]) for col in cols]
@@ -86,7 +88,7 @@ class Mode(object):
hdr = False
class MetadataCore(Mode):
- '''Base class for admin-modes that handle metadata'''
+ """Base class for admin-modes that handle metadata."""
def __init__(self, configfile, usage, pwhitelist=None, pblacklist=None):
Mode.__init__(self, configfile)
options = {'plugins': Bcfg2.Options.SERVER_PLUGINS,