1 from eventlet import patcher
2 from eventlet.green import socket
3 from eventlet.green import time
4 from eventlet.green import httplib
5 from eventlet.green import ftplib
6 from eventlet.support import six
9 to_patch = [('socket', socket), ('httplib', httplib),
10 ('time', time), ('ftplib', ftplib)]
12 from eventlet.green import ssl
13 to_patch.append(('ssl', ssl))
17 patcher.inject('urllib', globals(), *to_patch)
21 patcher.inject('urllib.request', globals(), *to_patch)
24 # patch a bunch of things that have imports inside the
25 # function body; this is lame and hacky but I don't feel
26 # too bad because urllib is a hacky pile of junk that no
27 # one should be using anyhow
28 URLopener.open_http = patcher.patch_function(URLopener.open_http, ('httplib', httplib))
29 if hasattr(URLopener, 'open_https'):
30 URLopener.open_https = patcher.patch_function(URLopener.open_https, ('httplib', httplib))
32 URLopener.open_ftp = patcher.patch_function(URLopener.open_ftp, ('ftplib', ftplib))
33 ftpwrapper.init = patcher.patch_function(ftpwrapper.init, ('ftplib', ftplib))
34 ftpwrapper.retrfile = patcher.patch_function(ftpwrapper.retrfile, ('ftplib', ftplib))
38 # Run test program when run as a script
39 if __name__ == '__main__':