Cleanup various deprecation warnings.

Change-Id: Iec16a5965d62bebb50d3e7307ab93c59304a9ab6
This commit is contained in:
Wayne Warren 2016-01-03 21:22:40 -08:00 committed by Thanh Ha
parent 0a8928f51a
commit c80e3bc5e9
No known key found for this signature in database
GPG Key ID: B0CB27E00DA095AA
12 changed files with 81 additions and 64 deletions

View File

@ -193,9 +193,10 @@ class Jenkins(object):
plugins_list = self.jenkins.get_plugins_info()
except jenkins.JenkinsException as e:
if re.search("Connection refused", str(e)):
logger.warn("Unable to retrieve Jenkins Plugin Info from {0},"
" using default empty plugins info list.".format(
self.jenkins.server))
logger.warning(
"Unable to retrieve Jenkins Plugin Info from {0},"
" using default empty plugins info list.".format(
self.jenkins.server))
plugins_list = [{'shortName': '',
'version': '',
'longName': ''}]

View File

@ -21,6 +21,7 @@ import logging
import os
from six.moves import configparser, StringIO
from six import PY2
from jenkins_jobs import builder
from jenkins_jobs.errors import JJBConfigException
@ -116,7 +117,10 @@ class JJBConfig(object):
"config values.".format(conf))
if config_fp is not None:
config_parser.readfp(config_fp)
if PY2:
config_parser.readfp(config_fp)
else:
config_parser.read_file(config_fp)
self.config_parser = config_parser
@ -140,7 +144,10 @@ class JJBConfig(object):
"""
config = configparser.ConfigParser()
# Load default config always
config.readfp(StringIO(DEFAULT_CONF))
if PY2:
config.readfp(StringIO(DEFAULT_CONF))
else:
config.read_file(StringIO(DEFAULT_CONF))
return config
def _read_config_file(self, config_filename):

View File

@ -300,8 +300,8 @@ class DeprecatedTag(BaseYAMLObject):
@classmethod
def from_yaml(cls, loader, node):
logger.warn("tag '%s' is deprecated, switch to using '%s'",
cls.yaml_tag, cls._new.yaml_tag)
logger.warning("tag '%s' is deprecated, switch to using '%s'",
cls.yaml_tag, cls._new.yaml_tag)
return cls._new.from_yaml(loader, node)

View File

@ -2618,13 +2618,14 @@ def dsl(registry, xml_parent, data):
if 'target' in data:
if 'targets' not in data:
logger.warn("Converting from old format of 'target' to new "
"name 'targets', please update your job definitions.")
logger.warning("Converting from old format of 'target' to new "
"name 'targets', please update your job "
"definitions.")
data['targets'] = data['target']
else:
logger.warn("Ignoring old argument 'target' in favour of new "
"format argument 'targets', please remove old "
"format.")
logger.warning("Ignoring old argument 'target' in favour of new "
"format argument 'targets', please remove old "
"format.")
if data.get('script-text'):
XML.SubElement(dsl, 'scriptText').text = data.get('script-text')

View File

@ -173,9 +173,9 @@ class General(jenkins_jobs.modules.base.Base):
if 'logrotate' in data:
if not self.logrotate_warn_issued:
logging.warn('logrotate is deprecated on jenkins>=1.637, use '
'the property build-discarder on newer jenkins '
'instead')
logging.warning('logrotate is deprecated on jenkins>=1.637,'
' the property build-discarder on newer'
' jenkins instead')
self.logrotate_warn_issued = True
lr_xml = XML.SubElement(xml, 'logRotator')

View File

@ -126,10 +126,10 @@ class HipChat(jenkins_jobs.modules.base.Base):
# convert for compatibility before dispatch
if 'room' in hipchat:
if 'rooms' in hipchat:
logger.warn("Ignoring deprecated 'room' as 'rooms' also "
"defined.")
logger.warning("Ignoring deprecated 'room' as 'rooms' also "
"defined.")
else:
logger.warn("'room' is deprecated, please use 'rooms'")
logger.warning("'room' is deprecated, please use 'rooms'")
hipchat['rooms'] = [hipchat['room']]
plugin_info = self.registry.get_plugin_info("Jenkins HipChat Plugin")
@ -140,7 +140,7 @@ class HipChat(jenkins_jobs.modules.base.Base):
if publishers is None:
publishers = XML.SubElement(xml_parent, 'publishers')
logger.warn(
logger.warning(
"'hipchat' module supports the old plugin versions <1.9, "
"newer versions are supported via the 'publishers' module. "
"Please upgrade you job definition")
@ -160,8 +160,8 @@ class HipChat(jenkins_jobs.modules.base.Base):
# Handle backwards compatibility 'start-notify' but all add an element
# of standardization with notify-*
if hipchat.get('start-notify'):
logger.warn("'start-notify' is deprecated, please use "
"'notify-start'")
logger.warning("'start-notify' is deprecated, please use "
"'notify-start'")
XML.SubElement(pdefhip, 'startNotification').text = str(
hipchat.get('notify-start', hipchat.get('start-notify',
False))).lower()

View File

@ -73,7 +73,7 @@ def archive(registry, xml_parent, data):
# backward compatibility
latest_only = data.get('latest_only', False)
if 'latest_only' in data:
logger.warn('latest_only is deprecated please use latest-only')
logger.warning('latest_only is deprecated please use latest-only')
if 'latest-only' in data:
latest_only = data['latest-only']
if latest_only:
@ -464,7 +464,7 @@ def trigger_parameterized_builds(registry, xml_parent, data):
pass
if orig_order:
logger.warn(
logger.warning(
"Using deprecated order for parameter sets in "
"triggered-parameterized-builds. This will be changed in a future "
"release to inherit the order from the user defined yaml. To "
@ -493,7 +493,7 @@ def trigger_parameterized_builds(registry, xml_parent, data):
properties.text = param_value
elif param_type == 'git-revision' and param_value:
if 'combine-queued-commits' in project_def:
logger.warn(
logger.warning(
"'combine-queued-commit' has moved to reside under "
"'git-revision' configuration, please update your "
"configs as support for this will be removed."
@ -808,7 +808,7 @@ def coverage(registry, xml_parent, data):
:language: yaml
"""
logger = logging.getLogger(__name__)
logger.warn("Coverage function is deprecated. Switch to cobertura.")
logger.warning("Coverage function is deprecated. Switch to cobertura.")
cobertura = XML.SubElement(xml_parent,
'hudson.plugins.cobertura.CoberturaPublisher')
@ -1301,8 +1301,8 @@ def xunit(registry, xml_parent, data):
for configured_type in data['types']:
type_name = next(iter(configured_type.keys()))
if type_name not in implemented_types:
logger.warn("Requested xUnit type '%s' is not yet supported",
type_name)
logger.warning("Requested xUnit type '%s' is not yet supported",
type_name)
else:
# Append for generation
supported_types.append(configured_type)
@ -1329,7 +1329,7 @@ def xunit(registry, xml_parent, data):
xmlthresholds = XML.SubElement(xunit, 'thresholds')
for t in data.get('thresholds', []):
if not ('failed' in t or 'skipped' in t):
logger.warn(
logger.warning(
"Unrecognized threshold, should be 'failed' or 'skipped'")
continue
elname = ("org.jenkinsci.plugins.xunit.threshold.%sThreshold" %
@ -2268,8 +2268,8 @@ def groovy_postbuild(registry, xml_parent, data):
logger = logging.getLogger("%s:groovy-postbuild" % __name__)
# Backward compatibility with old format
if isinstance(data, six.string_types):
logger.warn(
"You use deprecated configuration, please follow documentation "
logger.warning(
"You use depricated configuration, please follow documentation "
"to change configuration. It is not going to be supported in "
"future releases!"
)
@ -4318,12 +4318,12 @@ def doxygen(registry, xml_parent, data):
if 'keep-all' in data:
XML.SubElement(p, 'keepAll').text = str(
data.get('keep-all', False)).lower()
logger.warn("The value of 'keepall' will be ignored "
"in preference to 'keep-all'.")
logger.warning("The value of 'keepall' will be ignored "
"in preference to 'keep-all'.")
else:
XML.SubElement(p, 'keepAll').text = str(
data.get('keepall', False)).lower()
logger.warn("'keepall' is deprecated please use 'keep-all'")
logger.warning("'keepall' is deprecated please use 'keep-all'")
else:
XML.SubElement(p, 'keepAll').text = str(
data.get('keep-all', False)).lower()
@ -6222,7 +6222,7 @@ def slack(registry, xml_parent, data):
for yaml_name, _, _ in mapping_20:
if yaml_name in data:
logger.warn(
logger.warning(
"'%s' is invalid with plugin version < 2.0, ignored",
yaml_name,
)

View File

@ -264,10 +264,11 @@ def git(registry, xml_parent, data):
submodule_cfgs = ['disable-submodules', 'recursive-submodules']
if optname in submodule_cfgs:
if optname in data:
logger.warn("'{0}' is deprecated, please convert to use the "
"'submodule' section instead as support for this "
"top level option will be removed in a future "
"release.".format(optname))
logger.warning(
"'{0}' is deprecated, please convert to use the "
"'submodule' section instead as support for this "
"top level option will be removed in a future "
"release.".format(optname))
if 'submodule' in data:
continue
@ -312,9 +313,10 @@ def git(registry, xml_parent, data):
if isinstance(data['clean'], bool):
clean_after = data['clean']
clean_before = False
logger.warn("'clean: bool' configuration format is deprecated, "
"please use the extension style format to configure "
"this option.")
logger.warning(
"'clean: bool' configuration format is deprecated, "
"please use the extension style format to configure "
"this option.")
else:
clean_after = data['clean'].get('after', False)
clean_before = data['clean'].get('before', False)

View File

@ -59,8 +59,9 @@ def gerrit_handle_legacy_configuration(data):
for old_key in old_keys:
if old_key in d:
new_key = hyphenize(old_key)
logger.warn("'%s' is deprecated and will be removed after "
"1.0.0, please use '%s' instead", old_key, new_key)
logger.warning(
"'%s' is deprecated and will be removed after "
"1.0.0, please use '%s' instead", old_key, new_key)
d[new_key] = d[old_key]
del d[old_key]
@ -96,9 +97,10 @@ def gerrit_handle_legacy_configuration(data):
if key.startswith('trigger-on-'))
trigger_on = data.setdefault('trigger-on', [])
if old_format_events:
logger.warn("The events: %s; which you used is/are deprecated. "
"Please use 'trigger-on' instead.",
', '.join(old_format_events))
logger.warning(
"The events: %s; which you used is/are deprecated. "
"Please use 'trigger-on' instead.",
', '.join(old_format_events))
if old_format_events and trigger_on:
raise JenkinsJobsException(
@ -145,8 +147,9 @@ def build_gerrit_triggers(xml_parent, data):
if isinstance(event, six.string_types):
tag_name = available_simple_triggers.get(event)
if event == 'patchset-uploaded-event':
logger.warn("'%s' is deprecated. Use 'patchset-created-event' "
"format instead.", event)
logger.warning(
"'%s' is deprecated. Use 'patchset-created-event' "
"format instead.", event)
if not tag_name:
known = ', '.join(available_simple_triggers.keys()
@ -489,7 +492,7 @@ def gerrit(registry, xml_parent, data):
'branches section'
else:
warning += 'please use branches section instead'
logger.warn(warning)
logger.warning(warning)
if not project_branches:
project_branches = [
{'branch-compare-type': project.get(
@ -644,9 +647,10 @@ def pollscm(registry, xml_parent, data):
raise MissingAttributeError(e)
except TypeError:
# To keep backward compatibility
logger.warn("Your pollscm usage is deprecated, please use"
" the syntax described in the documentation"
" instead")
logger.warning(
"Your pollscm usage is deprecated, please use"
" the syntax described in the documentation"
" instead")
cron = data
ipch = 'false'

View File

@ -831,8 +831,9 @@ def port_allocator(registry, xml_parent, data):
names = data.get('names')
if not names:
logger = logging.getLogger(__name__)
logger.warn('port_allocator name is deprecated, use a names list '
' instead')
logger.warning(
'port_allocator name is deprecated, use a names list '
' instead')
names = [data['name']]
for name in names:
dpt = XML.SubElement(ports,
@ -1642,12 +1643,13 @@ def ssh_agent_credentials(registry, xml_parent, data):
entry_xml = XML.SubElement(entry_xml, 'credentialIds')
xml_key = 'string'
if 'user' in data:
logger.warn("Both 'users' and 'user' parameters specified for "
"ssh-agent-credentials. 'users' is used, 'user' is "
"ignored.")
logger.warning(
"Both 'users' and 'user' parameters specified for "
"ssh-agent-credentials. 'users' is used, 'user' is "
"ignored.")
elif 'user' in data:
logger.warn("The 'user' param has been deprecated, "
"use the 'users' param instead.")
logger.warning("The 'user' param has been deprecated, "
"use the 'users' param instead.")
user_list.append(data['user'])
else:
raise JenkinsJobsException("Missing 'user' or 'users' parameter "

View File

@ -167,7 +167,7 @@ class YamlParser(object):
logger.error(message)
raise JenkinsJobsException(message)
else:
logger.warn(message)
logger.warning(message)
def _getJob(self, name):
job = self.data.get('job', {}).get(name, None)

View File

@ -228,11 +228,11 @@ class ModuleRegistry(object):
component = self.parser_data.get(component_type, {}).get(name)
if component:
if name in eps and name not in self.masked_warned:
# Warn only once for each macro
self.masked_warned[name] = True
logger.warn("You have a macro ('%s') defined for '%s' "
"component type that is masking an inbuilt "
"definition" % (name, component_type))
logger.warning(
"You have a macro ('%s') defined for '%s' "
"component type that is masking an inbuilt "
"definition" % (name, component_type))
for b in component[component_list_type]:
# Pass component_data in as template data to this function