summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Admin/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Server/Admin/__init__.py')
-rw-r--r--src/lib/Server/Admin/__init__.py25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/lib/Server/Admin/__init__.py b/src/lib/Server/Admin/__init__.py
index dc3dc8c01..411f909ee 100644
--- a/src/lib/Server/Admin/__init__.py
+++ b/src/lib/Server/Admin/__init__.py
@@ -27,14 +27,17 @@ import sys
import Bcfg2.Server.Core
import Bcfg2.Options
+
class ModeOperationError(Exception):
pass
+
class Mode(object):
"""Help message has not yet been added for mode."""
__shorthelp__ = 'Shorthelp not defined yet'
__longhelp__ = 'Longhelp not defined yet'
__args__ = []
+
def __init__(self, configfile):
self.configfile = configfile
self.__cfp = False
@@ -50,11 +53,11 @@ class Mode(object):
def __call__(self, args):
if len(args) > 0 and args[0] == 'help':
- print self.__longhelp__
+ print(self.__longhelp__)
raise SystemExit(0)
def errExit(self, emsg):
- print emsg
+ print(emsg)
raise SystemExit(1)
def get_repo_path(self):
@@ -80,9 +83,9 @@ class Mode(object):
"""
hdelim = "="
- justify = {'left':str.ljust,
- 'center':str.center,
- 'right':str.rjust}[justify.lower()]
+ justify = {'left': str.ljust,
+ 'center': str.center,
+ 'right': str.rjust}[justify.lower()]
"""
Calculate column widths (longest item in each column
@@ -90,9 +93,9 @@ class Mode(object):
"""
cols = list(zip(*rows))
- colWidths = [max([len(str(item))+2*padding for \
+ colWidths = [max([len(str(item)) + 2 * padding for \
item in col]) for col in cols]
- borderline = vdelim.join([w*hdelim for w in colWidths])
+ borderline = vdelim.join([w * hdelim for w in colWidths])
# Print out the table
print(borderline)
@@ -103,6 +106,7 @@ class Mode(object):
print(borderline)
hdr = False
+
class MetadataCore(Mode):
"""Base class for admin-modes that handle metadata."""
def __init__(self, configfile, usage, pwhitelist=None, pblacklist=None):
@@ -113,9 +117,11 @@ class MetadataCore(Mode):
setup.hm = usage
setup.parse(sys.argv[1:])
if pwhitelist is not None:
- setup['plugins'] = [x for x in setup['plugins'] if x in pwhitelist]
+ setup['plugins'] = [x for x in setup['plugins']
+ if x in pwhitelist]
elif pblacklist is not None:
- setup['plugins'] = [x for x in setup['plugins'] if x not in pblacklist]
+ setup['plugins'] = [x for x in setup['plugins']
+ if x not in pblacklist]
try:
self.bcore = Bcfg2.Server.Core.Core(self.get_repo_path(),
setup['plugins'],
@@ -125,5 +131,6 @@ class MetadataCore(Mode):
self.bcore.fam.handle_events_in_interval(5)
self.metadata = self.bcore.metadata
+
class StructureMode(MetadataCore):
pass