Cleanup other misc pylint warnings
This commit is contained in:
parent
6d47689a33
commit
0094fab0d4
1
setup.py
1
setup.py
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from distutils.core import setup
|
||||
from glob import glob
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
import glob
|
||||
import optparse
|
||||
import os
|
||||
import shutil
|
||||
import sys
|
||||
import rpm
|
||||
|
||||
@ -46,8 +45,8 @@ class ImageMinimizer:
|
||||
def add_directory(self, files, dirname):
|
||||
self.visited.add(dirname)
|
||||
for root, dirs, items in os.walk(dirname):
|
||||
for dir in dirs:
|
||||
self.visited.add(os.path.join(root, dir))
|
||||
for d in dirs:
|
||||
self.visited.add(os.path.join(root, d))
|
||||
for name in items:
|
||||
files.add(os.path.join(root, name))
|
||||
|
||||
@ -124,14 +123,14 @@ class ImageMinimizer:
|
||||
os.remove(tag)
|
||||
|
||||
#remove all empty directory. Every 8k counts!
|
||||
for dir in sorted(self.visited, reverse=True):
|
||||
if len(os.listdir(dir)) == 0:
|
||||
for d in sorted(self.visited, reverse=True):
|
||||
if len(os.listdir(d)) == 0:
|
||||
if self.dryrun:
|
||||
print 'rm -rf ' + dir
|
||||
print 'rm -rf ' + d
|
||||
else:
|
||||
if self.verbose:
|
||||
print 'rm -rf ' + dir
|
||||
os.rmdir(dir)
|
||||
print 'rm -rf ' + d
|
||||
os.rmdir(d)
|
||||
|
||||
def remove_rpm(self):
|
||||
|
||||
@ -182,7 +181,7 @@ def parse_options():
|
||||
return (options, args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def main():
|
||||
try:
|
||||
(options, args) = parse_options()
|
||||
filename = args[0]
|
||||
@ -192,7 +191,10 @@ if __name__ == "__main__":
|
||||
except SystemExit, e:
|
||||
sys.exit(e.code)
|
||||
except KeyboardInterrupt, e:
|
||||
print >> sys.stderr, _("Aborted at user request")
|
||||
print >> sys.stderr, "Aborted at user request"
|
||||
except Exception, e:
|
||||
print e
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -79,7 +79,7 @@ class LogRequestHandler(SocketServer.BaseRequestHandler):
|
||||
"""
|
||||
def setup(self):
|
||||
if self.server.log_path:
|
||||
self.fp = open(self.server.log_path, "w")
|
||||
self.fp = open(self.server.log_path, "w") # pylint: disable=attribute-defined-outside-init
|
||||
else:
|
||||
print "no log_path specified"
|
||||
self.request.settimeout(10)
|
||||
@ -350,8 +350,8 @@ def is_image_mounted(disk_img):
|
||||
Return True if the disk_img is mounted
|
||||
"""
|
||||
with open("/proc/mounts") as mounts:
|
||||
for mount in mounts:
|
||||
fields = mount.split()
|
||||
for mnt in mounts:
|
||||
fields = mnt.split()
|
||||
if len(fields) > 2 and fields[1] == disk_img:
|
||||
return True
|
||||
return False
|
||||
@ -430,7 +430,7 @@ def make_fsimage(diskimage, fsimage, img_size=None, label="Anaconda"):
|
||||
if not img_mount or not img_mount.mount_dir:
|
||||
return None
|
||||
|
||||
log.info("Creating fsimage %s (%s)", (fsimage, img_size or "minimized"))
|
||||
log.info("Creating fsimage %s (%s)", fsimage, img_size or "minimized")
|
||||
if img_size:
|
||||
# convert to Bytes
|
||||
img_size *= 1024**2
|
||||
@ -503,7 +503,7 @@ def make_livecd(opts, mount_dir, work_dir):
|
||||
isolabel = opts.volid or "{0.name} {0.version} {1.basearch}".format(product, arch)
|
||||
if len(isolabel) > 32:
|
||||
isolabel = isolabel[:32]
|
||||
log.warn("Truncating isolabel to 32 chars: %s" % (isolabel,))
|
||||
log.warn("Truncating isolabel to 32 chars: %s", isolabel)
|
||||
|
||||
tb = TreeBuilder(product=product, arch=arch, domacboot=opts.domacboot,
|
||||
inroot=mount_dir, outroot=work_dir,
|
||||
@ -774,7 +774,7 @@ def setup_logging(opts):
|
||||
program_log.addHandler(fh)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
parser = argparse.ArgumentParser( description="Create Live Install Media",
|
||||
fromfile_prefix_chars="@" )
|
||||
|
||||
@ -1027,7 +1027,7 @@ if __name__ == '__main__':
|
||||
try:
|
||||
disk_img = make_image(opts, ks)
|
||||
except InstallError as e:
|
||||
log.error("ERROR: Image creation failed: %s" % (e))
|
||||
log.error("ERROR: Image creation failed: %s", e)
|
||||
sys.exit(1)
|
||||
|
||||
if not opts.image_only:
|
||||
@ -1082,3 +1082,5 @@ if __name__ == '__main__':
|
||||
|
||||
sys.exit( 0 )
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -34,6 +34,7 @@ import os
|
||||
import tempfile
|
||||
from optparse import OptionParser, OptionGroup
|
||||
import ConfigParser
|
||||
import shutil
|
||||
|
||||
import yum
|
||||
# This is a bit of a hack to short circuit yum's internal logging
|
||||
@ -195,8 +196,8 @@ def main(args):
|
||||
remove_temp=True)
|
||||
|
||||
|
||||
def get_yum_base_object(installroot, repositories, mirrorlists=[],
|
||||
tempdir="/var/tmp", proxy=None, excludepkgs=[]):
|
||||
def get_yum_base_object(installroot, repositories, mirrorlists=None,
|
||||
tempdir="/var/tmp", proxy=None, excludepkgs=None):
|
||||
|
||||
def sanitize_repo(repo):
|
||||
if repo.startswith("/"):
|
||||
@ -207,6 +208,9 @@ def get_yum_base_object(installroot, repositories, mirrorlists=[],
|
||||
else:
|
||||
return None
|
||||
|
||||
mirrorlists = mirrorlists or []
|
||||
excludepkgs = excludepkgs or []
|
||||
|
||||
# sanitize the repositories
|
||||
repositories = map(sanitize_repo, repositories)
|
||||
mirrorlists = map(sanitize_repo, mirrorlists)
|
||||
|
@ -113,7 +113,7 @@ def mkefidisk(efiboot, outfile):
|
||||
outfile.write(infile.read())
|
||||
dm_detach(dmdev+"p1")
|
||||
|
||||
if __name__ == '__main__':
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Make an EFI boot image from the given directory.")
|
||||
parser.add_argument("--debug", action="store_const", const=logging.DEBUG,
|
||||
dest="loglevel", default=log.getEffectiveLevel(),
|
||||
@ -157,3 +157,6 @@ if __name__ == '__main__':
|
||||
efiboot = tempfile.NamedTemporaryFile(prefix="mkefiboot.").name
|
||||
shutil.move(opt.outfile, efiboot)
|
||||
mkefidisk(efiboot, opt.outfile)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
@ -21,11 +21,11 @@ def main(args):
|
||||
|
||||
# parse sourcedir and targetdir
|
||||
sourcetree, targettree = {}, {}
|
||||
for tree, dir in [[sourcetree, sourcedir], [targettree, targetdir]]:
|
||||
for root, dnames, fnames in os.walk(dir):
|
||||
for tree, d in [[sourcetree, sourcedir], [targettree, targetdir]]:
|
||||
for root, _dnames, fnames in os.walk(d):
|
||||
for fname in fnames:
|
||||
fpath = os.path.join(root, fname)
|
||||
rpath = fpath.replace(dir, "", 1)
|
||||
rpath = fpath.replace(d, "", 1)
|
||||
tree[rpath] = fpath
|
||||
|
||||
# set up magic
|
||||
@ -116,7 +116,7 @@ def main(args):
|
||||
[(rpath, sizeinbytes, islink)]
|
||||
|
||||
# sort by size
|
||||
for pkg, size in sorted(sizedict.items(), key=operator.itemgetter(1),
|
||||
for pkg, _size in sorted(sizedict.items(), key=operator.itemgetter(1),
|
||||
reverse=True):
|
||||
|
||||
for item in sorted(pkgdict[pkg]):
|
||||
|
@ -37,11 +37,11 @@ def get_args(template):
|
||||
argspec = inspect.getargspec(template.module.render_body)
|
||||
return set(argspec.args[1:]) # skip "context"
|
||||
|
||||
def readtemplate(templatefile):
|
||||
def readtemplate(filename):
|
||||
parser = LoraxTemplate(directories=['.'])
|
||||
from mako.lookup import TemplateLookup
|
||||
lookup = TemplateLookup(directories=parser.directories)
|
||||
return lookup.get_template(templatefile)
|
||||
return lookup.get_template(filename)
|
||||
|
||||
if __name__ == '__main__':
|
||||
# check args
|
||||
|
Loading…
Reference in New Issue
Block a user