ArielGlenn has submitted this change and it was merged.
Change subject: some pylint fixes, mainly var names and superfluous imports
......................................................................
some pylint fixes, mainly var names and superfluous imports
Change-Id: I0f577afbdf75773cd0ec288998ecdb595f586ffe
---
M dataretention/retention/cli.py
M dataretention/retention/cliutils.py
M dataretention/retention/config.py
M dataretention/retention/fileinfo.py
M dataretention/retention/ignores.py
M dataretention/retention/localexaminer.py
M dataretention/retention/localfileaudit.py
M dataretention/retention/localhomeaudit.py
M dataretention/retention/locallogaudit.py
M dataretention/retention/localusercfgrabber.py
M dataretention/retention/remoteexaminer.py
M dataretention/retention/remotefileauditor.py
M dataretention/retention/remotehomeauditor.py
M dataretention/retention/remotelogauditor.py
M dataretention/retention/remoteusercfgrabber.py
M dataretention/retention/retentionaudit.py
M dataretention/retention/rule.py
M dataretention/retention/ruleutils.py
M dataretention/retention/runner.py
19 files changed, 101 insertions(+), 121 deletions(-)
Approvals:
ArielGlenn: Verified; Looks good to me, approved
diff --git a/dataretention/retention/cli.py b/dataretention/retention/cli.py
index 6e3a325..8e64149 100644
--- a/dataretention/retention/cli.py
+++ b/dataretention/retention/cli.py
@@ -361,7 +361,7 @@
return contents
def get_basedir_from_path(self, path):
- for location in clouseau.retention.config.cf[self.locations]:
+ for location in clouseau.retention.config.conf[self.locations]:
if path == location or path.startswith(location + os.path.sep):
return location
# fixme is this really the right fallback? check it
diff --git a/dataretention/retention/cliutils.py
b/dataretention/retention/cliutils.py
index 0b3808c..3d4aaea 100644
--- a/dataretention/retention/cliutils.py
+++ b/dataretention/retention/cliutils.py
@@ -1,5 +1,4 @@
import os
-import sys
import readline
import atexit
@@ -48,8 +47,8 @@
count = len(unicode(text, 'utf-8'))
except:
count = len(text)
- if len(text) > max_len[col]:
- max_len[col] = len(text)
+ if count > max_len[col]:
+ max_len[col] = count
for row in range(0, num_rows):
for col in range(0, cols):
diff --git a/dataretention/retention/config.py
b/dataretention/retention/config.py
index 4336547..efb9af2 100644
--- a/dataretention/retention/config.py
+++ b/dataretention/retention/config.py
@@ -1,22 +1,22 @@
import os
import salt.utils.yamlloader
-cf = None
+conf = None
def set_up_conf(confdir):
- global cf
+ global conf
- if cf is not None:
+ if conf is not None:
return
configfile = os.path.join(confdir, 'config.yaml')
if os.path.exists(configfile):
- cf = {}
+ conf = {}
try:
contents = open(configfile).read()
yamlcontents = salt.utils.yamlloader.load(contents,
Loader=salt.utils.yamlloader.SaltYamlSafeLoader)
# fixme do I need this or will a direct assign get it?
for key in yamlcontents:
- cf[key] = yamlcontents[key]
+ conf[key] = yamlcontents[key]
except:
raise
diff --git a/dataretention/retention/fileinfo.py
b/dataretention/retention/fileinfo.py
index 24fc3b0..2b85588 100644
--- a/dataretention/retention/fileinfo.py
+++ b/dataretention/retention/fileinfo.py
@@ -13,18 +13,20 @@
'''
def __init__(self, path):
self.path = path
- self.st = None
+ self.stat = None
self.start_content = None
self.is_binary = None
self.entry_dict = None
+ self.json = None
+ self.is_empty = None
def get_stats(self):
- if self.st is None:
+ if self.stat is None:
try:
- self.st = os.stat(self.path)
+ self.stat = os.stat(self.path)
except:
return None
- return self.st
+ return self.stat
def get_mtime_formatted(self):
'''
@@ -32,14 +34,14 @@
and return it, or None on error
'''
self.get_stats()
- if self.st is not None:
- return time.ctime(self.st.st_mtime)
+ if self.stat is not None:
+ return time.ctime(self.stat.st_mtime)
else:
return ""
def get_start_content(self, num_lines=1):
'''
- get up to the first 1000 characters or the first line from the file
+ get up to the first n*1000 characters or the first n lines from the
file
if not already loaded, and return them, or None on error
this also sets is_empty to the correct value, as a side effect,
if not already set
@@ -49,7 +51,7 @@
try:
filep = gzip.open(self.path, "rb")
lines = ""
- for count in range(0, num_lines):
+ for _ in range(0, num_lines):
line = filep.readline(1000)
if line == "":
break
@@ -121,8 +123,8 @@
get file owner if not already loaded, and return it, or -1 on error
'''
self.get_stats()
- if self.st is not None:
- return self.st.st_uid
+ if self.stat is not None:
+ return self.stat.st_uid
else:
return -1
@@ -137,13 +139,13 @@
self.entry_dict = {}
self.entry_dict['path'] = self.path
self.entry_dict['owner'] = self.get_owner()
- self.entry_dict['size'] = self.st[stat.ST_SIZE]
+ self.entry_dict['size'] = self.stat[stat.ST_SIZE]
self.entry_dict['mtime'] = self.get_mtime_formatted()
- if stat.S_ISLNK(self.st.st_mode):
+ if stat.S_ISLNK(self.stat.st_mode):
self.entry_dict['type'] = 'link'
- elif stat.S_ISDIR(self.st.st_mode):
+ elif stat.S_ISDIR(self.stat.st_mode):
self.entry_dict['type'] = 'dir'
- elif stat.S_ISREG(self.st.st_mode):
+ elif stat.S_ISREG(self.stat.st_mode):
self.entry_dict['type'] = 'file'
else:
self.entry_dict['type'] = 'unknown'
@@ -256,7 +258,7 @@
'''
super(FileInfo, self).__init__(path)
self.name = os.path.basename(self.path)
- self.st = statinfo
+ self.stat = statinfo
self.filetype = None
self.is_empty = None
self.is_open = None
@@ -271,8 +273,8 @@
and return it, or None on error
'''
self.get_stats()
- if self.st is not None:
- return self.st.st_ctime
+ if self.stat is not None:
+ return self.stat.st_ctime
else:
return None
@@ -282,8 +284,8 @@
and return it, or None on error
'''
self.get_stats()
- if self.st is not None:
- return self.st.st_mtime
+ if self.stat is not None:
+ return self.stat.st_mtime
else:
return None
@@ -353,9 +355,9 @@
self.get_ctime()
self.get_mtime()
- if self.st is not None:
- age = max(from_time - self.st.st_ctime,
- from_time - self.st.st_mtime)
+ if self.stat is not None:
+ age = max(from_time - self.stat.st_ctime,
+ from_time - self.stat.st_mtime)
else:
age = None
@@ -460,10 +462,10 @@
'old': FileInfo.bool_to_string(self.get_is_old()),
'type': self.get_filetype(),
'binary': self.get_is_binary(),
- 'stat': FileInfo.stat_to_dict(self.st),
+ 'stat': FileInfo.stat_to_dict(self.stat),
'entrydate': self.entrydate}
if ((not self.is_binary and 'data' not in self.filetype and
- 'binary' not in self.filetype) and
+ 'binary' not in self.filetype) and
self.start_content is not None):
self.entry_dict['content'] = self.start_content
return self.entry_dict
@@ -503,7 +505,7 @@
prettyprint, path_justify)
@staticmethod
- def fileinfo_from_dict(self, item, fromtime=None):
+ def fileinfo_from_dict(item, fromtime=None):
'''
this is the inverse of produce_dict, returning a new
FileInfo object
@@ -512,7 +514,7 @@
fromtime = time.time()
# fixme - eh? what's broken?
finfo = FileInfo(item['path'], magic=None, statinfo=None)
- finfo.st = item['stat']
+ finfo.stat = item['stat']
finfo.filetype = item['filetype']
if 'content' in item:
finfo.start_content = item['content']
diff --git a/dataretention/retention/ignores.py
b/dataretention/retention/ignores.py
index 8098ae1..f839a0e 100644
--- a/dataretention/retention/ignores.py
+++ b/dataretention/retention/ignores.py
@@ -131,7 +131,7 @@
clouseau.retention.config.set_up_conf(confdir)
home_dirs = []
- for location in clouseau.retention.config.cf[locations]:
+ for location in clouseau.retention.config.conf[locations]:
if not os.path.isdir(location):
continue
home_dirs.extend([os.path.join(location, d)
diff --git a/dataretention/retention/localexaminer.py
b/dataretention/retention/localexaminer.py
index 718b246..9639d60 100644
--- a/dataretention/retention/localexaminer.py
+++ b/dataretention/retention/localexaminer.py
@@ -1,12 +1,9 @@
import os
import stat
import json
-import logging
from clouseau.retention.utils import JsonHelper
from clouseau.retention.fileinfo import FileInfo, EntryInfo
-
-log = logging.getLogger(__name__)
class LocalFileExaminer(object):
@@ -39,7 +36,7 @@
'''
def __init__(self, path, batchno=1, batchsize=50, prettyprint=False):
self.path = path
- self.st = None
+ self.stat = None
self.full_contents = None
self.batch_contents = None
self.batch_entryinfo = None
@@ -53,12 +50,12 @@
'''
if path is None:
path = self.path
- if self.st is None:
+ if self.stat is None:
try:
- self.st = os.stat(self.path)
+ self.stat = os.stat(self.path)
except:
return None
- return self.st
+ return self.stat
def read_dir_batch(self):
'''
@@ -90,11 +87,11 @@
def get_contents(self):
if self.batch_contents is None:
self.get_dir_stats()
- if self.st is None:
+ if self.stat is None:
return "dir stat failed"
- if stat.S_ISLNK(self.st.st_mode):
+ if stat.S_ISLNK(self.stat.st_mode):
return "link"
- if not stat.S_ISDIR(self.st.st_mode):
+ if not stat.S_ISDIR(self.stat.st_mode):
return "not dir"
self.read_dir_batch()
if self.batch_contents is None:
@@ -148,7 +145,7 @@
output.append(self.display_json(entry))
output = '\n'.join(output)
return output
-
+
class LocalDirExaminer(object):
'''
@@ -156,7 +153,7 @@
'''
def __init__(self, path, batchno=1, batchsize=300, timeout=20,
quiet=False):
self.path = path
- self.st = None
+ self.stat = None
self.timeout = timeout
self.batchno = batchno
self.batchsize = batchsize
@@ -171,7 +168,7 @@
maybe we want to fix that
'''
- print ('WARNING: trying to get directory contents')
+ print 'WARNING: trying to get directory contents'
dcont = DirContents(self.path, self.batchno, self.batchsize, False)
result = dcont.get_contents()
if result != 'ok':
@@ -181,6 +178,6 @@
else:
dcont.get_batch_entryinfo()
output = dcont.show_batch()
+ if not self.quiet:
+ print output
return output
-
-
diff --git a/dataretention/retention/localfileaudit.py
b/dataretention/retention/localfileaudit.py
index c8ae28e..8872af9 100644
--- a/dataretention/retention/localfileaudit.py
+++ b/dataretention/retention/localfileaudit.py
@@ -1,5 +1,4 @@
import os
-import sys
import time
import socket
import stat
@@ -7,7 +6,6 @@
import salt.utils.yamlloader
import clouseau.retention.magic
-from clouseau.retention.rule import Rule
import clouseau.retention.config
from clouseau.retention.fileinfo import FileInfo
import clouseau.retention.fileutils
@@ -70,7 +68,7 @@
self.hostname = socket.getfqdn()
clouseau.retention.config.set_up_conf(self.confdir)
- self.cutoff = clouseau.retention.config.cf['cutoff']
+ self.cutoff = clouseau.retention.config.conf['cutoff']
self.local_rules_from_store_exported = None
self.perhost_ignores_from_file = None
@@ -215,7 +213,7 @@
return todo
def process_files_from_path(self, location, base, files, count,
- results, checklink=True):
+ results):
'''
arguments:
location: the location being checked
@@ -225,7 +223,7 @@
results: the result set
'''
- for fname, st in files:
+ for fname, fstat in files:
path = os.path.join(base, fname)
if self.file_is_wanted(path, location):
count += 1
@@ -237,7 +235,7 @@
return count
# for dirsizes option we don't collect or report files
if not self.dirsizes:
- results.append((path, st))
+ results.append((path, fstat))
return count
def walk_nolinks(self, top):
@@ -250,7 +248,7 @@
try:
names = os.listdir(top)
- except os.error, err:
+ except os.error:
return
dirs, files = [], []
@@ -272,8 +270,8 @@
for name in dirs:
new_path = os.path.join(top, name)
- for x in self.walk_nolinks(new_path):
- yield x
+ for result in self.walk_nolinks(new_path):
+ yield result
def process_one_dir(self, location, subdirpath, depth, results):
'''
@@ -320,15 +318,14 @@
if self.dirs_to_check is not None:
paths[:] = [p for p in paths
if
clouseau.retention.fileutils.dirtree_check(os.path.join(base, p),
-
self.dirs_to_check)]
+
self.dirs_to_check)]
paths[:] = [p for p in paths if
(not
clouseau.retention.fileutils.startswithpath(os.path.join(
base, p), expanded_dirs) and
not
clouseau.retention.fileutils.wildcard_matches(os.path.join(
base, p), wildcard_dirs, exact=False))]
count = self.process_files_from_path(location, base, files,
- count, temp_results,
- checklink=False)
+ count, temp_results)
if count > self.MAX_FILES:
return
@@ -336,7 +333,7 @@
def find_all_files(self):
results = []
- for location in clouseau.retention.config.cf[self.locations]:
+ for location in clouseau.retention.config.conf[self.locations]:
dirs_to_do = self.get_dirs_to_do(location)
if location.count(os.path.sep) >= self.depth + 1:
# do the run at least once
@@ -366,9 +363,9 @@
all_files = {}
files = self.find_all_files()
- for (f, st) in files:
- all_files[f] = FileInfo(f, self.magic, st)
- all_files[f].load_file_info(self.today, self.cutoff, open_files)
+ for (fname, fstat) in files:
+ all_files[fname] = FileInfo(fname, self.magic, fstat)
+ all_files[fname].load_file_info(self.today, self.cutoff,
open_files)
all_files_sorted = sorted(all_files, key=lambda f: all_files[f].path)
result = []
@@ -379,7 +376,7 @@
for fname in all_files_sorted:
if (not
clouseau.retention.fileutils.contains(all_files[fname].filetype,
-
clouseau.retention.config.cf['ignored_types'])
+
clouseau.retention.config.conf['ignored_types'])
and not all_files[fname].is_empty):
result.append(all_files[fname].format_output(
self.show_sample_content, False,
diff --git a/dataretention/retention/localhomeaudit.py
b/dataretention/retention/localhomeaudit.py
index a6ebc9c..ff1ba64 100644
--- a/dataretention/retention/localhomeaudit.py
+++ b/dataretention/retention/localhomeaudit.py
@@ -1,5 +1,3 @@
-import sys
-
from clouseau.retention.localfileaudit import LocalFilesAuditor
import clouseau.retention.ignores
diff --git a/dataretention/retention/locallogaudit.py
b/dataretention/retention/locallogaudit.py
index 774a2e6..fa99c3b 100644
--- a/dataretention/retention/locallogaudit.py
+++ b/dataretention/retention/locallogaudit.py
@@ -81,7 +81,7 @@
continue
if '*' in line:
log_group.extend(glob.glob(
-
os.path.join(clouseau.retention.config.cf['rotate_basedir'], line)))
+
os.path.join(clouseau.retention.config.conf['rotate_basedir'], line)))
else:
log_group.append(line)
elif state == 'want_rbracket':
@@ -106,7 +106,7 @@
return logs
def get_logrotate_defaults(self):
- contents = open(clouseau.retention.config.cf['rotate_mainconf']).read()
+ contents =
open(clouseau.retention.config.conf['rotate_mainconf']).read()
lines = contents.split('\n')
skip = False
freq = '-'
@@ -142,10 +142,10 @@
rotated_logs = {}
default_freq, default_keep = self.get_logrotate_defaults()
rotated_logs.update(self.parse_logrotate_contents(
- open(clouseau.retention.config.cf['rotate_mainconf']).read(),
+ open(clouseau.retention.config.conf['rotate_mainconf']).read(),
default_freq, default_keep))
- for fname in
os.listdir(clouseau.retention.config.cf['rotate_basedir']):
- pathname =
os.path.join(clouseau.retention.config.cf['rotate_basedir'], fname)
+ for fname in
os.listdir(clouseau.retention.config.conf['rotate_basedir']):
+ pathname =
os.path.join(clouseau.retention.config.conf['rotate_basedir'], fname)
if os.path.isfile(pathname):
rotated_logs.update(self.parse_logrotate_contents(
open(pathname).read(), default_freq, default_keep))
@@ -157,7 +157,7 @@
'''
# note that I also see my.cnf.s3 and we don't check those (yet)
output = ''
- for filename in clouseau.retention.config.cf['mysqlconf']:
+ for filename in clouseau.retention.config.conf['mysqlconf']:
found = False
try:
contents = open(filename).read()
@@ -210,7 +210,7 @@
if not fields[1].isdigit():
continue
found = True
- if int(fields[1]) >
clouseau.retention.config.cf['cutoff']/86400:
+ if int(fields[1]) >
clouseau.retention.config.conf['cutoff']/86400:
if output:
output = output + '\n'
output = output + ('WARNING: some mysql logs expired
after %s days in %s'
@@ -219,7 +219,7 @@
if output:
output = output + '\n'
output = output + 'WARNING: some mysql logs never expired in '
+ filename
- return(output)
+ return output
def do_local_audit(self):
'''
@@ -237,10 +237,10 @@
all_files = {}
files = self.find_all_files()
- for (f, st) in files:
- all_files[f] = LogInfo(f, self.magic, st)
- all_files[f].load_file_info(self.today, self.cutoff,
- open_files, rotated)
+ for (fname, stat) in files:
+ all_files[fname] = LogInfo(fname, self.magic, stat)
+ all_files[fname].load_file_info(self.today, self.cutoff,
+ open_files, rotated)
all_files_sorted = sorted(all_files,
key=lambda f: all_files[f].path)
@@ -256,7 +256,7 @@
for fname in all_files_sorted:
if clouseau.retention.fileutils.contains(all_files[fname].filetype,
-
clouseau.retention.config.cf['ignored_types']):
+
clouseau.retention.config.conf['ignored_types']):
continue
if (self.oldest_only and
diff --git a/dataretention/retention/localusercfgrabber.py
b/dataretention/retention/localusercfgrabber.py
index fb8fe78..7d851a0 100644
--- a/dataretention/retention/localusercfgrabber.py
+++ b/dataretention/retention/localusercfgrabber.py
@@ -25,5 +25,6 @@
local_ignores =
clouseau.retention.ignores.get_local_ignores(self.confdir, self.locations)
output = json.dumps(local_ignores)
- print output
+ if not quiet:
+ print output
return output
diff --git a/dataretention/retention/remoteexaminer.py
b/dataretention/retention/remoteexaminer.py
index 4ae22b9..03dc257 100644
--- a/dataretention/retention/remoteexaminer.py
+++ b/dataretention/retention/remoteexaminer.py
@@ -1,11 +1,8 @@
import json
-import logging
from salt.client import LocalClient
from clouseau.retention.utils import JsonHelper
from clouseau.retention.fileinfo import EntryInfo
-
-log = logging.getLogger(__name__)
class RemoteFileExaminer(object):
'''
@@ -45,7 +42,7 @@
def __init__(self, path, host, batchno=1, batchsize=300, timeout=20,
prettyprint=False):
self.path = path
- self.st = None
+ self.stat = None
self.host = host
self.timeout = timeout
self.batchno = batchno
diff --git a/dataretention/retention/remotefileauditor.py
b/dataretention/retention/remotefileauditor.py
index b5e074e..65c4d16 100644
--- a/dataretention/retention/remotefileauditor.py
+++ b/dataretention/retention/remotefileauditor.py
@@ -1,5 +1,4 @@
import os
-import sys
import time
import json
import socket
@@ -126,13 +125,14 @@
self.hostname = socket.getfqdn()
clouseau.retention.config.set_up_conf(confdir)
- self.cutoff = clouseau.retention.config.cf['cutoff']
+ self.cutoff = clouseau.retention.config.conf['cutoff']
client = LocalClientPlus()
hosts, expr_type = Runner.get_hosts_expr_type(self.hosts_expr)
self.expanded_hosts = client.cmd_expandminions(
hosts, "test.ping", expr_form=expr_type)
+ self.MAX_FILES = maxfiles
self.set_up_max_files(maxfiles)
self.cdb = RuleStore(self.store_filepath)
@@ -142,7 +142,7 @@
self.ignores = Ignores(self.confdir, self.cdb)
self.ignores.set_up_global_ignored(self.confdir, self.ignore_also)
if self.verbose:
-
self.ignores.show_ignored(clouseau.retention.config.cf[self.locations])
+
self.ignores.show_ignored(clouseau.retention.config.conf[self.locations])
self.perhost_ignores_from_file =
self.ignores.get_perhost_ignores_from_file()
@@ -151,6 +151,7 @@
self.magic.load()
self.summary = None
self.display_from_dict = FileInfo.display_from_dict
+ self.runner = None
def get_audit_args(self):
audit_args = [self.confdir,
@@ -198,7 +199,7 @@
def set_up_and_export_rule_store(self):
hosts = self.cdb.store_db_list_all_hosts()
destdir = os.path.join(os.path.dirname(self.store_filepath),
- "data_retention.d")
+ "data_retention.d")
if not os.path.isdir(destdir):
os.makedirs(destdir, 0755)
for host in hosts:
@@ -367,8 +368,8 @@
dirs_problem = list(set(dirs_problem))
for dirname in dirs_problem:
clouseau.retention.ruleutils.do_add_rule(self.cdb, dirname,
-
clouseau.retention.ruleutils.text_to_entrytype('dir'),
-
Status.text_to_status('problem'), host)
+
clouseau.retention.ruleutils.text_to_entrytype('dir'),
+
Status.text_to_status('problem'), host)
if dirs_skipped is not None:
dirs_skipped = list(set(dirs_skipped))
@@ -377,5 +378,5 @@
# problem report overrides 'too many to audit'
continue
clouseau.retention.ruleutils.do_add_rule(self.cdb, dirname,
-
clouseau.retention.ruleutils.text_to_entrytype('dir'),
-
Status.text_to_status('unreviewed'), host)
+
clouseau.retention.ruleutils.text_to_entrytype('dir'),
+
Status.text_to_status('unreviewed'), host)
diff --git a/dataretention/retention/remotehomeauditor.py
b/dataretention/retention/remotehomeauditor.py
index 9b2b1b2..ce44bc8 100644
--- a/dataretention/retention/remotehomeauditor.py
+++ b/dataretention/retention/remotehomeauditor.py
@@ -1,5 +1,4 @@
import os
-import sys
from retention.remotefileauditor import RemoteFilesAuditor
@@ -86,7 +85,7 @@
if not item['path'].startswith('/home/'):
return
- empty, home, user, rest = item['path'].split(os.path.sep, 3)
+ _, home, user, _ = item['path'].split(os.path.sep, 3)
home_dir = os.path.join(os.path.sep, home, user)
if home_dir not in self.homes_owners:
try:
@@ -97,5 +96,3 @@
if item['owner'] != self.homes_owners[home_dir]:
summary[dirname][group]['odd_owner'] += 1
-
-
diff --git a/dataretention/retention/remotelogauditor.py
b/dataretention/retention/remotelogauditor.py
index 03ab392..3407cf8 100644
--- a/dataretention/retention/remotelogauditor.py
+++ b/dataretention/retention/remotelogauditor.py
@@ -1,4 +1,3 @@
-import sys
import json
from clouseau.retention.fileinfo import LogInfo
diff --git a/dataretention/retention/remoteusercfgrabber.py
b/dataretention/retention/remoteusercfgrabber.py
index 121f928..296f463 100644
--- a/dataretention/retention/remoteusercfgrabber.py
+++ b/dataretention/retention/remoteusercfgrabber.py
@@ -36,14 +36,14 @@
timeout=self.timeout)
if self.host in result:
- input = result[self.host]
+ input_text = result[self.host]
try:
local_ignores = json.loads(
- input, object_hook=JsonHelper.decode_dict)
+ input_text, object_hook=JsonHelper.decode_dict)
except:
print "WARNING: failed to get local ignores on host",
print self.host,
- print "got this:", input
+ print "got this:", input_text
local_ignores = {}
if not quiet:
diff --git a/dataretention/retention/retentionaudit.py
b/dataretention/retention/retentionaudit.py
index 2405c5a..f3bc1d5 100644
--- a/dataretention/retention/retentionaudit.py
+++ b/dataretention/retention/retentionaudit.py
@@ -1,7 +1,4 @@
# salt module
-import logging
-
-log = logging.getLogger(__name__)
from clouseau.retention.localfileaudit import LocalFilesAuditor
from clouseau.retention.locallogaudit import LocalLogsAuditor
@@ -9,7 +6,7 @@
from clouseau.retention.localexaminer import LocalFileExaminer,
LocalDirExaminer
from clouseau.retention.localusercfgrabber import LocalUserCfGrabber
-def fileaudit_host(confdir,show_content, dirsizes, depth,
+def fileaudit_host(confdir, show_content, dirsizes, depth,
to_check, ignore_also, timeout,
maxfiles):
fauditor = LocalFilesAuditor('root', confdir, show_content,
diff --git a/dataretention/retention/rule.py b/dataretention/retention/rule.py
index 840a204..5a59005 100644
--- a/dataretention/retention/rule.py
+++ b/dataretention/retention/rule.py
@@ -1,15 +1,12 @@
import os
-import sys
import re
-import json
-import traceback
import sqlite3
from clouseau.retention.saltclientplus import LocalClientPlus
from clouseau.retention.status import Status
def to_unicode(param):
- '''
- convert a parameter to unicode if it is not already
+ '''
+ convert a parameter to unicode if it is not already
'''
newparam = param
if not isinstance(param, unicode):
@@ -22,8 +19,8 @@
return newparam
def from_unicode(param):
- '''
- convert a parameter from unicode back to bytes it is not already
+ '''
+ convert a parameter from unicode back to bytes it is not already
'''
newparam = param
if isinstance(param, unicode):
@@ -365,4 +362,3 @@
hosts.append(table[len(self.TABLE + "_"):].
replace('__', '-').replace('_', '.'))
return hosts
-
diff --git a/dataretention/retention/ruleutils.py
b/dataretention/retention/ruleutils.py
index a2e6eb6..88ca87b 100644
--- a/dataretention/retention/ruleutils.py
+++ b/dataretention/retention/ruleutils.py
@@ -1,6 +1,5 @@
import os
import sys
-import json
import traceback
from clouseau.retention.status import Status
import clouseau.retention.rule
@@ -78,7 +77,7 @@
import_rule_list(
cdb, yaml_contents[status],
Status.status_cf[status][0], host)
-
+
def do_remove_rule(cdb, path, host):
cdb.store_db_delete({'basedir': os.path.dirname(path),
'name': os.path.basename(path)},
diff --git a/dataretention/retention/runner.py
b/dataretention/retention/runner.py
index c80bb05..6dac48f 100644
--- a/dataretention/retention/runner.py
+++ b/dataretention/retention/runner.py
@@ -51,9 +51,9 @@
# fixme instead of this we call the right salt module based on the
# audit type and with the self.auditmodule_args which is a list
- hostbatches = [self.expanded_hosts[i: i +
clouseau.retention.config.cf['batchsize']]
+ hostbatches = [self.expanded_hosts[i: i +
clouseau.retention.config.conf['batchsize']]
for i in range(0, len(self.expanded_hosts),
-
clouseau.retention.config.cf['batchsize'])]
+
clouseau.retention.config.conf['batchsize'])]
result = {}
for hosts in hostbatches:
@@ -62,7 +62,7 @@
sys.stderr.write(','.join(hosts) + '\n')
path = os.path.join(os.path.dirname(self.store_filepath),
- "data_retention.d")
+ "data_retention.d")
contents = clouseau.retention.ignores.prep_good_rules_tosend(path,
hosts)
if contents:
new_result = client.cmd_full_return(hosts, 'cp.recv',
[contents, os.path.join(self.confdir, 'fromstore')],
--
To view, visit https://gerrit.wikimedia.org/r/233470
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0f577afbdf75773cd0ec288998ecdb595f586ffe
Gerrit-PatchSet: 2
Gerrit-Project: operations/software
Gerrit-Branch: master
Gerrit-Owner: ArielGlenn <[email protected]>
Gerrit-Reviewer: ArielGlenn <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits