Merge "Enable PEP8 checks for E121, E129, E231, E265, E302"

This commit is contained in:
Jenkins 2015-01-16 11:07:35 +00:00 committed by Gerrit Code Review
commit 64c2850441
11 changed files with 114 additions and 84 deletions

View File

@ -14,10 +14,6 @@ they are used in the engine-setup.py
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:"

View File

@ -77,6 +77,7 @@ def process_add_quotes_around_values(param, param_name, config=None):
param = ','.join(params_list)
return param
def process_password(param, param_name, config=None):
"""
Process passwords, checking the following:

View File

@ -32,6 +32,7 @@ commandLineValues = {}
masked_value_set = set()
tmpfiles = []
def initLogging(debug):
try:
logFile = os.path.join(basedefs.DIR_LOG, basedefs.FILE_LOG)
@ -60,6 +61,7 @@ def initLogging(debug):
return logFile
def _getInputFromUser(param):
"""
this private func reads the data from the user
@ -133,6 +135,7 @@ def _getInputFromUser(param):
logging.error(traceback.format_exc())
raise Exception(output_messages.ERR_EXP_READ_INPUT_PARAM % (param.CONF_NAME))
def input_param(param):
"""
this func will read input from user
@ -160,6 +163,7 @@ def input_param(param):
return param
def _askYesNo(question=None):
message = StringIO()
@ -182,6 +186,7 @@ def _askYesNo(question=None):
return answer == 'y'
def _addDefaultsToMaskedValueSet():
"""
For every param in conf_params
@ -195,6 +200,7 @@ def _addDefaultsToMaskedValueSet():
if ((param.MASK_INPUT == True) and param.DEFAULT_VALUE != ""):
masked_value_set.add(param.DEFAULT_VALUE)
def _updateMaskedValueSet():
"""
For every param in conf
@ -207,6 +213,7 @@ def _updateMaskedValueSet():
if (controller.getParamKeyValue(confName, "MASK_INPUT") == True):
masked_value_set.add(controller.CONF[confName])
def mask(input):
"""
Gets a dict/list/str and search maksked values in them.
@ -234,6 +241,7 @@ def mask(input):
return output
def removeMaskString(maskedString):
"""
remove an element from masked_value_set
@ -252,6 +260,7 @@ def removeMaskString(maskedString):
if found:
masked_value_set.remove(maskedString)
def validate_param_value(param, value):
cname = param.CONF_NAME
logging.debug("Validating parameter %s." % cname)
@ -265,6 +274,7 @@ def validate_param_value(param, value):
print 'Parameter %s failed validation: %s' % (cname, ex)
raise
def process_param_value(param, value):
_value = value
proclist = param.PROCESSORS or []
@ -287,6 +297,7 @@ def process_param_value(param, value):
raise
return _value
def _handleGroupCondition(config, conditionName, conditionValue):
"""
handle params group pre/post condition
@ -364,6 +375,7 @@ def _loadParamFromFile(config, section, param_name):
return value
def _handleAnswerFileParams(answerFile):
"""
handle loading and validating
@ -428,6 +440,7 @@ def _getanswerfilepath():
controller.MESSAGES.append(msg)
return path
def _gettmpanswerfilepath():
path = None
msg = "Could not find a suitable path on which to create the temporary answerfile"
@ -441,6 +454,7 @@ def _gettmpanswerfilepath():
return path
def _handleInteractiveParams():
try:
logging.debug("Groups: %s" % ', '.join([x.GROUP_NAME for x in controller.getAllGroups()]))
@ -498,6 +512,7 @@ def _handleInteractiveParams():
logging.error(traceback.format_exc())
raise Exception(output_messages.ERR_EXP_HANDLE_PARAMS)
def _handleParams(configFile):
_addDefaultsToMaskedValueSet()
if configFile:
@ -505,6 +520,7 @@ def _handleParams(configFile):
else:
_handleInteractiveParams()
def _getConditionValue(matchMember):
returnValue = False
if type(matchMember) == types.FunctionType:
@ -521,6 +537,7 @@ def _getConditionValue(matchMember):
return returnValue
def _displaySummary():
print output_messages.INFO_DSPLY_PARAMS
@ -561,12 +578,14 @@ def _displaySummary():
else:
logging.debug("user chose to accept user parameters")
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)
def _addFinalInfoMsg(logFile):
"""
add info msg to the user finalizing the
@ -590,6 +609,7 @@ def _summaryParamsToLog():
def runSequences():
controller.runAllSequences()
def _main(options, configFile=None, logFile=None):
print output_messages.INFO_HEADER
print("")
@ -656,6 +676,7 @@ def remove_remote_var_dirs(options, config, messages):
logging.exception(e)
messages.append(utils.color_text(msg, 'red'))
def remove_temp_files():
"""
Removes any temporary files generated during
@ -701,6 +722,7 @@ def generateAnswerFile(outputFile, overrides={}):
'conf_name': param.CONF_NAME}
ans_file.write(fmt % args)
def single_step_aio_install(options, logFile):
""" Installs an All in One host on this host"""
@ -717,12 +739,13 @@ def single_step_aio_install(options, logFile):
# If we are doing an all-in-one install, do demo provisioning
# unless specifically told not to
if (options.os_neutron_install != "n" and \
if (options.os_neutron_install != "n" and
not options.provision_all_in_one_ovs_bridge):
options.provision_all_in_one_ovs_bridge = "y"
single_step_install(options, logFile)
def single_step_install(options, logFile):
answerfilepath = _gettmpanswerfilepath()
if not answerfilepath:
@ -753,6 +776,7 @@ def single_step_install(options, logFile):
generateAnswerFile(answerfilepath, overrides)
_main(options, answerfilepath, logFile)
def initCmdLineParser():
"""
Initiate the optparse object, add all the groups and general command line flags
@ -796,6 +820,7 @@ def initCmdLineParser():
return parser
def printOptions():
"""
print and document the available options to the answer file (rst format)
@ -815,6 +840,7 @@ def printOptions():
print " %s %s" % (paramUsage, optionsList)
print
def plugin_compare(x, y):
"""
Used to sort the plugin file list
@ -826,6 +852,7 @@ def plugin_compare(x, y):
y_cmp = y_match.group(1)
return int(x_cmp) - int(y_cmp)
def loadPlugins():
"""
Load All plugins from ./plugins
@ -852,6 +879,7 @@ def loadPlugins():
logging.error(traceback.format_exc())
raise Exception("Failed to load plugin from file %s" % item)
def checkPlugin(plugin):
for funcName in ['initConfig', 'initSequences']:
if not hasattr(plugin, funcName):
@ -886,10 +914,12 @@ def initPluginsConfig():
for plugin in controller.getAllPlugins():
plugin.initConfig(controller)
def initPluginsSequences():
for plugin in controller.getAllPlugins():
plugin.initSequences(controller)
def _set_command_line_values(options):
for key, value in options.__dict__.items():
# Replace the _ with - in the string since optparse replace _ with -
@ -898,6 +928,7 @@ def _set_command_line_values(options):
if len(param) > 0 and value:
commandLineValues[param[0].CONF_NAME] = value
def main():
options = ""

View File

@ -208,6 +208,8 @@ def validate_multi_ping(param, options=None):
_tested_ports = []
def touch_port(host, port):
"""
Check that provided host is listening on provided port.

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,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
ignore = E123,E125,H803,E128,F403,F821,E127,F811,F401,F841,E501,E272,E111,E502,E202,W601,E271,E721,E712,E261,E131,E126,E303,E711,E241,E713,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