diff --git a/Bio/Entrez/__init__.py b/Bio/Entrez/__init__.py index 815daf824a5..cc6e7119e75 100644 --- a/Bio/Entrez/__init__.py +++ b/Bio/Entrez/__init__.py @@ -47,9 +47,8 @@ _open Internally used function. """ -import urllib, time, warnings +import urllib, urllib2, time, warnings import os.path -from Bio import File email = None @@ -73,7 +72,7 @@ def epost(db, **keywds): cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi' variables = {'db' : db} variables.update(keywds) - return _open(cgi, variables, post=True) + return _open(cgi, variables, post=False) def efetch(db, **keywds): """Fetches Entrez results which are returned as a handle. @@ -316,67 +315,17 @@ def _open(cgi, params={}, post=False): E-utilities.""", UserWarning) # Open a handle to Entrez. options = urllib.urlencode(params, doseq=True) - if post: - #HTTP POST - handle = urllib.urlopen(cgi, data=options) - else: - #HTTP GET - cgi += "?" + options - handle = urllib.urlopen(cgi) - - # Wrap the handle inside an UndoHandle. - uhandle = File.UndoHandle(handle) - - # Check for errors in the first 7 lines. - # This is kind of ugly. - lines = [] - for i in range(7): - lines.append(uhandle.readline()) - for i in range(6, -1, -1): - uhandle.saveline(lines[i]) - try: - data = ''.join(lines) - except TypeError: - #On Python 3 the lines will be bytes not unicode strings... - data = ''.join(x.decode() for x in lines) - #Note that this doesn't alter the nature of the UndoHandle this - #function will return to the caller (it will still be using bytes) - - if "500 Proxy Error" in data: - # Sometimes Entrez returns a Proxy Error instead of results - raise IOError("500 Proxy Error (NCBI busy?)") - elif "502 Proxy Error" in data: - raise IOError("502 Proxy Error (NCBI busy?)") - elif "WWW Error 500 Diagnostic" in data: - raise IOError("WWW Error 500 Diagnostic (NCBI busy?)") - elif "