From 9d629e2976c15731b53fa978bca3cbd1166eea14 Mon Sep 17 00:00:00 2001 From: Anand Shanmugam Date: Fri, 13 Dec 2019 06:52:31 +0000 Subject: [PATCH] Fixing pep8 errors Change-Id: Id792009e36f4d7fc6489373b1b432855301a09ad --- cloudpulse/common/utils.py | 21 ++++++++++--------- cloudpulse/conductor/cpulse_lock.py | 1 + .../ansible/openstack_config_reader.py | 12 +++++------ .../ansible/openstack_node_info_reader.py | 8 +++---- cloudpulse/tests/functional/test_utils.py | 4 ++-- requirements.txt | 2 +- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/cloudpulse/common/utils.py b/cloudpulse/common/utils.py index 2f3ac51..ff3b34b 100644 --- a/cloudpulse/common/utils.py +++ b/cloudpulse/common/utils.py @@ -34,6 +34,7 @@ from oslo_concurrency import processutils from oslo_config import cfg from oslo_utils import excutils import paramiko +from past.builtins import basestring import six from cloudpulse.common import exception @@ -314,16 +315,16 @@ def read_cached_file(filename, cache_info, reload_func=None): return cache_info['data'] -def file_open(*args, **kwargs): - """Open file - - see built-in file() documentation for more details - - Note: The reason this is kept in a separate module is to easily - be able to provide a stub module that doesn't alter system - state at all (for unit tests) - """ - return file(*args, **kwargs) +# def file_open(*args, **kwargs): +# """Open file +# +# see built-in file() documentation for more details +# +# Note: The reason this is kept in a separate module is to easily +# be able to provide a stub module that doesn't alter system +# state at all (for unit tests) +# """ +# return file(*args, **kwargs) def hash_file(file_like_object): diff --git a/cloudpulse/conductor/cpulse_lock.py b/cloudpulse/conductor/cpulse_lock.py index 4591286..69ea522 100644 --- a/cloudpulse/conductor/cpulse_lock.py +++ b/cloudpulse/conductor/cpulse_lock.py @@ -16,6 +16,7 @@ from cloudpulse import objects import contextlib from oslo_log import log as logging from oslo_utils import excutils +from past.builtins import xrange import time LOG = logging.getLogger(__name__) diff --git a/cloudpulse/operator/ansible/openstack_config_reader.py b/cloudpulse/operator/ansible/openstack_config_reader.py index a5281ab..cb27b29 100644 --- a/cloudpulse/operator/ansible/openstack_config_reader.py +++ b/cloudpulse/operator/ansible/openstack_config_reader.py @@ -26,7 +26,7 @@ class os_cfg_reader(object): try: fp = open(abs_path) except IOError as e: - print ("Error while opening the file...%s" % e) + print("Error while opening the file...%s" % e) return try: @@ -34,7 +34,7 @@ class os_cfg_reader(object): # print "self.hostYamlObj: ", self.hostYamlObj, # dir(self.hostYamlObj) except yaml.error.YAMLError as perr: - print ("Error while parsing...%s" % perr) + print("Error while parsing...%s" % perr) return def setOpenstackNodeIp(self): @@ -62,10 +62,10 @@ class os_cfg_reader(object): def printHostList(self): for hostObj in self.openstack_host_list: - print ("IP - %s" % (hostObj.getIp())) - print ("HOST - %s" % (hostObj.getHost())) - print ("USER - %s" % (hostObj.getUser())) - print ("NAGIOS RUNNING - %s" % (str(hostObj.isNagiosRunning()))) + print("IP - %s" % (hostObj.getIp())) + print("HOST - %s" % (hostObj.getHost())) + print("USER - %s" % (hostObj.getUser())) + print("NAGIOS RUNNING - %s" % (str(hostObj.isNagiosRunning()))) def generate_ansible_config(self, os_obj_list): f = open('/var/sec_hc/ansible_hosts', 'w+') diff --git a/cloudpulse/operator/ansible/openstack_node_info_reader.py b/cloudpulse/operator/ansible/openstack_node_info_reader.py index 26909d5..fdd820c 100644 --- a/cloudpulse/operator/ansible/openstack_node_info_reader.py +++ b/cloudpulse/operator/ansible/openstack_node_info_reader.py @@ -25,12 +25,12 @@ class openstack_node_info_reader(object): try: fp = open(os_node_file) except IOError as e: - print ("Error while opening the file...%s", e) + print("Error while opening the file...%s", e) return try: self.hostYamlObj = yaml.safe_load(fp) except yaml.error.YAMLError as perr: - print ("Error while parsing...%s", perr) + print("Error while parsing...%s", perr) return def get_host_list(self): @@ -54,8 +54,8 @@ class openstack_node_info_reader(object): def printHostList(self, openstack_host_list): for hostObj in openstack_host_list: - print ("%s - %s - %s", hostObj.getIp(), - hostObj.getHost(), hostObj.getUser()) + print("%s - %s - %s", hostObj.getIp(), + hostObj.getHost(), hostObj.getUser()) def get_galera_details(self): galera = {} diff --git a/cloudpulse/tests/functional/test_utils.py b/cloudpulse/tests/functional/test_utils.py index f5f4ec8..2dbf356 100644 --- a/cloudpulse/tests/functional/test_utils.py +++ b/cloudpulse/tests/functional/test_utils.py @@ -160,12 +160,12 @@ def create_parsed_yaml(yaml_file): try: fp = open(yaml_file) except IOError as ioerr: - print ("Failed to open file %s [%s]" % (yaml_file, ioerr)) + print("Failed to open file %s [%s]" % (yaml_file, ioerr)) raise IOError(ioerr) try: parsed = yaml.safe_load(fp) except yaml.error.YAMLError as perr: - print ("Failed to parse %s [%s]" % (yaml_file, perr)) + print("Failed to parse %s [%s]" % (yaml_file, perr)) return None fp.close() return parsed diff --git a/requirements.txt b/requirements.txt index 7f76061..0da10a1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,7 +7,7 @@ pbr>=1.6 ansible<2.0.0.0 eventlet!=0.18.3,>=0.18.2 # MIT keystonemiddleware>=4.0.0,!=4.1.0,!=4.5.0 # Apache-2.0 -MySQL-python +mysql-connector PyMySQL>=0.6.2,!=0.7.7 # MIT License oslo.config>=3.14.0 # Apache-2.0 oslo.concurrency>=3.8.0 # Apache-2.0