failed to use TLS with Couchbase Python SDK 3.0.x - python

I'm trying to use Couchbase Python SDK 3.0.x to connect to a cluster. I followed the document (https://docs.couchbase.com/python-sdk/3.0/howtos/managing-connections.html#ssl) to create the certificate file and used it with the following code:
cluster = Cluster("couchbase://10.82.xxx.xxx:18091", ClusterOptions(PasswordAuthenticator(DEST_USR, DEST_PW, cert_path="./cert.crt")))
However when I run it it gives the following:
$ python3 mycode.py
creating couchbase instance seriesMgmt#10.82.xxx.xxx:18091
Traceback (most recent call last):
File "scheduleCache.py", line 29, in <module>
cluster = Cluster("couchbase://"+DEST_CB_IP, ClusterOptions(PasswordAuthenticator(DEST_USR, DEST_PW, cert_path="./cert.crt")))
File "/usr/local/lib/python3.7/site-packages/couchbase/cluster.py", line 492, in __init__
super(Cluster, self).__init__(connection_string=str(self.connstr), _conntype=_LCB.LCB_TYPE_CLUSTER, **self._clusteropts)
File "/usr/local/lib/python3.7/site-packages/couchbase_core/client.py", line 141, in __init__
super(Client, self).__init__(*args, **kwargs)
couchbase.exceptions.InvalidArgumentException: <Bad/insufficient arguments provided, inner_cause='certpath' is an invalid keyword argument for this function, C Source=(src/bucket.c,1047)>
I believe it's not about the correctness of my cert file yet - somehow the SDK just doesn't want to take the parameter cert_path. Tried to remove the parameter name and it doesn't help:
cluster = Cluster("couchbase://10.82.xxx.xxx:18091", ClusterOptions(PasswordAuthenticator(DEST_USR, DEST_PW, "./cert.crt")))
BTW I can login https://10.82.xxx.xxx:18091 via browser without any problem.

Related

Unknown protocol type: 'file': I keep getting an error while creating a Virtual Machine in vert-manager on Ubuntu

I'm running Ubuntu 20.04.3 and just installed virt-manager along with QEMU/KVM.
I keep getting an error after the final step of creating a virtual machine.
Unable to complete install: 'unsupported configuration: unknown protocol type 'file''
Traceback (most recent call last):
File "/usr/share/virt-manager/virtManager/asyncjob.py", line 75, in cb_wrapper
callback(asyncjob, *args, **kwargs)
File "/usr/share/virt-manager/virtManager/createvm.py", line 2089, in _do_async_install
guest.installer_instance.start_install(guest, meter=meter)
File "/usr/share/virt-manager/virtinst/install/installer.py", line 542, in start_install
domain = self._create_guest(
File "/usr/share/virt-manager/virtinst/install/installer.py", line 491, in _create_guest
domain = self.conn.createXML(install_xml or final_xml, 0)
File "/usr/lib/python3/dist-packages/libvirt.py", line 4034, in createXML
if ret is None:raise libvirtError('virDomainCreateXML() failed', conn=self)
libvirt.libvirtError: unsupported configuration: unknown protocol type 'file'
I tried many options, fiddled with Storage pools, created images externally, but nothing seems to work.
When configuring the VM, I gave it the official windows ISO which was located in my /home/.../Downloads folder.
The problem was that the file browser inputted file://home/... instead of just /home/..., so I changed it and it worked thereafter.

RuntimeError: ALBroker::createBroker

I need help in python. I tried to put this code in python shell:
from naoqi import ALProxy
tts = ALProxy("ALTextToSpeech", "127.0.0.1",9559)
tts.say("Hello, world!")
and I get this error:
Traceback (most recent call last):
File "C:/Users/USER/Desktop/say.py", line 2, in <module>
tts = ALProxy("ALTextToSpeech", "127.0.0.1",9559)
File "C:/Users/USER/Desktop\naoqi.py", line 227, in __init__
inaoqi.proxy.__init__(self, args[0], args[1], args[2])
File "C:\Python27\lib\site-packages\inaoqi.py", line 318, in __init__
this = _inaoqi.new_proxy(*args)
RuntimeError: ALBroker::createBroker
Cannot connect to tcp://127.0.0.1:9559
This order happen whether I use virtual robot or real, I use choregraphe 1.14.5 version and python version 2.7.13
The connection is almost never done to 127.0.0.1:9559:
If you're connecting to a real robot, you should replace 127.0.0.1 by it's IP address (or it's domain name, e.g. "nao.local", but may or may not work depending of your local network configuration; when it does work it's more convenient)
If you're connecting to Choregraphe's virtual robot, you should replace 9559 by the virtual robot's port, which you can find in Choregraphe's preferences, at the bottom of the "Virtual Robot" tab, as seen in this image.

Python:Pycall Validation Error while Calling

I have Asterisk 13.20 set up and running fine on Ubuntu 16.04,calls are going well through a Softphone(Zoiper), I came across a Library in Python "Pycall" which lets you make calls through a Python Script.So I tried testing a snippet from the site Pycall
The code that I used:
from pycall import CallFile, Call, Application
call = Call('SIP/flowroute/18882223333')
action = Application('Playback', 'hello-world')
c = CallFile(call, action)
c.spool()
Just made changes in the extension,wherein I used one from my server
However I am getting the following error:
Traceback (most recent call last):
File "test.py", line 10, in <module>
c.spool()
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 131, in spool
self.writefile()
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 119, in writefile
f.write(self.contents)
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 114, in contents
return '\n'.join(self.buildfile())
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 96, in buildfile
raise ValidationError
pycall.errors.ValidationError
Tried searching online for the solution but coudnt find one,What am I doing wrong?
This question not related to PBX, it is just incorrect use of LIB.
General instruction how to solve ANY issue with availible source code.
You have error
File "/usr/local/lib/python2.7/dist-packages/pycall/callfile.py", line 96, in buildfile
Go that file and line, check code, add more debug if needed, fix your app.
Run as asterisk user.
sudo su asterisk -s /bin/bash
python
from pycall import CallFile, Call, Application
call = Call('SIP/flowroute/18882223333')
action = Application('Playback', 'hello-world')
c = CallFile(call, action)
c.spool()

Error running Google's Cloud Vision API Example (Face Detection)

I am trying to run the Face Detection Example in Google's Cloud Vision API. I am trying to run [faces.py here][1].
When I run the following:
faces.py demo-picture.jpg
below is the error I get:
ubuntu#ubuntu-VirtualBox:~/Documents/code/python- stuff/googleapis/cloudvisionapi/cloud-vision/python/face_detection$ python faces.py demo-image.jpg
Traceback (most recent call last):
File "faces.py", line 121, in <module>
main(args.input_image, args.output, args.max_results)
File "faces.py", line 98, in main
faces = detect_face(image, max_results)
File "faces.py", line 62, in detect_face
service = get_vision_service()
File "faces.py", line 35, in get_vision_service
credentials = GoogleCredentials.get_application_default()
File "/home/ubuntu/.local/lib/python2.7/site- packages/oauth2client/client.py", line 1398, in get_application_default
return GoogleCredentials._get_implicit_credentials()
File "/home/ubuntu/.local/lib/python2.7/site- packages/oauth2client/client.py", line 1388, in _get_implicit_credentials
raise ApplicationDefaultCredentialsError(ADC_HELP_MSG)
oauth2client.client.ApplicationDefaultCredentialsError: The Application Default Credentials are not available. They are available if running in Google Compute Engine. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application- default-credentials for more information.
ubuntu#ubuntu-VirtualBox:~/Documents/code/python- stuff/googleapis/cloudvisionapi/cloud-vision/python/face_detection$
[1]: https://github.com/GoogleCloudPlatform/cloud- vision/tree/master/python/face_detection
I guess my question is -- how do I do this:
Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials.
You need to download the service-account key; typically a JSON file.
If you have not created the credentials/obtained the key, follow the steps:
Go to your API manager;
Create credentials;
Choose "Service Account Key";
Select "Key Type" as JSON.
After this point, you should obtain a JSON file.
Once you obtain the key, go to your BASHRC (~/.bashrc) and add the following:
export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/JSON
Then restart your bash by
exec bash
Now, re-run your faces.py.

SUDS Exception Imported Schema Failed

I'm getting the error:
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at
(http://www.w3.org/2001/XMLSchema.x sd), failed
when passing a Doctor (constructed with ImportDoctor) to the suds Client constructor.
I'm working on two Windows machines, both of them got the same version of suds installed, but only one of them rises the error above.
Could someone guide me here to know why this error rises?, so I can figure out what's missing on the machine where it happens?.
Thanks in advance!!!.
UPDATE: I don't really know if this is important, but it's worth noting that my Windows machine that is rising the error is an Amazon Web Services instance. At my local machine everything's working well!.
UPDATE: Here's some code I ran at the python interpreter of the machine I mentioned. Here you can detail how the error is rising...
>>> from suds.client import Client
>>> from suds.xsd.doctor import ImportDoctor, Import
>>> missing_import = Import("http://www.w3.org/2001/XMLSchema")
>>> missing_import.filter.add("http://tempuri.org/")
>>> doctor = ImportDoctor(missing_import)
>>> client = Client("http://etcfulfill.ebooks.com/Fulfillment.asmx?wsdl")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "suds\client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "suds\reader.py", line 152, in open
d = self.fn(url, self.options)
File "suds\wsdl.py", line 159, in __init__
self.build_schema()
File "suds\wsdl.py", line 220, in build_schema
self.schema = container.load(self.options)
File "suds\xsd\schema.py", line 95, in load
child.dereference()
File "suds\xsd\schema.py", line 323, in dereference
midx, deps = x.dependencies()
File "suds\xsd\sxbasic.py", line 422, in dependencies
raise TypeNotFound(self.ref)
suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'
>>> client = Client("http://etcfulfill.ebooks.com/Fulfillment.asmx?wsdl", doctor=doctor)
No handlers could be found for logger "suds.xsd.sxbasic"
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "suds\client.py", line 112, in __init__
self.wsdl = reader.open(url)
File "suds\reader.py", line 152, in open
d = self.fn(url, self.options)
File "suds\wsdl.py", line 159, in __init__
self.build_schema()
File "suds\wsdl.py", line 220, in build_schema
self.schema = container.load(self.options)
File "suds\xsd\schema.py", line 93, in load
child.open_imports(options)
File "suds\xsd\schema.py", line 305, in open_imports
imported = imp.open(options)
File "suds\xsd\sxbasic.py", line 542, in open
result = self.download(options)
File "suds\xsd\sxbasic.py", line 567, in download
raise Exception(msg)
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at (http://www.w3.org/2001/XMLSchema.xsd), failed
UPDATE:
I realized that suds connections always open in TCP increasing ports, and if it reaches the maximum TCP port (65535) then it starts opening again from the minimum TCP port available, so there's no problem with this.
The problem shows up when using suds ImportDoctor, because it has to open a previous connection to the location where the import should be retrieved, and for some reason, if the system reaches the maximum TCP port count, then suds somehow assumes that there's no TCP port available to open the connection for obtaining the import, and in consecuence it throws the exception:
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at (http://www.w3.org/2001/XMLSchema.xsd), failed
I repeat, this only happens if suds has to open this previous connection for obtaining the import. If ImportDoctor is not used, then suds has no problem if the TCP port count reaches its maximum, it just restarts at the minimum port available.
Does anyone has any clue on how to resolve this issue???. I'd really appreciate the help!!!.
I've figured out what the problem was. The schema that was missing from the WSDL I was trying to use with suds was:
http://www.w3.org/2001/XMLSchema
And the XSD file for this schema is at:
http://www.w3.org/2001/XMLSchema.xsd
So when I used suds ImportDoctor to add this schema import, sometimes the w3.org domain was denying my access (don't know why really) and that's why this error was rising:
Exception: imported schema (http://www.w3.org/2001/XMLSchema) at (http://www.w3.org/2001/XMLSchema.xsd), failed
What did I do to solve this problem?. I just downloaded this schema to my machine and used suds ImportDoctor to retrieve this import locally.
And that was it!!!. Confusing bug!!!. But SOLVED.

Categories