'NoneType' object has no attribute 'promotePrefixes' - python

So initially I connect to a server with:
soapclient = Client(url, transport=WindowsHttpAuthenticated(username=user, password=passwd))
and this works fine because when I print it it shows all of its properties correctly.
Then I run:
request = self.soapclient.factory.create('ns3:CRRequest')
request['ChangeRequestId'] = '601904'
response = self.soapclient.service.GetChangeRequestById([request])
And then I get an error on the response line which reads:
Traceback (most recent call last):
File "C:\Users\nlujan\Desktop\prism_source.py", line 63, in <module>
CR = prism.getChangeRequestById('601904')
File "C:\Users\nlujan\Desktop\prism_source.py", line 36, in getChangeRequestById
response = self.soapclient.service.GetChangeRequestById([request])
File "build\bdist.win32\egg\suds\client.py", line 542, in __call__
return client.invoke(args, kwargs)
File "build\bdist.win32\egg\suds\client.py", line 602, in invoke
File "build\bdist.win32\egg\suds\client.py", line 643, in send
result = self.succeeded(binding, reply.message)
File "build\bdist.win32\egg\suds\client.py", line 678, in succeeded
reply, result = binding.get_reply(self.method, reply)
File "build\bdist.win32\egg\suds\bindings\binding.py", line 149, in get_reply
soapenv.promotePrefixes()
AttributeError: 'NoneType' object has no attribute 'promotePrefixes'
I had someone else run my script and it works fine on their computer but I keep getting an error in mine. I've installed several different versions of python to see if that's the problem but with no luck. Does anyone see what could be the problem?

Try to add an endpoint address
client = Client('url', location = "https://someurl/services")

Related

PRAW | submissions | prawcore.exceptions.NotFound: received 404 HTTP response

i try to get this running. In the past the script was running, i cant remember that i have changed something but now its no longer working. I alltimes get a 404 error at the line for submission in submissions.hot():. This script should upvote all posts from a specific redditor (selected by username). Does someone have an idea? I first tought submissions.hot() would be empty but i get back <praw.models.listing.generator.ListingGenerator object at 0x000001A43D81AD40> so that is not the case and there are enough posts on my profile.
import praw
reddit = praw.Reddit(
client_id="XXXXXXX", #personal use script code
client_secret="XXXXXXXX",
password="XXXXXXXXXXXXXX",
user_agent="XXXXXXXXX", #AppName
username="XXXXXXXXXXXX",
)
redditorName = "LofiBeatsMusicLovers"
redditor = reddit.redditor(redditorName)
submissions = redditor.submissions
print(str(submissions))
print(str(submissions.hot()))
for submission in submissions.hot():
submission.upvote()
print("upvoted hot one!!")
Here is the output from the script:
<praw.models.listing.mixins.redditor.SubListing object at 0x000001A43AC37730>
<praw.models.listing.generator.ListingGenerator object at 0x000001A43D81AD40>
Traceback (most recent call last):
File "C:\Users\erdtm\Desktop\YouTubeStreamingSetup\RedditDMBotSWCombination\RedditBot\UpvoteAllPostsOfUser.py", line 20, in <module>
for submission in submissions.hot():
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\models\listing\generator.py", line 63, in __next__
self._next_batch()
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\models\listing\generator.py", line 89, in _next_batch
self._listing = self._reddit.get(self.url, params=self.params)
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\util\deprecate_args.py", line 43, in wrapped
return func(**dict(zip(_old_args, args)), **kwargs)
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 634, in get
return self._objectify_request(method="GET", params=params, path=path)
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 739, in _objectify_request
self.request(
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\util\deprecate_args.py", line 43, in wrapped
return func(**dict(zip(_old_args, args)), **kwargs)
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\praw\reddit.py", line 941, in request
return self._core.request(
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 330, in request
return self._request_with_retries(
File "C:\Users\erdtm\AppData\Local\Programs\Python\Python310\lib\site-packages\prawcore\sessions.py", line 266, in _request_with_retries
raise self.STATUS_EXCEPTIONS[response.status_code](response)
prawcore.exceptions.NotFound: received 404 HTTP response

Asn1 parsing error when trying to connect to mongo atlas

I am using MongoDB atlas for my discord bot but recently ran into an error. On the hosting (Heroku) everything works without errors, I first updated all the modules, but the error has not disappeared.
I am using motor as a driver to work with MongoDB atlas.
Checked the database connection URL, everything is correct.
Python version 3.10(on Heroku too)
Traceback (most recent call last):
File "D:\Проекты\AkainuBot\main.py", line 23, in <module>
mongo = AsyncIOMotorClient(
File "D:\Python\lib\site-packages\motor\core.py", line 159, in __init__
delegate = self.__delegate_class__(*args, **kwargs)
File "D:\Python\lib\site-packages\pymongo\mongo_client.py", line 718, in __init__
self.__options = options = ClientOptions(
File "D:\Python\lib\site-packages\pymongo\client_options.py", line 165, in __init__
self.__pool_options = _parse_pool_options(options)
File "D:\Python\lib\site-packages\pymongo\client_options.py", line 132, in _parse_pool_options
ssl_context, ssl_match_hostname = _parse_ssl_options(options)
File "D:\Python\lib\site-packages\pymongo\client_options.py", line 98, in _parse_ssl_options
ctx = get_ssl_context(
File "D:\Python\lib\site-packages\pymongo\ssl_support.py", line 159, in get_ssl_context
ctx.load_verify_locations(certifi.where())
File "D:\Python\lib\site-packages\pymongo\pyopenssl_context.py", line 276, in load_verify_locations
self._callback_data.trusted_ca_certs = _load_trusted_ca_certs(cafile)
File "D:\Python\lib\site-packages\pymongo\ocsp_support.py", line 79, in _load_trusted_ca_certs
_load_pem_x509_certificate(cert_data, backend))
File "D:\Python\lib\site-packages\cryptography\x509\base.py", line 436, in load_pem_x509_certificate
return rust_x509.load_pem_x509_certificate(data)
ValueError: error parsing asn1 value: ParseError { kind: InvalidValue, location: ["RawCertificate::tbs_cert", "TbsCertificate::serial"] }
I've solved my problem getting the parsing asn1 value error by adding the ssl_cert_reqs option on the MongoClient (and obviously importing ssl).
dbClient = pymongo.MongoClient(uri, ssl_cert_reqs=ssl.CERT_NONE)

python elasticsearch client error: timed out while get_alias

I am new to python and elasticsearch and i am trying to run a sample application. But my elasticsearch connection shows some error. I have installed elasticsearch and started the server. In the application there is a code like this
ES_URL = ['thrift://127.0.0.1:9200']
connection = pyes.ES(ES_URL)
index = connection.indices.get_alias('staging-asset')
when .get_alias is called, it shows
Client error: timed out
Traceback (most recent call last):
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/connection.py", line 151, in _client_call
return getattr(conn.client, attr)(*args, **kwargs)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/pyesthrift/Rest.py", line 41, in execute
return self.recv_execute()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/pyes/pyesthrift/Rest.py", line 52, in recv_execute
(fname, mtype, rseqid) = self._iprot.readMessageBegin()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/protocol/TBinaryProtocol.py", line 126, in
readMessageBegin
sz = self.readI32()
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/protocol/TBinaryProtocol.py", line 206, in readI32
buff = self.trans.readAll(4)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TTransport.py", line 58, in readAll
chunk = self.read(sz - have)
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TTransport.py", line 159, in read
self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
File "/Users/shahanahamza/.virtualenvs/cms/lib/python2.7/site-
packages/thrift/transport/TSocket.py", line 103, in read
buff = self.handle.recv(sz)
timeout: timed out
Please help me to figure out the issue. Thanks in advance.
As mentioned in the comment by #omri , you might need to increase default threshold timeout-
pyes.es.ES(server, timeout=30, bulk_size=500,max_retries=10)
you can read more about here
There can also be other reasons for this timeouts. Check this and see if its still happening.
Check your mappings also

Instagram callback URL subscription not working

Hello everyone im trying to subscribe to the Instagram API, but for some reason i keep on getting an error.
code:
# Subscribe to all media in a geographic area
api.create_subscription(object='geography', lat=35.657872, lng=139.70232, radius=1000, aspect='media', callback_url='http://locallhost.com/')
Error:
Traceback (most recent call last):
File "C:/Users/Owner.Owner-PC/Documents/Final Year Project/testing.py", line 26, in <module>
api.create_subscription(object='geography', lat=35.657872, lng=139.70232, radius=1000, aspect='media', callback_url='http://locallhost.com/')
File "C:\Python 3.5\lib\site-packages\instagram\bind.py", line 197, in _call
return method.execute()
File "C:\Python 3.5\lib\site-packages\instagram\bind.py", line 189, in execute
content, next = self._do_api_request(url, method, body, headers)
File "C:\Python 3.5\lib\site-packages\instagram\bind.py", line 123, in _do_api_request
signature = hmac.new(secret, ips, sha256).hexdigest()
File "C:\Python 3.5\lib\hmac.py", line 144, in new
return HMAC(key, msg, digestmod)
File "C:\Python 3.5\lib\hmac.py", line 42, in __init__
raise TypeError("key: expected bytes or bytearray, but got %r" % type(key).__name__)
TypeError: key: expected bytes or bytearray, but got 'str'
Now i am very confused what the error is, can someone please explain how to solve this?

Python Geocoders Not Working

I am trying to access geolocation of addresses input by the User in my Django App.
The App was working fine with pygeocoder. Suddenly, the app has started giving problems.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ishaan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pygeocoder.py", line 129, in geocode
return GeocoderResult(Geocoder.get_data(params=params))
File "/home/ishaan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/pygeocoder.py", line 204, in get_data
response = session.send(request.prepare())
File "/home/ishaan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
r = adapter.send(request, **kwargs)
File "/home/ishaan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests/adapters.py", line 370, in send
timeout=timeout
File "/home/ishaan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/home/ishaan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 344, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File "/home/ishaan/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py", line 314, in _raise_timeout
if 'timed out' in str(err) or 'did not complete (read)' in str(err): # Python 2.6
TypeError: __str__ returned non-string (type Error)
I am unable to unserstand this problem, and have a close to no knowledge about SSL and its errors.
I dont know, how relevant it is, but the app was working until I installed Redis Server for another app in the same project. I have uninstalled it, but it is still not working.
Lastly, No other Geocoder is working - Every geocoder gives the same error. I tried to use GeoPy, geocoder 1.6.4
Thanks in advance

Categories