diff options
author | Sol Jerome <sol.jerome@gmail.com> | 2011-04-04 08:59:54 -0500 |
---|---|---|
committer | Sol Jerome <sol.jerome@gmail.com> | 2011-04-06 19:35:21 -0500 |
commit | 50d489f38e18577cb7e75605515d4b8d567aaa52 (patch) | |
tree | 3604a9eb742e7be758311f658b7398befde46d39 /tools/hostbase.py | |
parent | f1cf457edb2a9552adf82d72541af69487f897f4 (diff) | |
download | bcfg2-50d489f38e18577cb7e75605515d4b8d567aaa52.tar.gz bcfg2-50d489f38e18577cb7e75605515d4b8d567aaa52.tar.bz2 bcfg2-50d489f38e18577cb7e75605515d4b8d567aaa52.zip |
tools: PY3K + PEP8 fixes
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'tools/hostbase.py')
-rwxr-xr-x | tools/hostbase.py | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/tools/hostbase.py b/tools/hostbase.py index 974577e69..7474e68b7 100755 --- a/tools/hostbase.py +++ b/tools/hostbase.py @@ -1,36 +1,50 @@ #!/usr/bin/python -import sys, os -os.environ['DJANGO_SETTINGS_MODULE'] = 'Hostbase.settings' -from Hostbase.hostbase.models import Host, Interface +import os from getopt import getopt, GetoptError from re import split +import sys + +os.environ['DJANGO_SETTINGS_MODULE'] = 'Hostbase.settings' +from Hostbase.hostbase.models import Host -attribs = ['hostname', 'whatami', 'netgroup', 'security_class', 'support', - 'csi', 'printq', 'dhcp', 'outbound_smtp', 'primary_user', - 'administrator', 'location', 'expiration_date', 'comments', - 'status', 'last'] +attribs = ['administrator', + 'comments', + 'csi', + 'dhcp', + 'expiration_date', + 'hostname', + 'last', + 'location', + 'netgroup', + 'outbound_smtp', + 'primary_user', + 'printq', + 'security_class', + 'support', + 'status', + 'whatami'] already_exists = None #here's my attempt at making the command line idiot proof #you must supply and arugument and hostname for hostbase.py to run try: - (opts, args) = getopt(sys.argv[1:],'l:c:') + (opts, args) = getopt(sys.argv[1:], 'l:c:') sys.argv[1] if len(split("\.", opts[0][1])) == 1: hosttouse = opts[0][1] + ".mcs.anl.gov" else: hosttouse = opts[0][1] except (GetoptError, IndexError): - print "\nUsage: hostbase.py -flag (hostname)\n" - print "Flags:" - print "\t-l look (hostname)\n" -# print "\t-c copy (hostname)\n" + print("\nUsage: hostbase.py -flag (hostname)\n") + print("Flags:") + print("\t-l look (hostname)\n") +# print("\t-c copy (hostname)\n") sys.exit() try: host = Host.objects.get(hostname=hosttouse) except: - print "Error: host %s not in hostbase" % hosttouse + print("Error: host %s not in hostbase" % hosttouse) sys.exit(1) interfaces = [] for interface in host.interface_set.all(): @@ -53,7 +67,7 @@ for interface in interfaces: if opts[0][0] == '-l': """Displays general host information""" - print hostinfo + print(hostinfo) if opts[0][0] == '-c': """Provides pre-filled template to copy a host record""" |