Saving Cloud Text to Speech audio file to Cloud storage - python

Hi I am trying to use google cloud text to speech with appengine. When I send API requests to the text to speech servers, I receive a response with an audio file attached. Now I am trying to write this file to my bucket. Here's my code:
def speak(translation, target_lang):
lang_dict = {'ar': 'ar-XA', 'en': 'en-GB', 'cs': 'cs-CZ', 'da': 'da-DK', 'nl': 'nl-NL', 'fi': 'fi-FI', 'fr': 'fr-FR', 'de': 'de-DE', 'el': 'el-GR', 'hi': 'hi-IN', 'hu': 'hu-HU', 'id': 'id-ID', 'it': 'it-IT',
'ja': 'ja-JP', 'ko': 'ko-KR', 'zh': 'cmn-CN', 'no': 'nb-NO', 'pl': 'pl-PL', 'pt': 'pt-BR', 'ru': 'ru-RU', 'sk': 'sk-SK', 'es': 'es-ES', 'sv': 'sv-SE', 'tr': 'tr-TR', 'uk': 'uk-UA', 'vi': 'vi-VN'}
lang_code = ''
for key, val in lang_dict.items():
if target_lang == key:
lang_code = val
synthesis_input = texttospeech.SynthesisInput(text=translation)
voice = texttospeech.VoiceSelectionParams(
language_code=lang_code,
ssml_gender=texttospeech.SsmlVoiceGender.NEUTRAL)
audio_config = texttospeech.AudioConfig(
audio_encoding=texttospeech.AudioEncoding.MP3)
response = ttsClient.synthesize_speech(
input=synthesis_input, voice=voice, audio_config=audio_config
)
bucket = storage_client.bucket("MY_BUCKET_NAME")
blob = bucket.blob("output.mp3")
blob.upload_from_file(response.audio_content)
return " "
I have removed the actual bucket name from this code snippet but everything else is the same. Also, I tried just writing to the local file system instead of using buckets but appengine does not allow it.
EDIT
Here's the error I am receiving:
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/srv/main.py", line 80, in hello
speak(translation[0], translation[1])
File "/srv/main.py", line 59, in speak
blob.upload_from_file(response.audio_content)
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/storage/blob.py", line 2343, in upload_from_file
created_json = self._do_upload(
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/storage/blob.py", line 2180, in _do_upload
response = self._do_resumable_upload(
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/storage/blob.py", line 2024, in _do_resumable_upload
upload, transport = self._initiate_resumable_upload(
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/cloud/storage/blob.py", line 1911, in _initiate_resumable_upload
upload.initiate(
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/resumable_media/requests/upload.py", line 397, in initiate
method, url, payload, headers = self._prepare_initiate_request(
File "/layers/google.python.pip/pip/lib/python3.9/site-packages/google/resumable_media/_upload.py", line 463, in _prepare_initiate_request
if stream.tell() != 0:
AttributeError: 'bytes' object has no attribute 'tell'

Related

How can i fix the gas price issue in Thirdweb Python SDK Goerli TestNet

Im working with the Thirdweb Python SDK API. The code below sometimes work and sometimes throws a gasprice issue. I think it could be a network issue, because it works sometimes and generates the NFT but not always.
And when i got an error it is about gasprice. But in the Thirdweb API doesnt appear a gasprice argument or someting like this.
Any ideas?
Code:
sqlcol="SELECT ID,(SELECT contrato FROM colecciones WHERE ID=idcolec) AS contratonft FROM solicitudcert WHERE ID='" + idsolicitud + "' LIMIT 0, 1"
mycursor.execute(sqlcol)
misolicitud = mycursor.fetchone()
if(misolicitud):
contratonft_aux=str(misolicitud[1])
contratonft=contratonft_aux.replace('"','')
sdk = ThirdwebSDK.from_private_key(PRIVATE_KEY, NETWORK)
NFT_COLLECTION_ADDRESS = contratonft
nft_collection = sdk.get_nft_collection(NFT_COLLECTION_ADDRESS)
urlarchivoarr=imagencert.split("/")
urlarchivostr=str(urlarchivoarr[1]);
urlarchivoimg="https://files.avfenixrecords.com/" + urlarchivostr
# You can pass in any address here to mint the NFT to
tx = nft_collection.mint(NFTMetadataInput.from_json({
"name": nombrecert,
"description": descripcert,
"image": urlarchivoimg
}))
idnft=tx.id
return jsonify({'status':'OK','IDNFT':idnft})
else:
return jsonify({'status':'ERROR','IDNFT':"NULL"})
Error:
[2022-11-15 19:54:21,628] ERROR in app: Exception on /api/contracts/v1/mintnft [POST]
Traceback (most recent call last):
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 2525, in wsgi_app
response = self.full_dispatch_request()
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 1822, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 1820, in full_dispatch_request
rv = self.dispatch_request()
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/flask/app.py", line 1796, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
File "app.py", line 1851, in mintnft
tx = nft_collection.mint(NFTMetadataInput.from_json({
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/contracts/nft_collection.py", line 135, in mint
return self.mint_to(self._contract_wrapper.get_signer_address(), metadata)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/contracts/nft_collection.py", line 166, in mint_to
receipt = self._contract_wrapper.send_transaction("mint_to", [to, uri])
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/core/classes/contract_wrapper.py", line 113, in send_transaction
tx = getattr(self._contract_abi, fn).build_transaction(
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/thirdweb/abi/token_erc721.py", line 1638, in build_transaction
return self._underlying_method(to, uri).buildTransaction(
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/contract.py", line 1079, in buildTransaction
return build_transaction_for_function(
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/contract.py", line 1648, in build_transaction_for_function
prepared_transaction = fill_transaction_defaults(web3, prepared_transaction)
File "cytoolz/functoolz.pyx", line 249, in cytoolz.functoolz.curry.__call__
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/_utils/transactions.py", line 114, in fill_transaction_defaults
default_val = default_getter(web3, transaction)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/_utils/transactions.py", line 60, in <lambda>
'gas': lambda web3, tx: web3.eth.estimate_gas(tx),
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/eth.py", line 825, in estimate_gas
return self._estimate_gas(transaction, block_identifier)
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/module.py", line 57, in caller
result = w3.manager.request_blocking(method_str,
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/manager.py", line 198, in request_blocking
return self.formatted_response(response,
File "/home/ombhkqgo/virtualenv/contratos/3.8/lib/python3.8/site-packages/web3/manager.py", line 171, in formatted_response
raise ValueError(response["error"])
ValueError: {'code': -32000, 'message': 'err: max fee per gas less than block base fee: address 0x98E0463643b28E24223d2B5EF19E78A9AF031505, maxFeePerGas: 70565183066 baseFee: 77047968359 (supplied gas 22141296)'}
I tried to modify the contracts config into the thirdweb dashboard without success.
What network are you seeing this issue on? We can add in a method to manually overwrite gas limits in the SDK.

cryptography.fernet.InvalidToken error when retrieving data from SQLalchemy database

Hey I've been trying to encrypt some inputted data into a SQLalchemy database. However I keep receiving this error when trying to retrieve the decyrpted data from the database. Any help would be much appreciated.
key = Fernet.generate_key()
fernet = Fernet(key)
Encryption part:
fnam = str(form.first_name.data.lower())
Cfname = bytes(fnam, 'utf-8')
Efname = str(fernet.encrypt(Cfname))
lnam = str(form.last_name.data.lower())
Clname = bytes(lnam,'utf-8')
Elname = str(fernet.encrypt(Clname))
print(Efname)
print(Elname)
appoint.first_name =Efname
appoint.last_name = Elname
Decryption part:
info = user.query.filter_by(id=user.id).first()
finam = info.first_name
lanam = info.last_name
first = str(fernet.decrypt(bytes(finam,'utf-8')))
last = str(fernet.decrypt(bytes(lanam,'utf-8')))
Error message
Traceback (most recent call last):
File "appsec2\venv\lib\site-packages\flask\app.py", line 2095, in __call__
return self.wsgi_app(environ, start_response)
File "appsec2\venv\lib\site-packages\flask\app.py", line 2080, in wsgi_app
response = self.handle_exception(e)
File "appsec2\venv\lib\site-packages\flask\app.py", line 2077, in wsgi_app
response = self.full_dispatch_request()
File "appsec2\venv\lib\site-packages\flask\app.py", line 1525, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\txzsp\OneDrive\Documents\Poly sch stuff\Y2, S1\appsec2\venv\lib\site-packages\flask\app.py", line 1523, in full_dispatch_request
rv = self.dispatch_request()
File "appsec2\venv\lib\site-packages\flask\app.py", line 1509, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "appsec2\appsec\routes.py", line 908, in retrieveConsultation
first = str(fernet.decrypt(bytes(finam,'utf-8')))
File appsec2\venv\lib\site-packages\cryptography\fernet.py", line 83, in decrypt
timestamp, data = Fernet._get_unverified_token_data(token)
File "appsec2\venv\lib\site-packages\cryptography\fernet.py", line 115, in _get_unverified_token_data
raise InvalidToken
cryptography.fernet.InvalidToken

Unit tests are failing after adding environment variable to main file

I'm currently using an environment variable to hide my API's key. My unit test that is testing the API route is now failing. However, when the key was hard-coded into the main file, the tests passed. Here is my code:
import os
import requests
key = os.environ.get('key')
def test_code(state, API_BASE_URL):
url = f'https://covid-19-testing.github.io/locations/{state.lower()}/complete.json'
res = requests.get(url)
testing_data = res.json()
latsLngs = {}
for obj in testing_data:
if obj["physical_address"]:
for o in obj["physical_address"]:
addy = o["address_1"]
city = o["city"]
phone = obj["phones"][0]["number"]
location = f'{addy} {city}'
location_coordinates = requests.get(API_BASE_URL,
params={'key': key, 'location': location}).json()
lat = location_coordinates["results"][0]["locations"][0]["latLng"]["lat"]
lng = location_coordinates["results"][0]["locations"][0]["latLng"]["lng"]
latsLngs[location] = {'lat': lat, 'lng': lng, 'place': location, 'phone': phone}
return latsLngs
Here is the unit test:
from unittest import TestCase, mock
from models import db, User
from sqlalchemy.exc import InvalidRequestError
class UserViewTestCase(TestCase):
"""Test views for users."""
def setUp(self):
"""Create test client, add sample data."""
db.drop_all()
db.create_all()
self.app = create_app('testing')
self.client = self.app.test_client()
self.testuser = User.signup('test',
'dummy',
'test123',
'dummytest#test.com',
'password',
None,
"Texas",
None,
None)
self.uid = 1111
self.testuser.id = self.uid
db.session.commit()
def test_map_locations(self):
"""Does the map show testing locations?"""
with self.client as c:
resp = c.get('/location?state=California')
html = resp.get_data(as_text=True)
self.assertEqual(resp.status_code, 200)
self.assertIn('San Francisco', html)
I also think it's important to note that the application runs fine in the browser. It's just that the unit tests are not passing anymore.
UPDATE
Here is the full traceback:
ERROR: test_map_locations (test_user_views.UserViewTestCase)
Does the map show testing locations?
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/travis/build/azaria-dedmon/covid-19/tests/test_user_views.py", line 157, in test_map_locations
resp = c.get('/location?state=California')
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 1006, in get
return self.open(*args, **kw)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/testing.py", line 227, in open
follow_redirects=follow_redirects,
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 970, in open
response = self.run_wsgi_app(environ.copy(), buffered=buffered)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 861, in run_wsgi_app
rv = run_wsgi_app(self.application, environ, buffered=buffered)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/werkzeug/test.py", line 1096, in run_wsgi_app
app_rv = app(environ, start_response)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
return self.wsgi_app(environ, start_response)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/travis/build/azaria-dedmon/covid-19/app/__init__.py", line 111, in show_state_locations
latsLngs = test_code(state, API_BASE_URL)
File "/home/travis/build/azaria-dedmon/covid-19/app/refactor.py", line 22, in test_code
params={'key': key, 'location': location}).json()
File "/home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/opt/python/3.7.1/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/opt/python/3.7.1/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/opt/python/3.7.1/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I think it's most likely that your test framework is loading just the test_code() function from your test file, and not the fact that key is set up in the main body of the code. Perhaps moving your key = os.environ.get("key") into test_code() will solve your issue.
The environment variable needs to be set in the project's repository in travis CI so that all files have access to it. Here is the documentation on how to achieve this https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings

Google App Engine/NDB: "BadValueError: Expected Key, got None" for saving perfectly fine entity

I'm currently porting a web app to Google App Engine, Python 3, Standard Environment. (So I'm new to GAE and NDB).
I have a bug here that I don't understand. I obtain an entity like so, the adjust properties, then save.
sourceUsers = User.query().filter(User.email == request.form.get('sourceUserEmail')).fetch(1)
if sourceUsers:
sourceUser = sourceUsers[0]
# manipulation:
sourceUser.sentInvitationSubscriptionKeys.append(subscription.key)
# verify key:
assert sourceUser.key != None
sourceUser.put()
But the saving triggers the following traceback:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/Users/yanone/Code/Google App Engine/typeworldappengine/main.py", line 500, in api
sourceUser.put()
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/_options.py", line 89, in wrapper
return wrapped(*pass_args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/utils.py", line 78, in wrapper
return wrapped(*args, **new_kwargs)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/utils.py", line 109, in positional_wrapper
return wrapped(*args, **kwds)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 4914, in _put
return self._put_async(_options=kwargs["_options"]).result()
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/tasklets.py", line 190, in result
self.check_success()
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/tasklets.py", line 137, in check_success
raise self._exception
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/tasklets.py", line 312, in _advance_tasklet
yielded = self.generator.send(send_value)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 4974, in put
ds_entity = _entity_to_ds_entity(self)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 722, in _entity_to_ds_entity
names = prop._to_datastore(entity, data)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 2063, in _to_datastore
value = self._get_base_value_unwrapped_as_list(entity)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 1551, in _get_base_value_unwrapped_as_list
wrapped = self._get_base_value(entity)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 1537, in _get_base_value
return self._apply_to_values(entity, self._opt_call_to_base_type)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 1834, in _apply_to_values
value[:] = map(function, value)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 1612, in _opt_call_to_base_type
value = _BaseValue(self._call_to_base_type(value))
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 1671, in _call_to_base_type
return call(value)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 1801, in call
new_value = method(self, value)
File "/usr/local/lib/python3.7/site-packages/google/cloud/ndb/model.py", line 3344, in _validate
"Expected Key, got {!r}".format(value)
google.cloud.ndb.exceptions.BadValueError: Expected Key, got None
In the debugging, I even made sure that the entity has a key (assert sourceUser.key != None). So I really don't get it. What am I doing wrong?
Mind you, all other entities save fine. Just this one doesn't.
Thank you.
I dont think this entity's primary key is the problem. It's probably another Key field on the object.
Whats the schema for the rest of you User object?

Problem in response with alexa custom skill using ngrok

I'm working on Alexa custom skill by using Alexa voice control to control raspberry gpio pins, I followed each and every steps mentioned here https://www.instructables.com/id/Control-Raspberry-Pi-GPIO-With-Amazon-Echo-and-Pyt/ but this is giving me response error
I tried degrading cryptography to 2.2.
Re-starting the server.
Re-building the model.
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
#ask.intent('GPIOControlIntent', mapping={'status': 'status', 'pin': 'pin'})
def gpio_control(status, pin):
try:
pinNum = int(pin)
except Exception as e:
return statement('Pin number not valid.')
GPIO.setup(pinNum, GPIO.OUT)
if status in ['on', 'high']: GPIO.output(pinNum, GPIO.HIGH)
if status in ['off', 'low']: GPIO.output(pinNum, GPIO.LOW)
return statement('Turning pin {} {}'.format(pin, status))
The error I got:
127.0.0.1 - - [13/Jul/2019 00:04:25] "POST / HTTP/1.1" 500 - Traceback (most recent call last): File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request() File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request() File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args) File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/core.py", line 728, in _flask_view_func
ask_payload = self._alexa_request(verify=self.ask_verify_requests) File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/core.py", line 662, in _alexa_request
cert = verifier.load_certificate(cert_url) File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/verifier.py", line 21, in load_certificate
if not _valid_certificate(cert): File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/verifier.py", line 63, in _valid_certificate
value = str(extension) File "/home/pi/.local/lib/python2.7/site-packages/OpenSSL/crypto.py", line 779, in __str__
return self._subjectAltNameString() File "/home/pi/.local/lib/python2.7/site-packages/OpenSSL/crypto.py", line 740, in _subjectAltNameString
method = _lib.X509V3_EXT_get(self._extension) AttributeError: 'module' object has no attribute 'X509V3_EXT_get'
127.0.0.1 - - [13/Jul/2019 00:04:28] "POST / HTTP/1.1" 500 - Traceback (most recent call last): File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1997, in __call__
return self.wsgi_app(environ, start_response) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1985, in wsgi_app
response = self.handle_exception(e) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1540, in handle_exception
reraise(exc_type, exc_value, tb) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request() File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb) File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request() File "/home/pi/.local/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args) File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/core.py", line 728, in _flask_view_func
ask_payload = self._alexa_request(verify=self.ask_verify_requests) File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/core.py", line 662, in _alexa_request
cert = verifier.load_certificate(cert_url) File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/verifier.py", line 21, in load_certificate
if not _valid_certificate(cert): File "/home/pi/.local/lib/python2.7/site-packages/flask_ask/verifier.py", line 63, in _valid_certificate
value = str(extension) File "/home/pi/.local/lib/python2.7/site-packages/OpenSSL/crypto.py", line 779, in __str__
return self._subjectAltNameString() File "/home/pi/.local/lib/python2.7/site-packages/OpenSSL/crypto.py", line 740, in _subjectAltNameString
method = _lib.X509V3_EXT_get(self._extension) AttributeError: 'module' object has no attribute 'X509V3_EXT_get'
Try degrading it to less than 2.2
pip install 'cryptography<2.2'

Categories

Resources