mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-08 17:29:11 -07:00
Some Python-3 module_utils support
This commit is contained in:
parent
9a69354b6a
commit
0cb05d8ac9
3 changed files with 624 additions and 15 deletions
|
@ -219,6 +219,9 @@ except ImportError:
|
|||
|
||||
_literal_eval = literal_eval
|
||||
|
||||
# Backwards compat. There were present in basic.py before
|
||||
from ansible.module_utils.pycompat import get_exception
|
||||
|
||||
# Internal global holding passed in params and constants. This is consulted
|
||||
# in case multiple AnsibleModules are created. Otherwise each AnsibleModule
|
||||
# would attempt to read from stdin. Other code should not use this directly
|
||||
|
@ -253,21 +256,6 @@ EXEC_PERM_BITS = int('00111', 8) # execute permission bits
|
|||
DEFAULT_PERM = int('0666', 8) # default file permission bits
|
||||
|
||||
|
||||
def get_exception():
|
||||
"""Get the current exception.
|
||||
|
||||
This code needs to work on Python 2.4 through 3.x, so we cannot use
|
||||
"except Exception, e:" (SyntaxError on Python 3.x) nor
|
||||
"except Exception as e:" (SyntaxError on Python 2.4-2.5).
|
||||
Instead we must use ::
|
||||
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
|
||||
"""
|
||||
return sys.exc_info()[1]
|
||||
|
||||
|
||||
def get_platform():
|
||||
''' what's the platform? example: Linux is a platform. '''
|
||||
return platform.system()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue