be explicit about urllib import and remove conditional urllib(2) import

urllib and urllib2 have been in the python stdlib since at least
python-2.3.  There's no reason to conditionalize it.

Fixes https://github.com/ansible/ansible/issues/11322
This commit is contained in:
Toshio Kuratomi 2015-06-19 08:59:19 -07:00 committed by Matt Clay
parent 655fa27dc7
commit 16bd2c7357
11 changed files with 23 additions and 20 deletions

View file

@ -61,8 +61,7 @@ options:
default: 'yes' default: 'yes'
choices: ['yes', 'no'] choices: ['yes', 'no']
# informational: requirements for nodes requirements: []
requirements: [ urllib, urllib2 ]
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -72,6 +71,8 @@ EXAMPLES = '''
revision=4.2 revision=4.2
''' '''
import urllib
# =========================================== # ===========================================
# Module execution. # Module execution.
# #

View file

@ -72,8 +72,7 @@ options:
choices: ['yes', 'no'] choices: ['yes', 'no']
version_added: 1.5.1 version_added: 1.5.1
# informational: requirements for nodes requirements: []
requirements: [ urllib, urllib2 ]
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -83,6 +82,8 @@ EXAMPLES = '''
revision=1.0 revision=1.0
''' '''
import urllib
# =========================================== # ===========================================
# Module execution. # Module execution.
# #

View file

@ -76,6 +76,7 @@ EXAMPLES = '''
comment='Test Deploy' comment='Test Deploy'
''' '''
import urllib
def main(): def main():

View file

@ -81,7 +81,7 @@ options:
default: 'yes' default: 'yes'
choices: ['yes', 'no'] choices: ['yes', 'no']
requirements: [ "urllib", "urllib2" ] requirements: []
author: "Nandor Sivok (@dominis)" author: "Nandor Sivok (@dominis)"
''' '''
@ -99,7 +99,7 @@ ansible host -m netscaler -a "nsc_host=nsc.example.com user=apiuser password=api
import base64 import base64
import socket import socket
import urllib
class netscaler(object): class netscaler(object):

View file

@ -86,8 +86,8 @@ notes:
- The DNS Made Easy service requires that machines interacting with the API have the proper time and timezone set. Be sure you are within a few seconds of actual time by using NTP. - The DNS Made Easy service requires that machines interacting with the API have the proper time and timezone set. Be sure you are within a few seconds of actual time by using NTP.
- This module returns record(s) in the "result" element when 'state' is set to 'present'. This value can be be registered and used in your playbooks. - This module returns record(s) in the "result" element when 'state' is set to 'present'. This value can be be registered and used in your playbooks.
requirements: [ urllib, urllib2, hashlib, hmac ] requirements: [ hashlib, hmac ]
author: Brice Burgess author: "Brice Burgess (@briceburg)"
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -113,6 +113,8 @@ EXAMPLES = '''
# DNSMadeEasy module specific support methods. # DNSMadeEasy module specific support methods.
# #
import urllib
IMPORT_ERROR = None IMPORT_ERROR = None
try: try:
import json import json

View file

@ -85,8 +85,7 @@ options:
choices: ['yes', 'no'] choices: ['yes', 'no']
version_added: 1.5.1 version_added: 1.5.1
# informational: requirements for nodes requirements: [ ]
requirements: [ urllib, urllib2 ]
''' '''
EXAMPLES = ''' EXAMPLES = '''
@ -104,6 +103,8 @@ EXAMPLES = '''
tags=tag1,tag2,tag3 tags=tag1,tag2,tag3
''' '''
import urllib
# =========================================== # ===========================================
# Module execution. # Module execution.
# #

View file

@ -49,6 +49,8 @@ EXAMPLES = '''
message=deployed {{ target }} message=deployed {{ target }}
''' '''
import urllib
BASE_URL = 'https://grove.io/api/notice/%s/' BASE_URL = 'https://grove.io/api/notice/%s/'
# ============================================================== # ==============================================================

View file

@ -62,8 +62,7 @@ options:
version_added: 1.6.0 version_added: 1.6.0
# informational: requirements for nodes requirements: [ ]
requirements: [ urllib, urllib2 ]
author: "WAKAYAMA Shirou (@shirou), BOURDEL Paul (@pb8226)" author: "WAKAYAMA Shirou (@shirou), BOURDEL Paul (@pb8226)"
''' '''
@ -76,6 +75,7 @@ EXAMPLES = '''
# #
MSG_URI = "https://api.hipchat.com/v1/rooms/message" MSG_URI = "https://api.hipchat.com/v1/rooms/message"
import urllib
def send_msg(module, token, room, msg_from, msg, msg_format='text', def send_msg(module, token, room, msg_from, msg, msg_format='text',
color='yellow', notify=False, api=MSG_URI): color='yellow', notify=False, api=MSG_URI):

View file

@ -71,6 +71,7 @@ EXAMPLES = """
msg: "{{ inventory_hostname }} completed" msg: "{{ inventory_hostname }} completed"
""" """
import urllib
NEXMO_API = 'https://rest.nexmo.com/sms/json' NEXMO_API = 'https://rest.nexmo.com/sms/json'

View file

@ -84,10 +84,7 @@ EXAMPLES = '''
# ======================================= # =======================================
# sendgrid module support methods # sendgrid module support methods
# #
try: import urllib, urllib2
import urllib, urllib2
except ImportError:
module.fail_json(msg="urllib and urllib2 are required")
import base64 import base64

View file

@ -104,10 +104,7 @@ EXAMPLES = '''
# ======================================= # =======================================
# twilio module support methods # twilio module support methods
# #
try: import urllib, urllib2
import urllib, urllib2
except ImportError:
module.fail_json(msg="urllib and urllib2 are required")
import base64 import base64