Enable PEP8 checks for E211, E222, E225, E228

* E211 whitespace before '('
* E222 multiple spaces after operator
* E225 missing whitespace around operator
* E228 missing whitespace around modulo operator

Change-Id: I19f51d646bbb9a8854555419a4139c059207ea60
This commit is contained in:
Christian Berendt 2015-01-09 08:35:42 +01:00
parent e458fc721a
commit 05a27ebb9c
4 changed files with 77 additions and 77 deletions

View File

@ -18,28 +18,28 @@ import basedefs
####INFO MESSAGES####
#####################
INFO_HEADER="Welcome to the %s setup utility" % basedefs.APP_NAME
INFO_INSTALL_SUCCESS="\n **** Installation completed successfully ******\n"
INFO_INSTALL="Installing:"
INFO_DSPLY_PARAMS="\n%s will be installed using the following configuration:" % basedefs.APP_NAME
INFO_USE_PARAMS="Proceed with the configuration listed above"
INFO_DONE="DONE"
INFO_ERROR="ERROR"
INFO_LOG_FILE_PATH="The installation log file is available at: %s"
INFO_MANIFEST_PATH="The generated manifests are available at: %s"
INFO_ADDTIONAL_MSG="Additional information:"
INFO_ADDTIONAL_MSG_BULLET=" * %s"
INFO_CONF_PARAMS_PASSWD_CONFIRM_PROMPT="Confirm password"
INFO_VAL_PATH_SPACE="Error: mount point %s contains only %s of available space while a minimum of %s is required"
INFO_VAL_NOT_INTEGER="Error: value is not an integer"
INFO_VAL_PORT_NOT_RANGE="Error: port is outside the range of %i - 65535"
INFO_VAL_STRING_EMPTY="Warning: The %s parameter is empty"
INFO_VAL_NOT_IN_OPTIONS="Error: response is not part of the following accepted answers: %s"
INFO_VAL_NOT_DOMAIN="Error: domain is not a valid domain name"
INFO_VAL_NOT_USER="Error: user name contains illegal characters"
INFO_VAL_PORT_OCCUPIED="Error: TCP Port %s is already open by %s (pid: %s)"
INFO_VAL_PORT_OCCUPIED_BY_JBOSS="Error: TCP Port %s is used by JBoss"
INFO_VAL_PASSWORD_DONT_MATCH="Error: passwords don't match"
INFO_HEADER = "Welcome to the %s setup utility" % basedefs.APP_NAME
INFO_INSTALL_SUCCESS = "\n **** Installation completed successfully ******\n"
INFO_INSTALL = "Installing:"
INFO_DSPLY_PARAMS = "\n%s will be installed using the following configuration:" % basedefs.APP_NAME
INFO_USE_PARAMS = "Proceed with the configuration listed above"
INFO_DONE = "DONE"
INFO_ERROR = "ERROR"
INFO_LOG_FILE_PATH = "The installation log file is available at: %s"
INFO_MANIFEST_PATH = "The generated manifests are available at: %s"
INFO_ADDTIONAL_MSG = "Additional information:"
INFO_ADDTIONAL_MSG_BULLET = " * %s"
INFO_CONF_PARAMS_PASSWD_CONFIRM_PROMPT = "Confirm password"
INFO_VAL_PATH_SPACE = "Error: mount point %s contains only %s of available space while a minimum of %s is required"
INFO_VAL_NOT_INTEGER = "Error: value is not an integer"
INFO_VAL_PORT_NOT_RANGE = "Error: port is outside the range of %i - 65535"
INFO_VAL_STRING_EMPTY = "Warning: The %s parameter is empty"
INFO_VAL_NOT_IN_OPTIONS = "Error: response is not part of the following accepted answers: %s"
INFO_VAL_NOT_DOMAIN = "Error: domain is not a valid domain name"
INFO_VAL_NOT_USER = "Error: user name contains illegal characters"
INFO_VAL_PORT_OCCUPIED = "Error: TCP Port %s is already open by %s (pid: %s)"
INFO_VAL_PORT_OCCUPIED_BY_JBOSS = "Error: TCP Port %s is used by JBoss"
INFO_VAL_PASSWORD_DONT_MATCH = "Error: passwords don't match"
INFO_CHANGED_VALUE = ("Packstack changed given value %s to required "
"value %s")
@ -48,42 +48,42 @@ WARN_VAL_IS_HOSTNAME = ("Warning: Packstack failed to change given "
"services might not run correctly when hostname"
" is used.")
INFO_STRING_LEN_LESS_THAN_MIN="String length is less than the minimum allowed: %s"
INFO_STRING_EXCEEDS_MAX_LENGTH="String length exceeds the maximum length allowed: %s"
INFO_STRING_CONTAINS_ILLEGAL_CHARS="String contains illegal characters"
INFO_CINDER_VOLUMES_EXISTS="Did not create a cinder volume group, one already existed"
INFO_REMOVE_REMOTE_VAR="Removing %s on %s (if it is a remote host)"
INFO_STRING_LEN_LESS_THAN_MIN = "String length is less than the minimum allowed: %s"
INFO_STRING_EXCEEDS_MAX_LENGTH = "String length exceeds the maximum length allowed: %s"
INFO_STRING_CONTAINS_ILLEGAL_CHARS = "String contains illegal characters"
INFO_CINDER_VOLUMES_EXISTS = "Did not create a cinder volume group, one already existed"
INFO_REMOVE_REMOTE_VAR = "Removing %s on %s (if it is a remote host)"
WARN_WEAK_PASS="Warning: Weak Password."
WARN_NM_ENABLED=("Warning: NetworkManager is active on %s. OpenStack "
WARN_WEAK_PASS = "Warning: Weak Password."
WARN_NM_ENABLED = ("Warning: NetworkManager is active on %s. OpenStack "
"networking currently does not work on systems that have "
"the Network Manager service enabled.")
ERR_PING = "Error: the provided hostname is unreachable"
ERR_SSH = "Error: could not connect to the ssh server: %s"
ERR_FILE = "Error: the provided file is not present"
ERR_CHECK_LOG_FILE_FOR_MORE_INFO="Please check log file %s for more information"
ERR_YUM_LOCK="Internal Error: Can't edit versionlock "
ERR_CHECK_LOG_FILE_FOR_MORE_INFO = "Please check log file %s for more information"
ERR_YUM_LOCK = "Internal Error: Can't edit versionlock "
ERR_FAILED_START_SERVICE = "Error: Can't start the %s service"
ERR_FAILED_STOP_SERVICE = "Error: Can't stop the %s service"
ERR_EXP_HANDLE_PARAMS="Failed handling user parameters input"
ERR_EXP_KEYBOARD_INTERRUPT="Keyboard interrupt caught."
ERR_READ_RPM_VER="Error reading version number for package %s"
ERR_EXP_READ_INPUT_PARAM="Error while trying to read parameter %s from user."
ERR_EXP_VALIDATE_PARAM="Error validating parameter %s from user."
ERR_EXP_HANDLE_ANSWER_FILE="Failed handling answer file: %s"
ERR_EXP_GET_CFG_IPS="Could not get list of available IP addresses on this host"
ERR_EXP_GET_CFG_IPS_CODES="Failed to get list of IP addresses"
ERR_EXP_CANT_FIND_IP="Could not find any configured IP address"
ERR_DIDNT_RESOLVED_IP="%s did not resolve into an IP address"
ERR_IPS_NOT_CONFIGED="Some or all of the IP addresses: (%s) which were resolved from the FQDN %s are not configured on any interface on this host"
ERR_IPS_NOT_CONFIGED_ON_INT="The IP (%s) which was resolved from the FQDN %s is not configured on any interface on this host"
ERR_IPS_HAS_NO_PTR="None of the IP addresses on this host(%s) holds a PTR record for the FQDN: %s"
ERR_IP_HAS_NO_PTR="The IP %s does not hold a PTR record for the FQDN: %s"
ERR_EXP_FAILED_INIT_LOGGER="Unexpected error: Failed to initiate logger, please check file system permission"
ERR_FAILURE="General failure"
ERR_NO_ANSWER_FILE="Error: Could not find file %s"
ERR_ONLY_1_FLAG="Error: The %s flag is mutually exclusive to all other command line options"
ERR_REMOVE_REMOTE_VAR="Error: Failed to remove directory %s on %s, it contains sensitive data and should be removed"
ERR_REMOVE_TMP_FILE="Error: Failed to remove temporary file %s, it contains sensitive data and should be removed"
ERR_EXP_HANDLE_PARAMS = "Failed handling user parameters input"
ERR_EXP_KEYBOARD_INTERRUPT = "Keyboard interrupt caught."
ERR_READ_RPM_VER = "Error reading version number for package %s"
ERR_EXP_READ_INPUT_PARAM = "Error while trying to read parameter %s from user."
ERR_EXP_VALIDATE_PARAM = "Error validating parameter %s from user."
ERR_EXP_HANDLE_ANSWER_FILE = "Failed handling answer file: %s"
ERR_EXP_GET_CFG_IPS = "Could not get list of available IP addresses on this host"
ERR_EXP_GET_CFG_IPS_CODES = "Failed to get list of IP addresses"
ERR_EXP_CANT_FIND_IP = "Could not find any configured IP address"
ERR_DIDNT_RESOLVED_IP = "%s did not resolve into an IP address"
ERR_IPS_NOT_CONFIGED = "Some or all of the IP addresses: (%s) which were resolved from the FQDN %s are not configured on any interface on this host"
ERR_IPS_NOT_CONFIGED_ON_INT = "The IP (%s) which was resolved from the FQDN %s is not configured on any interface on this host"
ERR_IPS_HAS_NO_PTR = "None of the IP addresses on this host(%s) holds a PTR record for the FQDN: %s"
ERR_IP_HAS_NO_PTR = "The IP %s does not hold a PTR record for the FQDN: %s"
ERR_EXP_FAILED_INIT_LOGGER = "Unexpected error: Failed to initiate logger, please check file system permission"
ERR_FAILURE = "General failure"
ERR_NO_ANSWER_FILE = "Error: Could not find file %s"
ERR_ONLY_1_FLAG = "Error: The %s flag is mutually exclusive to all other command line options"
ERR_REMOVE_REMOTE_VAR = "Error: Failed to remove directory %s on %s, it contains sensitive data and should be removed"
ERR_REMOVE_TMP_FILE = "Error: Failed to remove temporary file %s, it contains sensitive data and should be removed"
#

View File

@ -32,7 +32,7 @@ commandLineValues = {}
masked_value_set = set()
tmpfiles = []
def initLogging (debug):
def initLogging(debug):
try:
logFile = os.path.join(basedefs.DIR_LOG, basedefs.FILE_LOG)
@ -40,14 +40,14 @@ def initLogging (debug):
# passwords in logs
os.close(os.open(logFile, os.O_CREAT | os.O_EXCL, 0600))
hdlr = logging.FileHandler (filename=logFile, mode='w')
hdlr = logging.FileHandler(filename=logFile, mode='w')
if (debug):
level = logging.DEBUG
else:
level = logging.INFO
fmts='%(asctime)s::%(levelname)s::%(module)s::%(lineno)d::%(name)s:: %(message)s'
dfmt='%Y-%m-%d %H:%M:%S'
fmts = '%(asctime)s::%(levelname)s::%(module)s::%(lineno)d::%(name)s:: %(message)s'
dfmt = '%Y-%m-%d %H:%M:%S'
fmt = logging.Formatter(fmts, dfmt)
hdlr.setFormatter(fmt)
@ -164,8 +164,8 @@ def _askYesNo(question=None):
message = StringIO()
while True:
askString = "\r%s? (yes|no): "%(question)
logging.debug("asking user: %s"%askString)
askString = "\r%s? (yes|no): " % (question)
logging.debug("asking user: %s" % askString)
message.write(askString)
message.seek(0)
@ -175,7 +175,7 @@ def _askYesNo(question=None):
continue
answer = raw[0].lower()
logging.debug("user answered read: %s"%(answer))
logging.debug("user answered read: %s" % (answer))
if answer not in 'yn':
continue
@ -398,9 +398,9 @@ def _handleAnswerFileParams(answerFile):
# Handle post condition match for group
if postConditionValue != group.POST_CONDITION_MATCH:
logging.error("The group condition (%s) returned: %s, which differs from the excpeted output: %s"%\
logging.error("The group condition (%s) returned: %s, which differs from the excpeted output: %s" %\
(group.GROUP_NAME, postConditionValue, group.POST_CONDITION_MATCH))
raise ValueError(output_messages.ERR_EXP_GROUP_VALIDATION_ANS_FILE%\
raise ValueError(output_messages.ERR_EXP_GROUP_VALIDATION_ANS_FILE %\
(group.GROUP_NAME, postConditionValue, group.POST_CONDITION_MATCH))
else:
logging.debug("condition (%s) passed" % group.POST_CONDITION)
@ -411,7 +411,7 @@ def _handleAnswerFileParams(answerFile):
except Exception as e:
logging.error(traceback.format_exc())
raise Exception(output_messages.ERR_EXP_HANDLE_ANSWER_FILE%(e))
raise Exception(output_messages.ERR_EXP_HANDLE_ANSWER_FILE % (e))
def _getanswerfilepath():
@ -422,7 +422,7 @@ def _getanswerfilepath():
p = os.path.expanduser("~/")
if os.access(p, os.W_OK):
path = os.path.abspath(os.path.join(p, "packstack-answers-%s.txt"%ts))
path = os.path.abspath(os.path.join(p, "packstack-answers-%s.txt" % ts))
msg = "A new answerfile was created in: %s" % path
controller.MESSAGES.append(msg)
@ -436,7 +436,7 @@ def _gettmpanswerfilepath():
p = os.path.expanduser("~/")
if os.access(p, os.W_OK):
path = os.path.abspath(os.path.join(p, "tmp-packstack-answers-%s.txt"%ts))
path = os.path.abspath(os.path.join(p, "tmp-packstack-answers-%s.txt" % ts))
tmpfiles.append(path)
return path
@ -517,7 +517,7 @@ def _getConditionValue(matchMember):
input_param(param)
returnValue = controller.CONF[matchMember]
else:
raise TypeError("%s type (%s) is not supported"%(matchMember, type(matchMember)))
raise TypeError("%s type (%s) is not supported" % (matchMember, type(matchMember)))
return returnValue
@ -565,16 +565,16 @@ def _printAdditionalMessages():
if len(controller.MESSAGES) > 0:
print "\n",output_messages.INFO_ADDTIONAL_MSG
for msg in controller.MESSAGES:
print output_messages.INFO_ADDTIONAL_MSG_BULLET%(msg)
print output_messages.INFO_ADDTIONAL_MSG_BULLET % (msg)
def _addFinalInfoMsg(logFile):
"""
add info msg to the user finalizing the
successfull install of rhemv
"""
controller.MESSAGES.append(output_messages.INFO_LOG_FILE_PATH%(logFile))
controller.MESSAGES.append(output_messages.INFO_LOG_FILE_PATH % (logFile))
controller.MESSAGES.append(
output_messages.INFO_MANIFEST_PATH%(basedefs.PUPPET_MANIFEST_DIR))
output_messages.INFO_MANIFEST_PATH % (basedefs.PUPPET_MANIFEST_DIR))
def _summaryParamsToLog():
@ -724,7 +724,7 @@ def single_step_aio_install(options, logFile):
single_step_install(options, logFile)
def single_step_install(options, logFile):
answerfilepath = _gettmpanswerfilepath()
answerfilepath = _gettmpanswerfilepath()
if not answerfilepath:
_printAdditionalMessages()
return
@ -915,7 +915,7 @@ def main():
raise SystemExit
# Initialize logging
logFile = initLogging (options.debug)
logFile = initLogging(options.debug)
# Parse parameters
runConfiguration = True
@ -928,7 +928,7 @@ def main():
if options.gen_answer_file:
# Make sure only --gen-answer-file was supplied
validateSingleFlag(options, "gen_answer_file")
answerfilepath = _gettmpanswerfilepath()
answerfilepath = _gettmpanswerfilepath()
if not answerfilepath:
_printAdditionalMessages()
return
@ -974,7 +974,7 @@ def main():
logging.error(traceback.format_exc())
print
print utils.color_text("ERROR : " + str(e), 'red')
print output_messages.ERR_CHECK_LOG_FILE_FOR_MORE_INFO%(logFile)
print output_messages.ERR_CHECK_LOG_FILE_FOR_MORE_INFO % (logFile)
sys.exit(1)
finally:

View File

@ -15,11 +15,11 @@ def steps_new_format(steplist):
class Controller(object):
__GROUPS=[]
__SEQUENCES=[]
__PLUGINS=[]
MESSAGES=[]
CONF={}
__GROUPS = []
__SEQUENCES = []
__PLUGINS = []
MESSAGES = []
CONF = {}
__single = None # the one, true Singleton ... for god's sake why ??? :)

View File

@ -33,6 +33,6 @@ commands = python setup.py build_sphinx
# E123, E125 skipped as they are invalid PEP-8.
#
# All other checks should be enabled in the future.
ignore = E123,E125,H803,E128,F403,F821,E127,F811,E265,F401,F841,E228,E129,E231,E501,E222,E211,E302,E272,E111,E502,E202,W601,E271,E721,E225,E712,E261,E131,E126,E303,E711,E241,E713,E121,E122,E401,H402,H302,H303,H304,H301,H306,H234,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H401,H232
ignore = E123,E125,H803,E128,F403,F821,E127,F811,E265,F401,F841,E129,E231,E501,E302,E272,E111,E502,E202,W601,E271,E721,E712,E261,E131,E126,E303,E711,E241,E713,E121,E122,E401,H402,H302,H303,H304,H301,H306,H234,H405,H404,H904,H201,H305,H307,H501,H102,H233,H101,H233,H401,H232
show-source = True
exclude=.venv,.git,.tox