diff --git a/jenkins_jobs/cli/entry.py b/jenkins_jobs/cli/entry.py index 7ba9618b4..484b7a3d6 100644 --- a/jenkins_jobs/cli/entry.py +++ b/jenkins_jobs/cli/entry.py @@ -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() diff --git a/jenkins_jobs/local_yaml.py b/jenkins_jobs/local_yaml.py index a55587b97..3af772f28 100644 --- a/jenkins_jobs/local_yaml.py +++ b/jenkins_jobs/local_yaml.py @@ -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 diff --git a/jenkins_jobs/modules/parameters.py b/jenkins_jobs/modules/parameters.py index 957320614..f475546bc 100644 --- a/jenkins_jobs/modules/parameters.py +++ b/jenkins_jobs/modules/parameters.py @@ -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) diff --git a/jenkins_jobs/modules/project_matrix.py b/jenkins_jobs/modules/project_matrix.py index 89633e75e..a96b7f00a 100644 --- a/jenkins_jobs/modules/project_matrix.py +++ b/jenkins_jobs/modules/project_matrix.py @@ -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: diff --git a/jenkins_jobs/modules/publishers.py b/jenkins_jobs/modules/publishers.py index 0fbfad9a3..1da0e0957 100644 --- a/jenkins_jobs/modules/publishers.py +++ b/jenkins_jobs/modules/publishers.py @@ -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 diff --git a/jenkins_jobs/modules/triggers.py b/jenkins_jobs/modules/triggers.py index fca9bfbf6..1fd24e6e3 100644 --- a/jenkins_jobs/modules/triggers.py +++ b/jenkins_jobs/modules/triggers.py @@ -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', '')] diff --git a/jenkins_jobs/modules/zuul.py b/jenkins_jobs/modules/zuul.py index 224412ae2..c4f4857a1 100644 --- a/jenkins_jobs/modules/zuul.py +++ b/jenkins_jobs/modules/zuul.py @@ -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': diff --git a/jenkins_jobs/parser.py b/jenkins_jobs/parser.py index 8be0823a8..f1b67c061 100644 --- a/jenkins_jobs/parser.py +++ b/jenkins_jobs/parser.py @@ -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) diff --git a/test-requirements.txt b/test-requirements.txt index 21866f2c9..0869b2c4e 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -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 diff --git a/tests/cmd/subcommands/test_test.py b/tests/cmd/subcommands/test_test.py index 78403ffa3..0ac06d4a9 100644 --- a/tests/cmd/subcommands/test_test.py +++ b/tests/cmd/subcommands/test_test.py @@ -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')