Martin Sivák has uploaded a new change for review.

Change subject: Fix PEP8 issues introduced by update to pep8 1.6.2
......................................................................

Fix PEP8 issues introduced by update to pep8 1.6.2

Change-Id: I6bb1256fca8fe50259b95531fa14eb33da68c19d
Signed-off-by: Martin Sivak <[email protected]>
---
M build/python.inc
M ovirt_hosted_engine_ha/agent/state_data.py
M ovirt_hosted_engine_ha/agent/state_data_test.py
M ovirt_hosted_engine_ha/agent/state_machine.py
M ovirt_hosted_engine_ha/agent/states.py
M ovirt_hosted_engine_ha/broker/notifications.py
M ovirt_hosted_engine_ha/broker/storage_broker.py
M ovirt_hosted_engine_ha/client/client.py
M ovirt_hosted_engine_ha/lib/fsm/__init__.py
M ovirt_hosted_engine_ha/lib/fsm/machine.py
M ovirt_hosted_engine_ha/lib/monotonic.py
M ovirt_hosted_engine_ha/lib/storage_backends.py
M ovirt_hosted_engine_ha/lib/storage_backends_test.py
13 files changed, 37 insertions(+), 37 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-hosted-engine-ha 
refs/changes/96/38496/1

diff --git a/build/python.inc b/build/python.inc
index 72d5db1..04f3343 100644
--- a/build/python.inc
+++ b/build/python.inc
@@ -25,7 +25,7 @@
                $(PYFLAKES) $(PYTHON_SYNTAX_CHECK_FILES); \
        fi
        if [ -n "$(PEP8)" ]; then \
-               $(PEP8) $(PYTHON_SYNTAX_CHECK_FILES); \
+               $(PEP8) --ignore=W503,E402 $(PYTHON_SYNTAX_CHECK_FILES); \
        fi
 endif
 
diff --git a/ovirt_hosted_engine_ha/agent/state_data.py 
b/ovirt_hosted_engine_ha/agent/state_data.py
index 2b265d4..223c375 100644
--- a/ovirt_hosted_engine_ha/agent/state_data.py
+++ b/ovirt_hosted_engine_ha/agent/state_data.py
@@ -1,6 +1,6 @@
-__author__ = 'msivak'
-
 import collections
+
+__author__ = 'msivak'
 
 # Prepare the state data type as namedtuple to prevent
 # accidental modification to it
@@ -105,7 +105,7 @@
             seg_time = last_time - cur_time
             seg_area = (seg_time *
                         (last_load + cur_load) / 2.0)
-            return area+seg_area, time+seg_time, cur_load, cur_time
+            return area + seg_area, time + seg_time, cur_load, cur_time
         else:
             return area, time, cur_load, cur_time
 
diff --git a/ovirt_hosted_engine_ha/agent/state_data_test.py 
b/ovirt_hosted_engine_ha/agent/state_data_test.py
index 3b03355..4c28265 100644
--- a/ovirt_hosted_engine_ha/agent/state_data_test.py
+++ b/ovirt_hosted_engine_ha/agent/state_data_test.py
@@ -1,7 +1,8 @@
-__author__ = 'msivak'
 import state_data
 import unittest
 
+__author__ = 'msivak'
+
 
 class TestCases(unittest.TestCase):
     @staticmethod
diff --git a/ovirt_hosted_engine_ha/agent/state_machine.py 
b/ovirt_hosted_engine_ha/agent/state_machine.py
index 94fd3ab..d520985 100644
--- a/ovirt_hosted_engine_ha/agent/state_machine.py
+++ b/ovirt_hosted_engine_ha/agent/state_machine.py
@@ -1,5 +1,3 @@
-__author__ = 'msivak'
-
 from ..lib.fsm import BaseFSM, BaseState
 from ..lib import util
 from ..lib.util import engine_status_score
@@ -9,6 +7,8 @@
 from state_data import HostedEngineData, StatsData
 from ..lib import monotonic
 
+__author__ = 'msivak'
+
 
 class StartState(BaseState):
     """
diff --git a/ovirt_hosted_engine_ha/agent/states.py 
b/ovirt_hosted_engine_ha/agent/states.py
index 047c19f..544f778 100644
--- a/ovirt_hosted_engine_ha/agent/states.py
+++ b/ovirt_hosted_engine_ha/agent/states.py
@@ -1,5 +1,3 @@
-__author__ = 'msivak'
-
 from ..lib.fsm import BaseState, BaseFSM
 from ..lib import log_filter
 from ..lib import engine
@@ -9,6 +7,8 @@
 from .state_data import time as dtime, load_factor
 import time
 
+__author__ = 'msivak'
+
 
 class EngineState(BaseState):
     """
diff --git a/ovirt_hosted_engine_ha/broker/notifications.py 
b/ovirt_hosted_engine_ha/broker/notifications.py
index c9ff9f7..6e7717c 100644
--- a/ovirt_hosted_engine_ha/broker/notifications.py
+++ b/ovirt_hosted_engine_ha/broker/notifications.py
@@ -1,7 +1,5 @@
 import socket
 
-__author__ = 'msivak'
-
 import smtplib
 import ConfigParser
 import re
@@ -9,6 +7,8 @@
 import logging
 
 from . import constants
+
+__author__ = 'msivak'
 
 # regular expression used to split the email addresses
 EMAIL_SPLIT_RE = re.compile(' *, *')
@@ -57,7 +57,7 @@
         return False
 
     try:
-        template_path = os.path.join(constants.NOTIFY_TEMPLATES, type+".txt")
+        template_path = os.path.join(constants.NOTIFY_TEMPLATES, type + ".txt")
         template = open(template_path).read()
     except (OSError, IOError) as e:
         logging.getLogger("%s.Notifications" % __name__).exception(e)
diff --git a/ovirt_hosted_engine_ha/broker/storage_broker.py 
b/ovirt_hosted_engine_ha/broker/storage_broker.py
index c766dd9..3c1b07a 100644
--- a/ovirt_hosted_engine_ha/broker/storage_broker.py
+++ b/ovirt_hosted_engine_ha/broker/storage_broker.py
@@ -131,7 +131,7 @@
                             path, exc_info=True)
             raise RequestError("failed to read metadata: {0}".format(str(e)))
 
-        return dict(((i / bs, data[i:i+bs])
+        return dict(((i / bs, data[i:i + bs])
                      for i in range(0, len(data), bs)
                      if data[i] != '\0'))
 
diff --git a/ovirt_hosted_engine_ha/client/client.py 
b/ovirt_hosted_engine_ha/client/client.py
index 7ef49fa..9b54459 100644
--- a/ovirt_hosted_engine_ha/client/client.py
+++ b/ovirt_hosted_engine_ha/client/client.py
@@ -74,7 +74,7 @@
     def _check_liveness_metadata(self, md, broker):
         with broker.connection():
             self._configure_broker_conn(broker)
-            service = constants.SERVICE_TYPE+agent_constants.MD_EXTENSION
+            service = constants.SERVICE_TYPE + agent_constants.MD_EXTENSION
             md["live-data"] = broker.is_host_alive(service, md["host-id"])
             self._log.debug("Is host '{0}' alive? -> '{1}'"
                             .format(md["host-id"], md["live-data"]))
@@ -98,7 +98,7 @@
         broker = brokerlink.BrokerLink()
         with broker.connection():
             self._configure_broker_conn(broker)
-            service = constants.SERVICE_TYPE+agent_constants.MD_EXTENSION
+            service = constants.SERVICE_TYPE + agent_constants.MD_EXTENSION
             stats = broker.get_stats_from_storage(service)
 
         stats = self._parse_stats(stats, mode)
@@ -214,7 +214,7 @@
             md_dict[flag] = put_val
             block = metadata.create_global_metadata_from_dict(md_dict)
             broker.put_stats_on_storage(
-                constants.SERVICE_TYPE+agent_constants.MD_EXTENSION,
+                constants.SERVICE_TYPE + agent_constants.MD_EXTENSION,
                 0,
                 block)
 
diff --git a/ovirt_hosted_engine_ha/lib/fsm/__init__.py 
b/ovirt_hosted_engine_ha/lib/fsm/__init__.py
index e64d265..f187869 100644
--- a/ovirt_hosted_engine_ha/lib/fsm/__init__.py
+++ b/ovirt_hosted_engine_ha/lib/fsm/__init__.py
@@ -1,4 +1,4 @@
+from machine import BaseFSM, BaseState
+
 __author__ = 'msivak'
 __all__ = ["BaseFSM", "BaseState"]
-
-from machine import BaseFSM, BaseState
diff --git a/ovirt_hosted_engine_ha/lib/fsm/machine.py 
b/ovirt_hosted_engine_ha/lib/fsm/machine.py
index 21eb5aa..03e3bcd 100644
--- a/ovirt_hosted_engine_ha/lib/fsm/machine.py
+++ b/ovirt_hosted_engine_ha/lib/fsm/machine.py
@@ -1,11 +1,11 @@
-__author__ = 'msivak'
-__all__ = ["BaseFSM", "BaseState"]
-
 import logging
 import abc
 from abc import abstractmethod
 import copy
 
+__author__ = 'msivak'
+__all__ = ["BaseFSM", "BaseState"]
+
 
 class FSMLoggerAdapter(logging.LoggerAdapter):
     """This logger adapter adds the fsm and state fields to the
diff --git a/ovirt_hosted_engine_ha/lib/monotonic.py 
b/ovirt_hosted_engine_ha/lib/monotonic.py
index 1867eca..2ccd7df 100644
--- a/ovirt_hosted_engine_ha/lib/monotonic.py
+++ b/ovirt_hosted_engine_ha/lib/monotonic.py
@@ -2,13 +2,12 @@
 This module provides a monotonic time. It's a time which doesn't depend on the
 system time which means is not influenced by time shifts.
 """
-
-__all__ = ["time"]
-
 import ctypes
 import os
 import logging
 
+__all__ = ["time"]
+
 logger = logging.getLogger(__name__)
 
 # this means time not influenced by ntp corrections - see <linux/time.h>
diff --git a/ovirt_hosted_engine_ha/lib/storage_backends.py 
b/ovirt_hosted_engine_ha/lib/storage_backends.py
index 3629021..f9c8988 100644
--- a/ovirt_hosted_engine_ha/lib/storage_backends.py
+++ b/ovirt_hosted_engine_ha/lib/storage_backends.py
@@ -494,7 +494,7 @@
         """
         lvc = popen(stdin=subprocess.PIPE, stdout=subprocess.PIPE,
                     stderr=subprocess.PIPE,
-                    args=["lvm", "lvcreate", "-L", str(size_bytes)+"B",
+                    args=["lvm", "lvcreate", "-L", str(size_bytes) + "B",
                           "-n", lv_name, vg_uuid])
         stdout, stderr = lvc.communicate()
         lvc.wait()
@@ -682,7 +682,7 @@
                     % block_device_fo.tell())
             services.setdefault(parsed.name, [])
             services[parsed.name].extend(parsed.pieces)
-            first_free_block = reduce(lambda acc, p: max(acc, p[0]+p[1]),
+            first_free_block = reduce(lambda acc, p: max(acc, p[0] + p[1]),
                                       parsed.pieces,
                                       first_free_block)
             if parsed.next == 0:
diff --git a/ovirt_hosted_engine_ha/lib/storage_backends_test.py 
b/ovirt_hosted_engine_ha/lib/storage_backends_test.py
index d2141ee..c99f64e 100644
--- a/ovirt_hosted_engine_ha/lib/storage_backends_test.py
+++ b/ovirt_hosted_engine_ha/lib/storage_backends_test.py
@@ -27,12 +27,12 @@
 
         # Test if the create call happened
         self.assertEqual(
-            [call("uuid", constants.SD_METADATA_DIR+"-test", 500)],
+            [call("uuid", constants.SD_METADATA_DIR + "-test", 500)],
             dev.lvcreate.mock_calls)
 
         # Test if the zero call happened
         self.assertEqual(
-            [call("uuid", constants.SD_METADATA_DIR+"-test", 500)],
+            [call("uuid", constants.SD_METADATA_DIR + "-test", 500)],
             dev.lvzero.mock_calls)
 
     def test_lvmcreate_enough(self):
@@ -70,7 +70,7 @@
 
         # Test if the zero call happened
         self.assertEqual(
-            [call("uuid", constants.SD_METADATA_DIR+"-test", 500)],
+            [call("uuid", constants.SD_METADATA_DIR + "-test", 500)],
             dev.lvzero.mock_calls)
 
     def test_lvmcreate_not_enough(self):
@@ -115,7 +115,7 @@
         b = BlockBackend("/dev/null", "test-1")
         blocks = b.create_info_blocks({"test1": 300,
                                        "test2": 512,
-                                       "test3": 1024*1024*50})
+                                       "test3": 1024 * 1024 * 50})
 
         self.assertEqual(3, len(blocks))
 
@@ -150,7 +150,7 @@
         b = BlockBackend("/dev/null", "test-1")
         blocks = b.create_info_blocks({"test1": 300,
                                        "test2": 512,
-                                       "test3": 1024*1024*50},
+                                       "test3": 1024 * 1024 * 50},
                                       first_free=1000)
 
         self.assertEqual(3, len(blocks))
@@ -192,7 +192,7 @@
         rawcrc = struct.pack("!L", zlib.crc32(raw) & 0xffffffff)
         b = BlockBackend("/dev/null", "test-1")
         block = b.create_block([(1, 100), (102, 100)], 1, "test")
-        self.assertEqual(raw+rawcrc, block)
+        self.assertEqual(raw + rawcrc, block)
 
     def test_create_empty_block(self):
         raw = struct.pack("!4sQ64pQQ",
@@ -202,7 +202,7 @@
         rawcrc = struct.pack("!L", zlib.crc32(raw) & 0xffffffff)
         b = BlockBackend("/dev/null", "test-1")
         block = b.create_block([], 1, "test")
-        self.assertEqual(raw+rawcrc, block)
+        self.assertEqual(raw + rawcrc, block)
 
     def test_single_good_block_decode(self):
         raw = struct.pack("!4sQ64pQQQQQQ",
@@ -213,7 +213,7 @@
                           0, 0)
         rawcrc = struct.pack("!L", zlib.crc32(raw) & 0xffffffff)
         b = BlockBackend("/dev/null", "test-1")
-        block = b.parse_meta_block(raw+rawcrc)
+        block = b.parse_meta_block(raw + rawcrc)
         self.assertEqual(block, BlockBackend.BlockInfo(
             self.SIGNATURE, 1, "test", ((1, 100), (102, 100)), True))
 
@@ -266,7 +266,7 @@
             "d": [(0, 1)]
         }
         updates = b._compute_updates({
-            "a": 15*b.blocksize + 5,  # should add another 5B
+            "a": 15 * b.blocksize + 5,  # should add another 5B
             "b": 5,  # no update, the space is already there
             "c": 5,  # new service
             "d": 5  # won't update because we always allocate a whole block
@@ -282,7 +282,7 @@
         dev = io.BytesIO()
         info = ['\0', '\1']
         b._write(dev, info)
-        self.assertEqual('\0'*512+'\1', dev.getvalue())
+        self.assertEqual('\0' * 512 + '\1', dev.getvalue())
 
     def test_write_update(self):
         b = BlockBackend("/dev/null", "test-1")
@@ -298,6 +298,6 @@
         expected.write(b.create_block([], 1, "test"))
         expected.seek(b.blocksize)
         expected.write(b.create_block([], 2, "test2"))
-        expected.seek(2*b.blocksize)
+        expected.seek(2 * b.blocksize)
         expected.write(b.create_block([], 0, "test3"))
         self.assertEqual(expected.getvalue(), dev.getvalue())


-- 
To view, visit https://gerrit.ovirt.org/38496
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6bb1256fca8fe50259b95531fa14eb33da68c19d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-hosted-engine-ha
Gerrit-Branch: master
Gerrit-Owner: Martin Sivák <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to