mirror of
https://github.com/ansible/awx.git
synced 2026-04-07 02:59:21 -02:30
Merge pull request #10788 from beeankha/fix_sanity_errors_collections
Fix Collections Errors
This commit is contained in:
@@ -72,6 +72,7 @@ from ansible.errors import AnsibleParserError, AnsibleOptionsError
|
|||||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||||
from ansible.config.manager import ensure_type
|
from ansible.config.manager import ensure_type
|
||||||
|
|
||||||
|
from ansible.module_utils.six import raise_from
|
||||||
from ..module_utils.controller_api import ControllerAPIModule
|
from ..module_utils.controller_api import ControllerAPIModule
|
||||||
|
|
||||||
|
|
||||||
@@ -130,9 +131,9 @@ class InventoryModule(BaseInventoryPlugin):
|
|||||||
try:
|
try:
|
||||||
inventory_id = ensure_type(inventory_id, 'str')
|
inventory_id = ensure_type(inventory_id, 'str')
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
raise AnsibleOptionsError(
|
raise_from(AnsibleOptionsError(
|
||||||
'Invalid type for configuration option inventory_id, ' 'not integer, and cannot convert to string: {err}'.format(err=to_native(e))
|
'Invalid type for configuration option inventory_id, ' 'not integer, and cannot convert to string: {err}'.format(err=to_native(e))
|
||||||
) from e
|
), e)
|
||||||
inventory_id = inventory_id.replace('/', '')
|
inventory_id = inventory_id.replace('/', '')
|
||||||
inventory_url = '/api/v2/inventories/{inv_id}/script/'.format(inv_id=inventory_id)
|
inventory_url = '/api/v2/inventories/{inv_id}/script/'.format(inv_id=inventory_id)
|
||||||
|
|
||||||
|
|||||||
@@ -169,7 +169,7 @@ class LookupModule(LookupBase):
|
|||||||
try:
|
try:
|
||||||
rrule_kwargs['dtstart'] = LookupModule.parse_date_time(kwargs['start_date'])
|
rrule_kwargs['dtstart'] = LookupModule.parse_date_time(kwargs['start_date'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleError('Parameter start_date must be in the format YYYY-MM-DD [HH:MM:SS]') from e
|
raise_from(AnsibleError('Parameter start_date must be in the format YYYY-MM-DD [HH:MM:SS]'), e)
|
||||||
|
|
||||||
# If we are a none frequency we don't need anything else
|
# If we are a none frequency we don't need anything else
|
||||||
if frequency == 'none':
|
if frequency == 'none':
|
||||||
@@ -184,7 +184,7 @@ class LookupModule(LookupBase):
|
|||||||
try:
|
try:
|
||||||
rrule_kwargs['until'] = LookupModule.parse_date_time(end_on)
|
rrule_kwargs['until'] = LookupModule.parse_date_time(end_on)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleError('Parameter end_on must either be an integer or in the format YYYY-MM-DD [HH:MM:SS]') from e
|
raise_from(AnsibleError('Parameter end_on must either be an integer or in the format YYYY-MM-DD [HH:MM:SS]'), e)
|
||||||
|
|
||||||
# A week-based frequency can also take the on_days parameter
|
# A week-based frequency can also take the on_days parameter
|
||||||
if frequency == 'week' and 'on_days' in kwargs:
|
if frequency == 'week' and 'on_days' in kwargs:
|
||||||
@@ -208,7 +208,7 @@ class LookupModule(LookupBase):
|
|||||||
if my_month_day < 1 or my_month_day > 31:
|
if my_month_day < 1 or my_month_day > 31:
|
||||||
raise Exception()
|
raise Exception()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleError('month_day_number must be between 1 and 31') from e
|
raise_from(AnsibleError('month_day_number must be between 1 and 31'), e)
|
||||||
|
|
||||||
rrule_kwargs['bymonthday'] = my_month_day
|
rrule_kwargs['bymonthday'] = my_month_day
|
||||||
|
|
||||||
@@ -216,7 +216,7 @@ class LookupModule(LookupBase):
|
|||||||
try:
|
try:
|
||||||
(occurance, weekday) = kwargs['on_the'].split(' ')
|
(occurance, weekday) = kwargs['on_the'].split(' ')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise AnsibleError('on_the parameter must be two words separated by a space') from e
|
raise_from(AnsibleError('on_the parameter must be two words separated by a space'), e)
|
||||||
|
|
||||||
if weekday not in LookupModule.weekdays:
|
if weekday not in LookupModule.weekdays:
|
||||||
raise AnsibleError('Weekday portion of on_the parameter is not valid')
|
raise AnsibleError('Weekday portion of on_the parameter is not valid')
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ from __future__ import absolute_import, division, print_function
|
|||||||
__metaclass__ = type
|
__metaclass__ = type
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
from ansible.module_utils.basic import AnsibleModule, env_fallback
|
||||||
from ansible.module_utils.six import string_types
|
from ansible.module_utils.six import raise_from, string_types
|
||||||
from ansible.module_utils.six.moves import StringIO
|
from ansible.module_utils.six.moves import StringIO
|
||||||
from ansible.module_utils.six.moves.urllib.parse import urlparse, urlencode
|
from ansible.module_utils.six.moves.urllib.parse import urlparse, urlencode
|
||||||
from ansible.module_utils.six.moves.configparser import ConfigParser, NoOptionError
|
from ansible.module_utils.six.moves.configparser import ConfigParser, NoOptionError
|
||||||
@@ -238,10 +238,10 @@ class ControllerModule(AnsibleModule):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ConfigFileException("An unknown exception occured trying to ini load config file: {0}".format(e)) from e
|
raise_from(ConfigFileException("An unknown exception occured trying to ini load config file: {0}".format(e)), e)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise ConfigFileException("An unknown exception occured trying to load config file: {0}".format(e)) from e
|
raise_from(ConfigFileException("An unknown exception occured trying to load config file: {0}".format(e)), e)
|
||||||
|
|
||||||
# If we made it here, we have a dict which has values in it from our config, any final settings logic can be performed here
|
# If we made it here, we have a dict which has values in it from our config, any final settings logic can be performed here
|
||||||
for honorred_setting in self.short_params:
|
for honorred_setting in self.short_params:
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ from requests.models import Response, PreparedRequest
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from ansible.module_utils.six import raise_from
|
||||||
|
|
||||||
from awx.main.tests.functional.conftest import _request
|
from awx.main.tests.functional.conftest import _request
|
||||||
from awx.main.models import Organization, Project, Inventory, JobTemplate, Credential, CredentialType, ExecutionEnvironment, UnifiedJob
|
from awx.main.models import Organization, Project, Inventory, JobTemplate, Credential, CredentialType, ExecutionEnvironment, UnifiedJob
|
||||||
|
|
||||||
@@ -184,7 +186,7 @@ def run_module(request, collection_import):
|
|||||||
try:
|
try:
|
||||||
result = json.loads(module_stdout)
|
result = json.loads(module_stdout)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)) from e
|
raise_from(Exception('Module did not write valid JSON, error: {0}, stdout:\n{1}'.format(str(e), module_stdout)), e)
|
||||||
# A module exception should never be a test expectation
|
# A module exception should never be a test expectation
|
||||||
if 'exception' in result:
|
if 'exception' in result:
|
||||||
if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']:
|
if "ModuleNotFoundError: No module named 'tower_cli'" in result['exception']:
|
||||||
|
|||||||
@@ -47,4 +47,4 @@ def test_create_project_copy_from(run_module, admin_user, organization, silence_
|
|||||||
dict(name=proj_name, copy_from='foo', scm_type='git', wait=False),
|
dict(name=proj_name, copy_from='foo', scm_type='git', wait=False),
|
||||||
admin_user,
|
admin_user,
|
||||||
)
|
)
|
||||||
silence_warning.assert_called_with(f"A project with the name {proj_name} already exists.")
|
silence_warning.assert_called_with("A project with the name {0} already exists.".format(proj_name))
|
||||||
|
|||||||
Reference in New Issue
Block a user