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'
Related
'''
features = [gender, SeniorCitizen, Partner, Dependents, Tenure, PhoneService, MultipleLines, OnlineSecurity, OnlineBackup,
DeviceProtection, TechSupport, StreamingTV, StreamingMovies, PaperlessBilling, MonthlyCharges, TotalCharges,
InternetService_Fiberoptic, InternetService_No, Contract_Oneyear,Contract_Twoyear,
PaymentMethod_CreditCard, PaymentMethod_ElectronicCheck, PaymentMethod_MailedCheck]
final_features = [np.array(features)]
prediction = model.predict_proba(final_features)
output = prediction[0,1]
# Shap Values
explainer = joblib.load(filename="explainer.bz2")
shap_values = explainer.shap_values(np.array(final_features))
shap_img = io.BytesIO()
shap.force_plot(explainer.expected_value[1], shap_values[1], columns, matplotlib = True, show = False).savefig(shap_img, bbox_inches="tight", format = 'png')
shap_img.seek(0)
shap_url = base64.b64encode(shap_img.getvalue()).decode()
The error is coming about tree ensemble when we try to run the python file.The error says: 'TreeEnsemble' object has no attribute 'model_output'. Please help to correct this error
the traceback is :
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask_compat.py", line 33, in reraise
raise value
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask_compat.py", line 33, in reraise
raise value
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\Users\utrej\Desktop####\product dev lab\Customer-Survival-Analysis-and-Churn-Prediction-master\app.py", line 118, in predict
shap_values = explainer.shap_values(np.array(final_features))
File "C:\Users\utrej\AppData\Local\Programs\Python\Python38\Lib\site-packages\shap\explainers\tree.py", line 298, in shap_values
if self.model.model_output == "log_loss":
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?
My endpoint is defined as
#app.route('/PollingEngineExceptions',methods=['POST'])
def PollingEngineExceptions(PollingException):
..
return response
Im posting to this endpoint
def test_atg_polling_exception(self):
jsonEncoder = CustomJSONEncoder()
a= PollingException('System.OutOfMemoryException','System.OutOfMemoryException','System.OutOfMemoryException','2009-02-15T00:00:00Z')
jsonmsg=jsonEncoder.default(a)
response = requests.post("http://localhost:5000/PollingEngineExceptions",data=jsonmsg)
when I POSTing im getting
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/Library/Python/2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Library/Python/2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Library/Python/2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/Library/Python/2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
TypeError: PollingEngineExceptions() takes exactly 1 argument (0 given)
What Im doing wrong here?
I have fixed like correcting my endpoint;
#app.route('/ATGPollingEngineExceptions',methods=['POST'])
def ATGPollingEngineExceptions():
value = request.values
print value
...
return response
I have a piece of code as below python code:-
with multiprocessing.Manager() as manager:
L = manager.list()
number_processes = int(max(min(multiprocessing.cpu_count(), math.ceil(len(splittedFrames)/10.0)),1))
pool = multiprocessing.Pool(number_processes)
workFunc = partial(multiProcWork, dictMVUserMapping, diColMapping, L)
results = pool.map_async(workFunc, splittedFrames)
results.get()
pool.close()
pool.join()
# print L
masterDictList = [x for x in L]
Which fails with below error:-
Traceback (most recent call last):
File "/home/wiproadmin/Python2713/lib/python2.7/site-packages/flask/app.py", line 1982, in wsgi_app
response = self.full_dispatch_request()
File "/home/wiproadmin/Python2713/lib/python2.7/site-packages/flask/app.py", line 1614, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/wiproadmin/Python2713/lib/python2.7/site-packages/flask/app.py", line 1517, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/wiproadmin/Python2713/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/home/wiproadmin/Python2713/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "app.py", line 138, in setMvMappingFields
data = fn.uiDriverFunction(userMapping,token,username,provName=providerName)
File "../bin/functionsForUI.py", line 499, in uiDriverFunction
with multiprocessing.Manager() as manager:
File "/home/wiproadmin/Python2713/lib/python2.7/multiprocessing/__init__.py", line 99, in Manager
m.start()
File "/home/wiproadmin/Python2713/lib/python2.7/multiprocessing/managers.py", line 524, in start
self._process.start()
File "/home/wiproadmin/Python2713/lib/python2.7/multiprocessing/process.py", line 130, in start
self._popen = Popen(self)
File "/home/wiproadmin/Python2713/lib/python2.7/multiprocessing/forking.py", line 121, in __init__
self.pid = os.fork()
File "/home/wiproadmin/Python2713/lib/python2.7/site-packages/gevent/os.py", line 419, in fork
return fork_and_watch(*args, **kwargs)
File "/home/wiproadmin/Python2713/lib/python2.7/site-packages/gevent/os.py", line 375, in fork_and_watch
watcher = loop.child(pid, ref=ref)
File "gevent.libev.corecext.pyx", line 518, in gevent.libev.corecext.loop.child (src/gevent/libev/gevent.corecext.c:7603)
File "gevent.libev.corecext.pyx", line 1886, in gevent.libev.corecext.child.__init__ (src/gevent/libev/gevent.corecext.c:21688)
TypeError: child watchers are only available on the default loop
Which is working fine in windows and failing in ubuntu machine version 14.04, Tried searching around, couldnt find any information.
I have a form, and on submit I keep getting the error below. I can't work out what the problem is, but I think it has something to do with the selectfield as this is the first time I am using it and I haven't had problems before.
Here is my form:
class CampaignForm(Form):
name = StringField('Campaign Name', validators=[DataRequired])
start = DateField('Start', validators=[DataRequired], format='%d-%m-%Y')
end = DateField('End', validators=[DataRequired], format='%d-%m-%Y')
budget = IntegerField('Budget', validators=[DataRequired])
customer_id = SelectField(
'Customer', validators=[DataRequired], coerce=int)
Here is my view, GET works, but I keep getting an error on POST:
#app.route('/campaign/add', methods=['GET', 'POST'])
#login_required
def campaign_add():
form = CampaignForm()
form.customer_id.choices = [
(customer.id, customer.name)
for customer in current_user.account.customers]
if form.validate_on_submit():
campaign = Campaign(name=form.name.data,
start=form.start.data,
end=form.end.data,
budget=form.budget.data,
account_id=current_user.account_id,
customer_id=form.customer_id.data,
created_at=datetime.now(),
created_by=current_user.id,
updated_at=datetime.now(),
updated_by=current_user.id)
db.session.add(campaign)
db.session.commit()
return redirect(url_for('campaigns'))
return render_template('campaigns/add.html', form=form)
Here is the error that I am getting, and I can't work out what is wrong.
Traceback (most recent call last):
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/tornado/web.py", line 1309, in _execute
result = self.prepare()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/tornado/web.py", line 2498, in prepare
self.fallback(self.request)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/livereload/server.py", line 89, in __call__
WSGIContainer.environ(request), start_response)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/_compat.py", line 33, in reraise
raise value
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask_debugtoolbar/__init__.py", line 124, in dispatch_request
return view_func(**req.view_args)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask_login.py", line 758, in decorated_view
return func(*args, **kwargs)
File "/home/lee/Code/fastplan/src/fastplan/views.py", line 249, in campaign_add
if form.validate_on_submit():
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/flask_wtf/form.py", line 166, in validate_on_submit
return self.is_submitted() and self.validate()
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/form.py", line 310, in validate
return super(Form, self).validate(extra)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/form.py", line 152, in validate
if not field.validate(self, extra):
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/fields/core.py", line 200, in validate
stop_validation = self._run_validation_chain(form, chain)
File "/home/lee/Code/fastplan/venv/lib/python3.4/site-packages/wtforms/fields/core.py", line 220, in _run_validation_chain
validator(form, self)
TypeError: __init__() takes from 1 to 2 positional arguments but 3 were given
The issue is that lines like this:
validators=[DataRequired]
should be like this
validators=[DataRequired()]