On Tue, Dec 01, 2009 at 11:28:50AM +0100, Iustin Pop wrote:
> On Tue, Dec 01, 2009 at 10:21:55AM +0000, Michael Hanselmann wrote:
> > 2009/12/1 Iustin Pop <[email protected]>:
> > > Interdiff:
> > > diff --git a/lib/bdev.py b/lib/bdev.py
> > > index 09b5b14..eda59ed 100644
> > > --- a/lib/bdev.py
> > > +++ b/lib/bdev.py
> > > -    f = open(path, "r")
> > > -    try:
> > > -      f.read(128*1024)
> > > -    finally:
> > > -      f.close()
> > > +    utils.ReadFile(path, size=128*1024)
> > 
> > Please use spaces around operators.
> 
> but ", size=128 * 1024)" looks worse. Grrr… :)

What I mean is:
diff --git a/lib/bdev.py b/lib/bdev.py
index 0b6253c..2475303 100644
--- a/lib/bdev.py
+++ b/lib/bdev.py
@@ -34,6 +34,9 @@ from ganeti import constants
 from ganeti import objects
 
 
+_DEVICE_READ_SIZE = 128 * 1024
+
+
 def _IgnoreError(fn, *args, **kwargs):
   """Executes the given function, ignoring BlockDeviceErrors.
 
@@ -73,7 +76,7 @@ def _CanReadDevice(path):
 
   """
   try:
-    utils.ReadFile(path, size=128 * 1024)
+    utils.ReadFile(path, size=_DEVICE_READ_SIZE)
     return True
   except EnvironmentError, err:
     logging.warning("Can't read from device %s", path, exc_info=True)

iustin

Reply via email to