Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
a54b8764
Commit
a54b8764
authored
May 19, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reset locale to 'C' if the specified one is invalid
Fixes #7448
parent
6b4584d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
lib/ansible/module_utils/basic.py
+21
-0
No files found.
lib/ansible/module_utils/basic.py
View file @
a54b8764
...
@@ -43,6 +43,7 @@ BOOLEANS = BOOLEANS_TRUE + BOOLEANS_FALSE
...
@@ -43,6 +43,7 @@ BOOLEANS = BOOLEANS_TRUE + BOOLEANS_FALSE
# of an ansible module. The source of this common code lives
# of an ansible module. The source of this common code lives
# in lib/ansible/module_common.py
# in lib/ansible/module_common.py
import
locale
import
os
import
os
import
re
import
re
import
pipes
import
pipes
...
@@ -191,6 +192,10 @@ class AnsibleModule(object):
...
@@ -191,6 +192,10 @@ class AnsibleModule(object):
if
k
not
in
self
.
argument_spec
:
if
k
not
in
self
.
argument_spec
:
self
.
argument_spec
[
k
]
=
v
self
.
argument_spec
[
k
]
=
v
# check the locale as set by the current environment, and
# reset to LANG=C if it's an invalid/unavailable locale
self
.
_check_locale
()
(
self
.
params
,
self
.
args
)
=
self
.
_load_params
()
(
self
.
params
,
self
.
args
)
=
self
.
_load_params
()
self
.
_legal_inputs
=
[
'CHECKMODE'
,
'NO_LOG'
]
self
.
_legal_inputs
=
[
'CHECKMODE'
,
'NO_LOG'
]
...
@@ -561,6 +566,22 @@ class AnsibleModule(object):
...
@@ -561,6 +566,22 @@ class AnsibleModule(object):
kwargs
[
'state'
]
=
'absent'
kwargs
[
'state'
]
=
'absent'
return
kwargs
return
kwargs
def
_check_locale
(
self
):
'''
Uses the locale module to test the currently set locale
(per the LANG and LC_CTYPE environment settings)
'''
try
:
# setting the locale to '' uses the default locale
# as it would be returned by locale.getdefaultlocale()
locale
.
setlocale
(
locale
.
LC_ALL
,
''
)
except
locale
.
Error
,
e
:
# fallback to the 'C' locale, which may cause unicode
# issues but is preferable to simply failing because
# of an unknown locale
locale
.
setlocale
(
locale
.
LC_ALL
,
'C'
)
except
Exception
,
e
:
self
.
fail_json
(
msg
=
"An unknown error was encountered while attempting to validate the locale:
%
s"
%
e
)
def
_handle_aliases
(
self
):
def
_handle_aliases
(
self
):
aliases_results
=
{}
#alias:canon
aliases_results
=
{}
#alias:canon
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment