upgrade hacking module

- upgrades hacking to current version
- sorts new linting issues
- sorts bug with sys.reload on py3

Change-Id: I4a18abc93116667a2733e8aec619ac59ea73d630
Signed-off-by: Sorin Sbarnea <ssbarnea@redhat.com>
This commit is contained in:
Sorin Sbarnea 2018-06-19 17:23:22 +01:00
parent c337c5fa75
commit 4f7b6ee568
No known key found for this signature in database
GPG Key ID: B85725D917D27B8A
10 changed files with 27 additions and 23 deletions

View File

@ -17,6 +17,7 @@ import io
import os
import logging
import platform
import sys
from stevedore import extension
import yaml
@ -26,6 +27,9 @@ from jenkins_jobs.config import JJBConfig
from jenkins_jobs import utils
from jenkins_jobs import version
if sys.version_info[0] != 2:
from importlib import reload
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger()

View File

@ -417,7 +417,7 @@ class YamlInclude(BaseYAMLObject):
try:
with io.open(filename, 'r', encoding='utf-8') as f:
return f.read()
except:
except Exception:
logger.error("Failed to include file using search path: '{0}'"
.format(':'.join(loader.search_path)))
raise

View File

@ -668,8 +668,8 @@ def dynamic_string_scriptler_param(registry, xml_parent, data):
def dynamic_param_common(registry, xml_parent, data, ptype):
pdef = base_param(registry, xml_parent, data, False,
'com.seitenbau.jenkins.plugins.dynamicparameter.'
+ ptype)
'com.seitenbau.jenkins.plugins.dynamicparameter.' +
ptype)
XML.SubElement(pdef, '__remote').text = str(
data.get('remote', False)).lower()
XML.SubElement(pdef, '__script').text = data.get('script', None)

View File

@ -136,8 +136,8 @@ class Matrix(jenkins_jobs.modules.base.Base):
root = XML.Element('matrix-project')
# Default to 'execution-strategy'
strategies = ([s for s in data.keys() if s.endswith('-strategy')]
or ['execution-strategy'])
strategies = ([s for s in data.keys() if s.endswith('-strategy')] or
['execution-strategy'])
# Job can not have multiple strategies
if len(strategies) > 1:

View File

@ -656,8 +656,8 @@ def clone_workspace(registry, xml_parent, data):
if 'criteria' in data and criteria not in criteria_list:
raise JenkinsJobsException(
'clone-workspace criteria must be one of: '
+ ', '.join(criteria_list))
'clone-workspace criteria must be one of: ' +
', '.join(criteria_list))
else:
XML.SubElement(cloneworkspace, 'criteria').text = criteria
@ -667,8 +667,8 @@ def clone_workspace(registry, xml_parent, data):
if 'archive-method' in data and archive_method not in archive_list:
raise JenkinsJobsException(
'clone-workspace archive-method must be one of: '
+ ', '.join(archive_list))
'clone-workspace archive-method must be one of: ' +
', '.join(archive_list))
else:
XML.SubElement(cloneworkspace, 'archiveMethod').text = archive_method
@ -2083,8 +2083,8 @@ def claim_build(registry, xml_parent, data):
def base_email_ext(registry, xml_parent, data, ttype):
trigger = XML.SubElement(xml_parent,
'hudson.plugins.emailext.plugins.trigger.'
+ ttype)
'hudson.plugins.emailext.plugins.trigger.' +
ttype)
email = XML.SubElement(trigger, 'email')
XML.SubElement(email, 'recipientList').text = ''
XML.SubElement(email, 'subject').text = '$PROJECT_DEFAULT_SUBJECT'
@ -4033,8 +4033,8 @@ def postbuildscript(registry, xml_parent, data):
for shell_script in script_data:
script_xml = XML.SubElement(
scripts_xml,
'org.jenkinsci.plugins.postbuildscript.'
+ script_types[step])
'org.jenkinsci.plugins.postbuildscript.' +
script_types[step])
file_path_xml = XML.SubElement(script_xml, 'filePath')
file_path_xml.text = shell_script

View File

@ -153,9 +153,9 @@ def build_gerrit_triggers(xml_parent, data):
"format instead.", event)
if not tag_name:
known = ', '.join(available_simple_triggers.keys()
+ ['comment-added-event',
'comment-added-contains-event'])
known = ', '.join(available_simple_triggers.keys() +
['comment-added-event',
'comment-added-contains-event'])
msg = ("The event '%s' under 'trigger-on' is not one of the "
"known: %s.") % (event, known)
raise JenkinsJobsException(msg)
@ -880,8 +880,8 @@ def jms_messaging(registry, xml_parent, data):
if len(checks) > 0:
msgchecks = XML.SubElement(jmsm, 'checks')
for check in checks:
msgcheck = XML.SubElement(msgchecks, namespace
+ 'messaging.checks.MsgCheck')
msgcheck = XML.SubElement(msgchecks, namespace +
'messaging.checks.MsgCheck')
mapping = [
('field', 'field', ''),
('expected-value', 'expectedValue', '')]

View File

@ -21,6 +21,7 @@ http://docs.openstack.org/infra/zuul/launchers.html#zuul-parameters
"""
import itertools
import jenkins_jobs.modules.base
def zuul():
@ -55,7 +56,6 @@ def zuul_post():
- zuul-post
"""
import jenkins_jobs.modules.base
ZUUL_PARAMETERS = [
{'string':

View File

@ -99,8 +99,8 @@ class YamlParser(object):
if not hasattr(path, 'read') and os.path.isdir(path):
files_to_process.extend([os.path.join(path, f)
for f in sorted(os.listdir(path))
if (f.endswith('.yml')
or f.endswith('.yaml'))])
if (f.endswith('.yml') or
f.endswith('.yaml'))])
else:
files_to_process.append(path)

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking<0.13,>=0.12.0 # Apache-2.0
hacking>=1.1.0 # Apache-2.0
coverage>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD

View File

@ -251,7 +251,7 @@ class TestJenkinsGetPluginInfoError(CmdTestsBase):
self.execute_jenkins_jobs_with_args(args)
except jenkins.JenkinsException:
self.fail("jenkins.JenkinsException propagated to main")
except:
except Exception:
pass # only care about jenkins.JenkinsException for now
@mock.patch('jenkins.Jenkins.get_plugins')