Fix some PEP8 errors in util.py
Signed-off-by: Qixiang Wan <qwan@redhat.com>
This commit is contained in:
parent
0f508e2228
commit
0ee2189d9c
@ -37,7 +37,6 @@ from .wrappers import kojiwrapper
|
|||||||
def _doRunCommand(command, logger, rundir='/tmp', output=subprocess.PIPE, error=subprocess.PIPE, env=None):
|
def _doRunCommand(command, logger, rundir='/tmp', output=subprocess.PIPE, error=subprocess.PIPE, env=None):
|
||||||
"""Run a command and log the output. Error out if we get something on stderr"""
|
"""Run a command and log the output. Error out if we get something on stderr"""
|
||||||
|
|
||||||
|
|
||||||
logger.info("Running %s" % subprocess.list2cmdline(command))
|
logger.info("Running %s" % subprocess.list2cmdline(command))
|
||||||
|
|
||||||
p1 = subprocess.Popen(command, cwd=rundir, stdout=output, stderr=error, universal_newlines=True, env=env,
|
p1 = subprocess.Popen(command, cwd=rundir, stdout=output, stderr=error, universal_newlines=True, env=env,
|
||||||
@ -50,7 +49,8 @@ def _doRunCommand(command, logger, rundir='/tmp', output=subprocess.PIPE, error=
|
|||||||
if p1.returncode != 0:
|
if p1.returncode != 0:
|
||||||
logger.error("Got an error from %s" % command[0])
|
logger.error("Got an error from %s" % command[0])
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
raise OSError, "Got an error (%d) from %s: %s" % (p1.returncode, command[0], err)
|
raise OSError("Got an error (%d) from %s: %s" % (p1.returncode, command[0], err))
|
||||||
|
|
||||||
|
|
||||||
def _link(local, target, logger, force=False):
|
def _link(local, target, logger, force=False):
|
||||||
"""Simple function to link or copy a package, removing target optionally."""
|
"""Simple function to link or copy a package, removing target optionally."""
|
||||||
@ -58,7 +58,7 @@ def _link(local, target, logger, force=False):
|
|||||||
if os.path.exists(target) and force:
|
if os.path.exists(target) and force:
|
||||||
os.remove(target)
|
os.remove(target)
|
||||||
|
|
||||||
#check for broken links
|
# check for broken links
|
||||||
if force and os.path.islink(target):
|
if force and os.path.islink(target):
|
||||||
if not os.path.exists(os.readlink(target)):
|
if not os.path.exists(os.readlink(target)):
|
||||||
os.remove(target)
|
os.remove(target)
|
||||||
@ -68,11 +68,12 @@ def _link(local, target, logger, force=False):
|
|||||||
except OSError, e:
|
except OSError, e:
|
||||||
if e.errno != 18: # EXDEV
|
if e.errno != 18: # EXDEV
|
||||||
logger.error('Got an error linking from cache: %s' % e)
|
logger.error('Got an error linking from cache: %s' % e)
|
||||||
raise OSError, e
|
raise OSError(e)
|
||||||
|
|
||||||
# Can't hardlink cross file systems
|
# Can't hardlink cross file systems
|
||||||
shutil.copy2(local, target)
|
shutil.copy2(local, target)
|
||||||
|
|
||||||
|
|
||||||
def _ensuredir(target, logger, force=False, clean=False):
|
def _ensuredir(target, logger, force=False, clean=False):
|
||||||
"""Ensure that a directory exists, if it already exists, only continue
|
"""Ensure that a directory exists, if it already exists, only continue
|
||||||
if force is set."""
|
if force is set."""
|
||||||
@ -110,6 +111,7 @@ def _ensuredir(target, logger, force=False, clean=False):
|
|||||||
sys.stderr(message)
|
sys.stderr(message)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def _doCheckSum(path, hash, logger):
|
def _doCheckSum(path, hash, logger):
|
||||||
"""Generate a checksum hash from a provided path.
|
"""Generate a checksum hash from a provided path.
|
||||||
Return a string of type:hash"""
|
Return a string of type:hash"""
|
||||||
|
Loading…
Reference in New Issue
Block a user