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/Tidy.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/Tidy.py')
-rw-r--r-- | src/lib/Bcfg2/Server/Admin/Tidy.py | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/lib/Bcfg2/Server/Admin/Tidy.py b/src/lib/Bcfg2/Server/Admin/Tidy.py deleted file mode 100644 index 8a417a427..000000000 --- a/src/lib/Bcfg2/Server/Admin/Tidy.py +++ /dev/null @@ -1,66 +0,0 @@ -import os -import re -import socket - -import Bcfg2.Server.Admin -from Bcfg2.Compat import input - - -class Tidy(Bcfg2.Server.Admin.Mode): - __shorthelp__ = "Clean up useless files in the repo" - __longhelp__ = __shorthelp__ + "\n\nbcfg2-admin tidy [-f] [-I]\n" - __usage__ = ("bcfg2-admin tidy [options]\n\n" - " %-25s%s\n" - " %-25s%s\n" % - ("-f", - "force", - "-I", - "interactive")) - - def __call__(self, args): - Bcfg2.Server.Admin.Mode.__call__(self, args) - badfiles = self.buildTidyList() - if '-f' in args or '-I' in args: - if '-I' in args: - for name in badfiles[:]: - 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) - else: - for name in badfiles: - print(name) - - def buildTidyList(self): - """Clean up unused or unusable files from the repository.""" - hostmatcher = re.compile('.*\.H_(\S+)$') - to_remove = [] - good = [] - bad = [] - - # clean up unresolvable hosts in SSHbase - for name in os.listdir("%s/SSHbase" % self.setup['repo']): - if hostmatcher.match(name): - hostname = hostmatcher.match(name).group(1) - if hostname in good + bad: - continue - try: - socket.gethostbyname(hostname) - good.append(hostname) - except: - bad.append(hostname) - for name in os.listdir("%s/SSHbase" % self.setup['repo']): - if not hostmatcher.match(name): - to_remove.append("%s/SSHbase/%s" % (self.setup['repo'], - name)) - else: - if hostmatcher.match(name).group(1) in bad: - to_remove.append("%s/SSHbase/%s" % - (self.setup['repo'], name)) - # clean up file~ - # clean up files without parsable names in Cfg - return to_remove |