Change in vdsm[master]: More PEP8 fixes
smizrahi at redhat.com
smizrahi at redhat.com
Fri Nov 30 23:09:38 UTC 2012
Saggi Mizrahi has uploaded a new change for review.
Change subject: More PEP8 fixes
......................................................................
More PEP8 fixes
Change-Id: I7b4dac13951b63263e59bb962cdc69496d277b70
Signed-off-by: Saggi Mizrahi <smizrahi at redhat.com>
---
M tests/betterPopenTests.py
M vdsm/storage/fileUtils.py
M vdsm/storage/mount.py
3 files changed, 30 insertions(+), 26 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/04/9604/1
diff --git a/tests/betterPopenTests.py b/tests/betterPopenTests.py
index 1459ac2..a3e3232 100644
--- a/tests/betterPopenTests.py
+++ b/tests/betterPopenTests.py
@@ -37,7 +37,7 @@
p = BetterPopen([EXT_ECHO, "-n", data])
p.wait()
self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
+ "Process failed: %s" % os.strerror(p.returncode))
self.assertEquals(p.stdout.read(), data)
def testCat(self):
@@ -45,16 +45,16 @@
p = BetterPopen(["cat", path])
p.wait()
self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
+ "Process failed: %s" % os.strerror(p.returncode))
with open(path, "r") as f:
self.assertEquals(p.stdout.read(), f.read())
def _subTest(self, name, params, *args, **kwargs):
p = BetterPopen(["python", __file__, name] + params,
- *args, **kwargs)
+ *args, **kwargs)
p.wait()
self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
+ "Process failed: %s" % os.strerror(p.returncode))
self.assertEquals(p.stdout.read().strip(), "True")
def testCloseFDs(self):
@@ -82,10 +82,10 @@
def testCwd(self):
cwd = "/proc"
p = BetterPopen(["python", "-c", "import os; print os.getcwd()"],
- cwd=cwd)
+ cwd=cwd)
p.wait()
self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
+ "Process failed: %s" % os.strerror(p.returncode))
self.assertEquals(p.stdout.read().strip(), cwd)
def testRunNonExecutable(self):
@@ -93,7 +93,7 @@
def testBadCwd(self):
self.assertRaises(OSError, BetterPopen, ["echo", "hello"],
- cwd="/~~~~~dasdas~~~~")
+ cwd="/~~~~~dasdas~~~~")
def testUnicodeArg(self):
data = u'hello'
@@ -102,7 +102,7 @@
p = BetterPopen(cmd)
p.wait()
p2 = subprocess.Popen(cmd, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p2.wait()
self.assertEquals(p.stdout.read(), p2.stdout.read())
@@ -118,7 +118,7 @@
p = BetterPopen(cmd)
p.wait()
p2 = subprocess.Popen(cmd, stdin=subprocess.PIPE,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p2.wait()
self.assertEquals(p.stdout.read(), p2.stdout.read())
@@ -130,7 +130,7 @@
p.stdin.close()
p.wait()
self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
+ "Process failed: %s" % os.strerror(p.returncode))
self.assertEquals(p.stdout.read(), data)
@@ -147,7 +147,7 @@
p.stdin.close()
p.wait()
self.assertTrue(p.returncode == 0,
- "Process failed: %s" % os.strerror(p.returncode))
+ "Process failed: %s" % os.strerror(p.returncode))
self.assertEquals(p.stdout.read(), data)
diff --git a/vdsm/storage/fileUtils.py b/vdsm/storage/fileUtils.py
index 13a8cfa..78c498a 100644
--- a/vdsm/storage/fileUtils.py
+++ b/vdsm/storage/fileUtils.py
@@ -31,11 +31,12 @@
import ctypes
from contextlib import contextmanager
import subprocess
-
import shutil
-from vdsm import constants
import logging
import errno
+
+from vdsm import constants
+
libc = ctypes.CDLL("libc.so.6", use_errno=True)
log = logging.getLogger('fileUtils')
@@ -184,10 +185,13 @@
log.warning("Dir %s already exists", dirPath)
if mode is not None:
statinfo = os.stat(dirPath)
- if statinfo[stat.ST_MODE] != mode:
+ curMode = statinfo[stat.ST_MODE]
+ if curMode != mode:
raise OSError(errno.EPERM,
- "Existing %s permissions %s are not as requested %s" %
- (dirPath, oct(statinfo[stat.ST_MODE]), oct(mode)))
+ ("Existing %s permissions %s are not as "
+ "requested %s") % (dirPath,
+ oct(curMode),
+ oct(mode)))
def resolveUid(user):
@@ -219,7 +223,7 @@
currentGid = stat.st_gid
if ((uid == currentUid or user == -1) and
- (gid == currentGid or group == -1)):
+ (gid == currentGid or group == -1)):
return True
os.chown(path, uid, gid)
diff --git a/vdsm/storage/mount.py b/vdsm/storage/mount.py
index 94cfae0..d0a0b58 100644
--- a/vdsm/storage/mount.py
+++ b/vdsm/storage/mount.py
@@ -34,14 +34,14 @@
VFS_EXT3 = "ext3"
MountRecord = namedtuple("MountRecord", "fs_spec fs_file fs_vfstype "
- "fs_mntops fs_freq fs_passno")
+ "fs_mntops fs_freq fs_passno")
_RE_ESCAPE = re.compile(r"\\0\d\d")
def _parseFstabLine(line):
(fs_spec, fs_file, fs_vfstype, fs_mntops,
- fs_freq, fs_passno) = line.split()[:6]
+ fs_freq, fs_passno) = line.split()[:6]
fs_mntops = fs_mntops.split(",")
fs_freq = int(fs_freq)
fs_passno = int(fs_passno)
@@ -50,7 +50,7 @@
fs_mntops = [_parseFstabPath(item) for item in fs_mntops]
return MountRecord(fs_spec, fs_file, fs_vfstype, fs_mntops,
- fs_freq, fs_passno)
+ fs_freq, fs_passno)
def _iterateMtab():
@@ -118,7 +118,7 @@
continue
yield MountRecord(realSpec, rec.fs_file, rec.fs_vfstype,
- rec.fs_mntops, rec.fs_freq, rec.fs_passno)
+ rec.fs_mntops, rec.fs_freq, rec.fs_passno)
def iterMounts():
@@ -195,7 +195,7 @@
if not p.wait(timeout):
p.kill()
raise OSError(errno.ETIMEDOUT,
- "%s operation timed out" % os.path.basename(cmd[0]))
+ "%s operation timed out" % os.path.basename(cmd[0]))
out, err = p.communicate()
rc = p.returncode
@@ -232,9 +232,9 @@
return record
raise OSError(errno.ENOENT,
- "Mount of `%s` at `%s` does not exist" %
- (self.fs_spec, self.fs_file))
+ "Mount of `%s` at `%s` does not exist" %
+ (self.fs_spec, self.fs_file))
def __repr__(self):
- return "<Mount fs_spec='%s' fs_file='%s'>" % \
- (self.fs_spec, self.fs_file)
+ return ("<Mount fs_spec='%s' fs_file='%s'>" %
+ (self.fs_spec, self.fs_file))
--
To view, visit http://gerrit.ovirt.org/9604
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7b4dac13951b63263e59bb962cdc69496d277b70
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Saggi Mizrahi <smizrahi at redhat.com>
More information about the vdsm-patches
mailing list