mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Fixed exception handeling for Python 2.4 and python 3 compatablity (#2364)
This commit is contained in:
parent
1b4a458417
commit
2579934ae0
3 changed files with 16 additions and 6 deletions
|
@ -163,6 +163,9 @@ try:
|
|||
except:
|
||||
HAS_GITLAB_PACKAGE = False
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
|
||||
|
||||
class GitLabProject(object):
|
||||
def __init__(self, module, git):
|
||||
|
@ -361,7 +364,8 @@ def main():
|
|||
git.login(user=login_user, password=login_password)
|
||||
else:
|
||||
git = gitlab.Gitlab(server_url, token=login_token, verify_ssl=verify_ssl)
|
||||
except Exception, e:
|
||||
except Exception:
|
||||
e = get_exception()
|
||||
module.fail_json(msg="Failed to connect to Gitlab server: %s " % e)
|
||||
|
||||
# Validate if project exists and take action based on "state"
|
||||
|
@ -391,7 +395,7 @@ def main():
|
|||
else:
|
||||
module.exit_json(changed=False)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue