]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
fix bug lp:1025526,update iniparser.py to accept empty value.
authorYaguang Tang <heut2008@gmail.com>
Tue, 17 Jul 2012 05:23:00 +0000 (13:23 +0800)
committerYaguang Tang <heut2008@gmail.com>
Thu, 19 Jul 2012 10:46:19 +0000 (18:46 +0800)
also,this patch turn off pep8 E125 check,this for now seems to
be unnecessary,it check continuous line split.and update the
latest openstack-common https://review.openstack.org/#/c/9201
which has fix pep8 1.3 issue except for E125 check.

Change-Id: I86e6a3add56a0a2941031a1248f1696667ac56b8

quantum/openstack/common/iniparser.py
quantum/openstack/common/log.py
quantum/openstack/common/notifier/api.py
quantum/openstack/common/notifier/list_notifier.py
quantum/openstack/common/notifier/log_notifier.py
quantum/openstack/common/notifier/rabbit_notifier.py
quantum/openstack/common/rpc/impl_zmq.py
quantum/tests/unit/test_api_v2.py
quantum/tests/unit/test_db_plugin.py
run_tests.sh
tox.ini

index e91eea5380fa4e88a070ede2971bcacfea5107a7..241284449e32c0be0200df6eec92b46b632d4cca 100644 (file)
@@ -53,7 +53,8 @@ class BaseParser(object):
             key, value = line[:colon], line[colon + 1:]
 
         value = value.strip()
-        if value[0] == value[-1] and value[0] == "\"" or value[0] == "'":
+        if ((value and value[0] == value[-1]) and
+            (value[0] == "\"" or value[0] == "'")):
             value = value[1:-1]
         return key.strip(), [value]
 
index 7165fe2253f4ec586abab9826d8e5ed6125fb712..0bf986bf13dea615a483c7d832a2403d5ad1f34c 100644 (file)
@@ -66,13 +66,13 @@ log_opts = [
                help='prefix each line of exception output with this format'),
     cfg.ListOpt('default_log_levels',
                 default=[
-                  'amqplib=WARN',
-                  'sqlalchemy=WARN',
-                  'boto=WARN',
-                  'suds=INFO',
-                  'keystone=INFO',
-                  'eventlet.wsgi.server=WARN'
-                  ],
+                    'amqplib=WARN',
+                    'sqlalchemy=WARN',
+                    'boto=WARN',
+                    'suds=INFO',
+                    'keystone=INFO',
+                    'eventlet.wsgi.server=WARN'
+                ],
                 help='list of logger=LEVEL pairs'),
     cfg.BoolOpt('publish_errors',
                 default=False,
@@ -89,7 +89,7 @@ log_opts = [
                default='[instance: %(uuid)s] ',
                help='If an instance UUID is passed with the log message, '
                     'format it like this'),
-    ]
+]
 
 
 generic_log_opts = [
@@ -105,7 +105,7 @@ generic_log_opts = [
     cfg.StrOpt('logfile_mode',
                default='0644',
                help='Default file mode used when creating log files'),
-    ]
+]
 
 
 CONF = cfg.CONF
@@ -208,9 +208,9 @@ class JSONFormatter(logging.Formatter):
     def formatException(self, ei, strip_newlines=True):
         lines = traceback.format_exception(*ei)
         if strip_newlines:
-            lines = [itertools.ifilter(lambda x: x,
-                                      line.rstrip().splitlines())
-                    for line in lines]
+            lines = [itertools.ifilter(
+                lambda x: x,
+                line.rstrip().splitlines()) for line in lines]
             lines = list(itertools.chain(*lines))
         return lines
 
@@ -252,9 +252,9 @@ class PublishErrorsHandler(logging.Handler):
                 CONF.list_notifier_drivers):
                 return
         notifier.api.notify(None, 'error.publisher',
-                                 'error_notification',
-                                 notifier.api.ERROR,
-                                 dict(error=record.msg))
+                            'error_notification',
+                            notifier.api.ERROR,
+                            dict(error=record.msg))
 
 
 def handle_exception(type, value, tb):
index b3e7371edf1735aa818a783cee59598a6d41169c..2b31ecc28d884833a296f131820d3bb9d317bf38 100644 (file)
@@ -37,7 +37,7 @@ notifier_opts = [
     cfg.StrOpt('default_publisher_id',
                default='$host',
                help='Default publisher_id for outgoing notifications'),
-    ]
+]
 
 CONF = cfg.CONF
 CONF.register_opts(notifier_opts)
@@ -122,21 +122,21 @@ def notify(context, publisher_id, event_type, priority, payload):
     """
     if priority not in log_levels:
         raise BadPriorityException(
-                 _('%s not in valid priorities') % priority)
+            _('%s not in valid priorities') % priority)
 
     # Ensure everything is JSON serializable.
     payload = jsonutils.to_primitive(payload, convert_instances=True)
 
     driver = importutils.import_module(CONF.notification_driver)
     msg = dict(message_id=str(uuid.uuid4()),
-                   publisher_id=publisher_id,
-                   event_type=event_type,
-                   priority=priority,
-                   payload=payload,
-                   timestamp=str(timeutils.utcnow()))
+               publisher_id=publisher_id,
+               event_type=event_type,
+               priority=priority,
+               payload=payload,
+               timestamp=str(timeutils.utcnow()))
     try:
         driver.notify(context, msg)
     except Exception, e:
         LOG.exception(_("Problem '%(e)s' attempting to "
                         "send to notification system. Payload=%(payload)s") %
-                        locals())
+                      locals())
index b2f3afa282724b26e7384a9e3b8d6b4081424dfd..baa4fab31fb278196078f61ec945460b9b87870a 100644 (file)
@@ -19,9 +19,10 @@ from quantum.openstack.common import importutils
 from quantum.openstack.common import log as logging
 
 
-list_notifier_drivers_opt = cfg.MultiStrOpt('list_notifier_drivers',
-        default=['quantum.openstack.common.notifier.no_op_notifier'],
-        help='List of drivers to send notifications')
+list_notifier_drivers_opt = cfg.MultiStrOpt(
+    'list_notifier_drivers',
+    default=['quantum.openstack.common.notifier.no_op_notifier'],
+    help='List of drivers to send notifications')
 
 CONF = cfg.CONF
 CONF.register_opt(list_notifier_drivers_opt)
index ea779082002b1404105dad0bc3f494f819e06476..225cbd1e10517efbc9d574d98c8e9a1d3da228a5 100644 (file)
@@ -30,6 +30,6 @@ def notify(_context, message):
                            CONF.default_notification_level)
     priority = priority.lower()
     logger = logging.getLogger(
-            'quantum.openstack.common.notification.%s' %
-            message['event_type'])
+        'quantum.openstack.common.notification.%s' %
+        message['event_type'])
     getattr(logger, priority)(jsonutils.dumps(message))
index 1f737da18de898d2053b69e51cf482d78f7a484d..e11c418fead1abb12dcdb990827e2d3eeddf67b3 100644 (file)
@@ -22,9 +22,9 @@ from quantum.openstack.common import rpc
 
 LOG = logging.getLogger(__name__)
 
-notification_topic_opt = cfg.ListOpt('notification_topics',
-        default=['notifications', ],
-        help='AMQP topic used for openstack notifications')
+notification_topic_opt = cfg.ListOpt(
+    'notification_topics', default=['notifications', ],
+    help='AMQP topic used for openstack notifications')
 
 CONF = cfg.CONF
 CONF.register_opt(notification_topic_opt)
index 0b1336e3af36a7dc8c27fa9c1870999bf6fe1e14..3396ef3720db7b2389881e41df09c103c2f83835 100644 (file)
@@ -52,7 +52,7 @@ zmq_opts = [
         default=('quantum.openstack.common.rpc.'
                  'matchmaker.MatchMakerLocalhost'),
         help='MatchMaker driver',
-        ),
+    ),
 
     # The following port is unassigned by IANA as of 2012-05-21
     cfg.IntOpt('rpc_zmq_port', default=9501,
index 66be5ceee3d800e2d80c55538eb12041ad71c35d..b068108cd17292cae7c0e51ff00ca7827518e3a6 100644 (file)
@@ -68,7 +68,7 @@ class V2WsgiResourceTestCase(unittest.TestCase):
 
         environ = {'wsgiorg.routing_args': (None, {'action': 'test'})}
         res = resource.get('', extra_environ=environ, expect_errors=True)
-        self.assertEqual(res.status_int,  exc.HTTPInternalServerError.code)
+        self.assertEqual(res.status_int, exc.HTTPInternalServerError.code)
 
     def test_mapped_quantum_error(self):
         controller = mock.MagicMock()
index 4bf80d2aec3ebdf79e74603a4991a1724c94d204..5b88979c1f89a4392137a0ce123af9fbb1c4fed8 100644 (file)
@@ -772,7 +772,7 @@ class TestPortsV2(QuantumDbPluginV2TestCase):
     def test_invalid_admin_state(self):
         with self.network() as network:
             data = {'port': {'network_id': network['network']['id'],
-                             'tenant_id':  network['network']['tenant_id'],
+                             'tenant_id': network['network']['tenant_id'],
                              'admin_state_up': 7,
                              'fixed_ips': []}}
             port_req = self.new_create_request('ports', data)
@@ -782,7 +782,7 @@ class TestPortsV2(QuantumDbPluginV2TestCase):
     def test_invalid_mac_address(self):
         with self.network() as network:
             data = {'port': {'network_id': network['network']['id'],
-                             'tenant_id':  network['network']['tenant_id'],
+                             'tenant_id': network['network']['tenant_id'],
                              'admin_state_up': 1,
                              'mac_address': 'mac',
                              'fixed_ips': []}}
index a2e3772d961f650c243b7344ebd73a42e8ef4d69..4282058efa41572da592b06b67a1859604384da6 100755 (executable)
@@ -98,13 +98,9 @@ function run_pep8 {
   echo "Running pep8 ..."
 
   PEP8_EXCLUDE="vcsversion.py,*.pyc"
-  # TODO(gongysh) we should pep8 check openstack common files. But that project does
-  # not stick to latest pep8 version. Therefore we exclude these common files here.
-  # Pep8 does not support exclude in the format quantum/openstack/common,
-  # so I have to exclude some of openstack common files one by one. This also applies
-  # to tox.ini.
-  PEP8_EXCLUDE="$PEP8_EXCLUDE,log.py,notifier,rpc"
-  PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-source"
+  # we now turn off pep8 1.3 E125 check to avoid make change to 
+  # openstack-common . 
+  PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --ignore=E125 --repeat --show-source"
   PEP8_INCLUDE="bin/* quantum run_tests.py setup*.py"
   ${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE
 }
diff --git a/tox.ini b/tox.ini
index 402b6539bdeb39509b31610c249f1c537c11a81c..823b6b2e335ca088b1f52658326c690124d01f39 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -21,7 +21,7 @@ downloadcache = ~/cache/pip
 [testenv:pep8]
 deps = pep8
        setuptools_git>=0.4
-commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc,*egg,log.py,notifier,rpc .
+commands = pep8 --repeat --show-source --ignore=E125 --exclude=.venv,.tox,dist,doc,*egg .
 
 [testenv:cover]
 setenv = NOSE_WITH_COVERAGE=1