diff options
author | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-10-17 10:26:13 -0400 |
---|---|---|
committer | Chris St. Pierre <chris.a.st.pierre@gmail.com> | 2012-10-17 10:27:42 -0400 |
commit | 90b1276b8039642f95f5987ff1d0df413454a6d9 (patch) | |
tree | 72b6a65f3e2614d7b9d693e173d683e234fbac0d /src/lib/Bcfg2/Server/Admin/Viz.py | |
parent | 6eeded84fca720269d1fda36f785f01ddeb705bb (diff) | |
download | bcfg2-90b1276b8039642f95f5987ff1d0df413454a6d9.tar.gz bcfg2-90b1276b8039642f95f5987ff1d0df413454a6d9.tar.bz2 bcfg2-90b1276b8039642f95f5987ff1d0df413454a6d9.zip |
expanded pylint coverage to Admin modes, removed some old/broken admin modes
Diffstat (limited to 'src/lib/Bcfg2/Server/Admin/Viz.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Admin/Viz.py | 59 |
1 files changed, 26 insertions, 33 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Viz.py b/src/lib/Bcfg2/Server/Admin/Viz.py index b190dd62a..1d9d25f16 100644 --- a/src/lib/Bcfg2/Server/Admin/Viz.py +++ b/src/lib/Bcfg2/Server/Admin/Viz.py @@ -1,17 +1,14 @@ +""" Produce graphviz diagrams of metadata structures """ + import getopt from subprocess import Popen, PIPE -import sys import pipes import Bcfg2.Server.Admin class Viz(Bcfg2.Server.Admin.MetadataCore): - __shorthelp__ = "Produce graphviz diagrams of metadata structures" - __longhelp__ = (__shorthelp__ + "\n\nbcfg2-admin viz [--includehosts] " - "[--includebundles] [--includekey] " - "[--only-client clientname] " - "[-o output.<ext>]\n") - __usage__ = ("bcfg2-admin viz [options]\n\n" + """ Produce graphviz diagrams of metadata structures """ + __usage__ = ("[options]\n\n" " %-32s%s\n" " %-32s%s\n" " %-32s%s\n" @@ -32,23 +29,20 @@ class Viz(Bcfg2.Server.Admin.MetadataCore): 'indianred1', 'limegreen', 'orange1', 'lightblue2', 'green1', 'blue1', 'yellow1', 'darkturquoise', 'gray66'] - __plugin_blacklist__ = ['DBStats', 'Snapshots', 'Cfg', 'Pkgmgr', 'Packages', - 'Rules', 'Account', 'Decisions', 'Deps', 'Git', - 'Svn', 'Fossil', 'Bzr', 'Bundler', 'TGenshi', - 'Base'] + __plugin_blacklist__ = ['DBStats', 'Snapshots', 'Cfg', 'Pkgmgr', + 'Packages', 'Rules', 'Account', 'Decisions', + 'Deps', 'Git', 'Svn', 'Fossil', 'Bzr', 'Bundler', + 'TGenshi', 'Base'] def __call__(self, args): - Bcfg2.Server.Admin.MetadataCore.__call__(self, args) # First get options to the 'viz' subcommand try: opts, args = getopt.getopt(args, 'Hbkc:o:', ['includehosts', 'includebundles', - 'includekey', 'only-client=', 'outfile=']) + 'includekey', 'only-client=', + 'outfile=']) except getopt.GetoptError: - msg = sys.exc_info()[1] - print(msg) - print(self.__longhelp__) - raise SystemExit(1) + self.usage() hset = False bset = False @@ -67,21 +61,19 @@ class Viz(Bcfg2.Server.Admin.MetadataCore): elif opt in ("-o", "--outfile"): outputfile = arg - data = self.Visualize(self.setup['repo'], hset, bset, - kset, only_client, outputfile) + data = self.Visualize(hset, bset, kset, only_client, outputfile) if data: print(data) - raise SystemExit(0) - def Visualize(self, repopath, hosts=False, - bundles=False, key=False, only_client=None, output=False): + def Visualize(self, hosts=False, bundles=False, key=False, + only_client=None, output=None): """Build visualization of groups file.""" if output: - format = output.split('.')[-1] + fmt = output.split('.')[-1] else: - format = 'png' + fmt = 'png' - cmd = ["dot", "-T", format] + cmd = ["dot", "-T", fmt] if output: cmd.extend(["-o", output]) try: @@ -91,7 +83,7 @@ class Viz(Bcfg2.Server.Admin.MetadataCore): # shell=True. on others (Gentoo with Python 2.7), you # must. In yet others (RHEL 5), either way works. I have # no idea what the difference is, but it's kind of a PITA. - cmd = ["dot", "-T", pipes.quote(format)] + cmd = ["dot", "-T", pipes.quote(fmt)] if output: cmd.extend(["-o", pipes.quote(output)]) dotpipe = Popen(cmd, shell=True, @@ -106,13 +98,14 @@ class Viz(Bcfg2.Server.Admin.MetadataCore): key, only_client, self.colors)) if key: dotpipe.stdin.write("\tsubgraph cluster_key {\n") - dotpipe.stdin.write('''\tstyle="filled";\n''') - dotpipe.stdin.write('''\tcolor="lightblue";\n''') - dotpipe.stdin.write('''\tBundle [ shape="septagon" ];\n''') - dotpipe.stdin.write('''\tGroup [shape="ellipse"];\n''') - dotpipe.stdin.write('''\tProfile [style="bold", shape="ellipse"];\n''') - dotpipe.stdin.write('''\tHblock [label="Host1|Host2|Host3", shape="record"];\n''') - dotpipe.stdin.write('''\tlabel="Key";\n''') + dotpipe.stdin.write('\tstyle="filled";\n') + dotpipe.stdin.write('\tcolor="lightblue";\n') + dotpipe.stdin.write('\tBundle [ shape="septagon" ];\n') + dotpipe.stdin.write('\tGroup [shape="ellipse"];\n') + dotpipe.stdin.write('\tProfile [style="bold", shape="ellipse"];\n') + dotpipe.stdin.write('\tHblock [label="Host1|Host2|Host3", ' + 'shape="record"];\n') + dotpipe.stdin.write('\tlabel="Key";\n') dotpipe.stdin.write("\t}\n") dotpipe.stdin.write("}\n") dotpipe.stdin.close() |