summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Admin/Tidy.py
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-04-06 19:34:30 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-04-06 19:35:21 -0500
commit742fc83dcdb82639b97723ce4cbfade75fb1aa71 (patch)
tree3c242e7029ab20f03300292d272e665c33c17943 /src/lib/Server/Admin/Tidy.py
parente17608a61575ec9d50cfed34a80540257254840b (diff)
downloadbcfg2-742fc83dcdb82639b97723ce4cbfade75fb1aa71.tar.gz
bcfg2-742fc83dcdb82639b97723ce4cbfade75fb1aa71.tar.bz2
bcfg2-742fc83dcdb82639b97723ce4cbfade75fb1aa71.zip
bcfg2-admin: PY3K + PEP8 fixes
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Server/Admin/Tidy.py')
-rw-r--r--src/lib/Server/Admin/Tidy.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lib/Server/Admin/Tidy.py b/src/lib/Server/Admin/Tidy.py
index cc8ab4f5e..f79991fd9 100644
--- a/src/lib/Server/Admin/Tidy.py
+++ b/src/lib/Server/Admin/Tidy.py
@@ -4,6 +4,7 @@ import socket
import Bcfg2.Server.Admin
+
class Tidy(Bcfg2.Server.Admin.Mode):
__shorthelp__ = "Clean up useless files in the repo"
__longhelp__ = __shorthelp__ + "\n\nbcfg2-admin tidy [-f] [-I]\n"
@@ -24,17 +25,21 @@ class Tidy(Bcfg2.Server.Admin.Mode):
if '-f' in args or '-I' in args:
if '-I' in args:
for name in badfiles[:]:
- answer = raw_input("Unlink file %s? [yN] " % name)
+ # py3k compatibility
+ try:
+ answer = raw_input("Unlink file %s? [yN] " % name)
+ except NameError:
+ answer = input("Unlink file %s? [yN] " % name)
if answer not in ['y', 'Y']:
badfiles.remove(name)
for name in badfiles:
try:
os.unlink(name)
except IOError:
- print "Failed to unlink %s" % name
+ print("Failed to unlink %s" % name)
else:
for name in badfiles:
- print name
+ print(name)
def buildTidyList(self):
"""Clean up unused or unusable files from the repository."""
@@ -56,7 +61,8 @@ class Tidy(Bcfg2.Server.Admin.Mode):
bad.append(hostname)
for name in os.listdir("%s/SSHbase" % (self.get_repo_path())):
if not hostmatcher.match(name):
- to_remove.append("%s/SSHbase/%s" % (self.get_repo_path(), name))
+ to_remove.append("%s/SSHbase/%s" % (self.get_repo_path(),
+ name))
else:
if hostmatcher.match(name).group(1) in bad:
to_remove.append("%s/SSHbase/%s" %