Getting 504 error when trying to parse some text with tika in python - python

Some weeks ago I had tika-python working without any issue in Windows 10. Today I had to re-create my virtualenv and upgraded tika to version 1.19 but when I tried to use it as usual and I got 502 and 504 errors all the time.
I tried to use it in ubuntu18.04 and with previous tika versions and nothing changed.
Can anyone help?
(I'm not a native english speaker so sorry if my english is not very good)
parsed_data = parser.from_buffer(buffer)
2019-05-25 20:40:42,446 [MainThread ] [INFO ] Retrieving http://search.maven.org/remotecontent?filepath=org/apache/tika/tika-server/1.15/tika-server-1.15.jar.md5 to /tmp/tika-server.jar.md5.
Traceback (most recent call last):
File "/home/ohm/Documentos/TFG/venv/lib/python3.7/site-packages/tika/tika.py", line 651, in getRemoteJar
urlretrieve(urlOrPath, destPath)
File "/usr/lib/python3.7/urllib/request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.7/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.7/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 504: Gateway Time-out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ohm/Documentos/TFG/venv/lib/python3.7/site-packages/tika/parser.py", line 51, in from_buffer
{'Accept': 'application/json'}, False)
File "/home/ohm/Documentos/TFG/venv/lib/python3.7/site-packages/tika/tika.py", line 506, in callServer
serverEndpoint = checkTikaServer(scheme, serverHost, port, tikaServerJar, classpath)
File "/home/ohm/Documentos/TFG/venv/lib/python3.7/site-packages/tika/tika.py", line 557, in checkTikaServer
if not checkJarSig(tikaServerJar, jarPath):
File "/home/ohm/Documentos/TFG/venv/lib/python3.7/site-packages/tika/tika.py", line 572, in checkJarSig
getRemoteJar(tikaServerJar + ".md5", jarPath + ".md5")
File "/home/ohm/Documentos/TFG/venv/lib/python3.7/site-packages/tika/tika.py", line 661, in getRemoteJar
urlretrieve(urlOrPath, destPath)
File "/usr/lib/python3.7/urllib/request.py", line 247, in urlretrieve
with contextlib.closing(urlopen(url, data)) as fp:
File "/usr/lib/python3.7/urllib/request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib/python3.7/urllib/request.py", line 531, in open
response = meth(req, response)
File "/usr/lib/python3.7/urllib/request.py", line 641, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python3.7/urllib/request.py", line 569, in error
return self._call_chain(*args)
File "/usr/lib/python3.7/urllib/request.py", line 503, in _call_chain
result = func(*args)
File "/usr/lib/python3.7/urllib/request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPErr: HTTP Error 502: Bad Gateway

Related

python: urllib.request.urlopen() HTTP Error 308 Permanent redirect

i was just trying to read a file from the internet..
then an error came..
Traceback (most recent call last):
File "E:\Sapphire\Programming\download_file.py", line 46, in <module>
download(arg[1])
File "E:\Sapphire\Programming\download_file.py", line 19, in download
file_info = req.urlopen("http://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))
File "E:\Programming\Python38-32\lib\urllib\request.py", line 222, in urlopen
return opener.open(url, data, timeout)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 531, in open
response = meth(req, response)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 640, in http_response
response = self.parent.error(
File "E:\Programming\Python38-32\lib\urllib\request.py", line 569, in error
return self._call_chain(*args)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 502, in _call_chain
result = func(*args)
File "E:\Programming\Python38-32\lib\urllib\request.py", line 649, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 308: Permanent Redirect
the line that brought the error (line 20):
file_info = req.urlopen("http://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))
(the link that it should use is correct..)
any ideas how it came?
SPECS:
OS: Windows 7 SP1
Python: Python 3.8.10
Arch: x86 (32-bit)
Http is outdated, so most sites would redirect to https.
So use
file_info = req.urlopen("https://proget.whirlpool.repl.co/{}/{}.txt".format(arch, name))

yahoo_finance api throws 404. urllib2.HTTPError: HTTP Error 400: Bad Request

$ pip install yahoo-finance
$ python
Then in python console,
>>> from yahoo_finance import Share
>>> yahoo = Share('YHOO')
Traceback (most recent call last): File "", line 1, in File
"/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 178, in init
self.refresh() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 142, in refresh
self.data_set = self._fetch() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 181, in _fetch
data = super(Share, self)._fetch() File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 134, in _fetch
data = self._request(query) File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/init.py",
line 118, in _request
response = yql.YQLQuery().execute(query) File "/Users/ishandutta2007/virtualenvironment/googlfin/lib/python2.7/site-packages/yahoo_finance/yql.py",
line 61, in execute
'env': DATATABLES_URL File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 435, in open
response = meth(req, response) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 473, in error
return self._call_chain(*args) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 407, in _call_chain
result = func(*args) File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) urllib2.HTTPError: HTTP Error 400: Bad Request

python jenkins api quiet_down() not working

I am trying to send quiet_down() using python-jenkins api but I get the following messages and the server doesn't go into shutdown mode.
import jenkins
server = jenkins.Jenkins('serveraddress', username='someuser', password='somepassword')
server.quiet_down()
Traceback (most recent call last):
File "", line 1, in
File "C:\Python27\lib\site-packages\jenkins__init__.py", line 1642, in quiet_
down
self.jenkins_open(request)
File "C:\Python27\lib\site-packages\jenkins__init__.py", line 431, in jenkins
_open
response = urlopen(req, timeout=self.timeout).read()
File "C:\Python27\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 435, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 548, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python27\lib\urllib2.py", line 473, in error
return self._call_chain(*args)
File "C:\Python27\lib\urllib2.py", line 407, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 556, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 405: Method Not Allowed
I have checked and I'm being authenticated correctly and I do have all the rights on it. Jenkins version is 2.7.4.
Any help would be appreciated.
Thanks.

amazon product api returning HTTP Error 400: Bad Request

I've access data using the amazon product API before and that was easy. All I had to do was make some api keys and use a module in Python and it gave back the data.
however, this was 4-5 months ago and now when I try to use the api keys, its giving me 400 error.
Here is my code
from amazon.api import AmazonAPI
asin = 'B00CAB5ZKC'
AMAZON_ACCESS_KEY='AKIAI4ZP7EZGNSTAWKTA'
AMAZON_SECRET_KEY ='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'
AMAZON_ASSOC_TAG =246152698300
amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG, region = "DE")
product = amazon.lookup(ItemId=asin, Condition='All', MerchantId='All')
This is the error I get
Traceback (most recent call last):
File "C:\Users\Hari\Documents\Python\data\amazon_test_script.py", line 22, in <module>
product = amazon.lookup(ItemId=asin, Condition='All', MerchantId='All')
File "build\bdist.win-amd64\egg\amazon\api.py", line 173, in lookup
response = self.api.ItemLookup(ResponseGroup=ResponseGroup, **kwargs)
File "C:\Python27\lib\site-packages\bottlenose\api.py", line 265, in __call__
{'api_url': api_url, 'cache_url': cache_url})
File "C:\Python27\lib\site-packages\bottlenose\api.py", line 226, in _call_api
return urllib2.urlopen(api_request, timeout=self.Timeout)
File "C:\Python27\lib\urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "C:\Python27\lib\urllib2.py", line 437, in open
response = meth(req, response)
File "C:\Python27\lib\urllib2.py", line 550, in http_response
'http', request, response, code, msg, hdrs)
File "C:\Python27\lib\urllib2.py", line 475, in error
return self._call_chain(*args)
File "C:\Python27\lib\urllib2.py", line 409, in _call_chain
result = func(*args)
File "C:\Python27\lib\urllib2.py", line 558, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
HTTPError: HTTP Error 400: Bad Request
>>>
I've been debugging this for 2 days now, with no success. Could anyone tell me what am I missing.

Jenkins Python API, create_node(), error: 400

I'm setting my jenkins environment and, as part of this process, I need to create a slave node.
Bellow follow the script that is crashing:
import jenkins
server = jenkins.Jenkins('http://localhost:9090')
server.create_node('slave')
Follows the output:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 1156, in create_node
self._build_url(CREATE_NODE, params), b''))
File "/usr/local/lib/python2.7/dist-packages/jenkins/__init__.py", line 341, in jenkins_open
response = urlopen(req, timeout=self.timeout).read()
File "/usr/lib/python2.7/urllib2.py", line 127, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib/python2.7/urllib2.py", line 410, in open
response = meth(req, response)
File "/usr/lib/python2.7/urllib2.py", line 523, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib/python2.7/urllib2.py", line 448, in error
return self._call_chain(*args)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/urllib2.py", line 531, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 400: Bad Request
Use jenkinsapi module,
from jenkinsapi.jenkins import Jenkins
server = Jenkins('http://localhost:9090')
server.create_node('slave')
It appears to be a bug in python-jenkins 0.4.11, which was fixed by commit
302eb5dad6439842e076fead5bd76f20f615e6a8.
I got a similar error, upgrading python-jenkins fixed it.

Categories