taskqueue is not working google app engine - google-app-engine

File "/layers/google.python.pip/pip/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/django/views/generic/base.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/django/views/generic/base.py", line 142, in dispatch
return handler(request, *args, **kwargs)
File "/workspace/apps/account/views.py", line 235, in post
taskqueue.add(queue_name='create-waybill', url = reverse('_api:createWaybill') , params = {'key':url_key})
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/google/appengine/api/taskqueue/taskqueue.py", line 575, in create_rpc
return apiproxy_stub_map.UserRPC('taskqueue', deadline, callback)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/google/appengine/api/apiproxy_stub_map.py", line 444, in __init__
self.__rpc = CreateRPC(service, stubmap)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/google/appengine/api/apiproxy_stub_map.py", line 69, in CreateRPC
assert stub, 'No api proxy found for service "%s"' % service
AssertionError: No api proxy found for service "taskqueue"
I am working on google app engine and try to run taskqueue and getting error
i am using django python3
from google.appengine.api import taskqueue
taskqueue.Task(name='create-waybill', url='/_api/createWaybill',params = {'key':url_key}).add()
just this one
and
path ('createWaybill', csrf_exempt(views.CreateWaybill.as_view()), name='createWaybill'),

To use the bundled services in Python 3, you first have to enable them.
See documentation from Google for doing that

Related

prawcore.exceptions.NotFound: received 404 HTTP response

Hey guys I'm having trouble figuring this out:
Traceback (most recent call last):
File "SOLIS.py", line 62, in <module>
com_df1 = scraper.comments(sub_id_list,keywords1,keywords2)
File "/Users/CarranzaEE/Desktop/CDS 491:DEXIS/Reddit_SOLIS/Reddit_SOLIS.py", line 252, in comments
if((comment.author is None) or (hasattr(comment.author, 'id') != True)):
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/models/reddit/base.py", line 34, in __getattr__
self._fetch()
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/models/reddit/redditor.py", line 171, in _fetch
data = self._fetch_data()
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/models/reddit/redditor.py", line 168, in _fetch_data
return self._reddit.request("GET", path, params)
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/praw/reddit.py", line 765, in request
json=json,
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/prawcore/sessions.py", line 339, in request
url=url,
File "/Users/CarranzaEE/anaconda3/lib/python3.7/site-packages/prawcore/sessions.py", line 265, in _request_with_retries
raise self.STATUS_EXCEPTIONS[response.status_code](response)
prawcore.exceptions.NotFound: received 404 HTTP response
This error happens when I try to use author (an instance of Redditor) to try and call author.id. PRAW documents also say that Shadowbanned accounts are treated the same as non-existent accounts, meaning that they will not have any attributes, and that will only return name and is_suspended.
But is_suspended is no longer an attribute provided by reddit api. So I'm having trouble trying to handle cases where the account is a shawdowbanned account. Any tips or ideas?

TemplateDoesNotExist error for a simple ModelAdmin example

I've used Wagtail's ModelAdmin on a few other projects with great success, but this is the first time I'm attempting to use it with a model inheriting from Page.
I copied the simple example template and removed the parts that didn't relate to my BlogPageModel.
The link to the ModelAdmin appears as expected, but when I click it, I get TemplateDoesNotExist at /admin/blog/blogpage/.
I don't remember having to set up a template before. Is there a setting I'm missing?
Wagtail: 1.9 /
Django: 1.10.5 /
Python: 3.5.2
Update: I tried it with a model that inherits from models.Model as well with the same result.
Traceback follows:
Internal Server Error: /admin/blog/blogpage/
Traceback (most recent call last):
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 217, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py", line 215, in _get_response
response = response.render()
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 109, in render
self.content = self.rendered_content
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 84, in rendered_content
template = self.resolve_template(self.template_name)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/response.py", line 66, in resolve_template
return select_template(template, using=self.using)
File "/Users/username/.virtualenv/lib/python3.5/site-packages/django/template/loader.py", line 53, in select_template
raise TemplateDoesNotExist(', '.join(template_name_list), chain=chain)
django.template.exceptions.TemplateDoesNotExist: modeladmin/blog/blogpage/index.html, modeladmin/blog/index.html, modeladmin/index.html
[21/Feb/2017 07:56:38] "GET /admin/blog/blogpage/ HTTP/1.1" 500 110901
I suspect you've missed out adding 'wagtail.contrib.modeladmin' to INSTALLED_APPS.

python-twitter in google app engine

I am trying to use python-twitter api in GAE.
I need to import Oauth2 and httplib2.
Here is how I did
For OAuth2, I downloaded github.com/simplegeo/python-oauth2/tree/master/oauth2. For HTTPLib2, I dowloaded code.google.com/p/httplib2/wiki/Install and extracted folder python2/httplib2 to project root folder.
my views.py
import twitter
def index(request):
api = twitter.Api(consumer_key='XNAUYmsmono4gs3LP4T6Pw',consumer_secret='xxxxx',access_token_key='xxxxx',access_token_secret='iHzMkC6RRDipon1kYQtE5QOAYa1bVfYMhH7GFmMFjg',cache=None)
return render_to_response('fbtwitter/index.html')
I got the error paste.shehas.net/show/jbXyx2MSJrpjt7LR2Ksc
AttributeError
AttributeError: 'module' object has no attribute 'SignatureMethod_PLAINTEXT'
Traceback (most recent call last)
File "D:\PythonProj\fbtwitter\kay\lib\werkzeug\wsgi.py", line 471, in __call__
return app(environ, start_response)
File "D:\PythonProj\fbtwitter\kay\app.py", line 478, in __call__
response = self.get_response(request)
File "D:\PythonProj\fbtwitter\kay\app.py", line 405, in get_response
return self.handle_uncaught_exception(request, exc_info)
File "D:\PythonProj\fbtwitter\kay\app.py", line 371, in get_response
response = view_func(request, **values)
File "D:\PythonProj\fbtwitter\fbtwitter\views.py", line 39, in index
access_token_secret='iHzMkC6RRDipon1kYQtE5QOAYa1bVfYMhH7GFmMFjg',cache=None)
File "D:\PythonProj\fbtwitter\fbtwitter\twitter.py", line 2235, in __init__
self.SetCredentials(consumer_key, consumer_secret, access_token_key, access_token_secret)
File "D:\PythonProj\fbtwitter\fbtwitter\twitter.py", line 2264, in SetCredentials
self._signature_method_plaintext = oauth.SignatureMethod_PLAINTEXT()
AttributeError: 'module' object has no attribute 'SignatureMethod_PLAINTEXT'
It seems I did not import Oauth2 correctly when I tracked the error in twitter.py
self._signature_method_plaintext = oauth.SignatureMethod_PLAINTEXT()
I even go to twitter.py and add import oauth2 as oauth but it couldnt solve the problem
Can anybody help?
I fixed it. In twitter.py,
try:
from hashlib import md5
except ImportError:
from md5 import md5
import oauth
CHARACTER_LIMIT = 140
# A singleton representing a lazily instantiated FileCache.
DEFAULT_CACHE = object()
REQUEST_TOKEN_URL = 'https://api.twitter.com/oauth/request_token'
ACCESS_TOKEN_URL = 'https://api.twitter.com/oauth/access_token'
AUTHORIZATION_URL = 'https://api.twitter.com/oauth/authorize'
SIGNIN_URL = 'https://api.twitter.com/oauth/authenticate'
Need to change import oauth to import oauth2 as oauth
I'm using tweetpy with my GAE application and it works well.
https://github.com/tweepy/tweepy
You can find some sample codes of tweetpy on GAE in google search.

urllib2 error on appengine

The following works locally but not when deployed:
import urllib
import urllib2
import simplejson as json
url = 'https://www.googleapis.com/rpc'
requests = [{
'method': 'freebase.text.get',
'apiVersion': 'v1',
'params': {
'id': ['en','bob_dylan']
}
},{
'method': 'freebase.text.get',
'apiVersion': 'v1',
'params': {
'id': ['en','blade_runner']
}
}]
headers = { 'Content-Type': 'application/json' }
req = urllib2.Request(url, json.dumps(requests), headers)
response = urllib2.urlopen(req)
print response.read()
When deployed it throws the following error:
class 'urllib2.HTTPError': HTTP Error 404: Not Found
Traceback (most recent call last):
File "/base/data/home/apps/s~34thquote/1.359254037177435492/test.py", line 38, in <module>
response = urllib2.urlopen(req)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 124, in urlopen
return _opener.open(url, data)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 387, in open
response = meth(req, response)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 498, in http_response
'http', request, response, code, msg, hdrs)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 425, in error
return self._call_chain(*args)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 360, in _call_chain
result = func(*args)
File "/base/python_runtime/python_dist/lib/python2.5/urllib2.py", line 506, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
It could be related to this problem: freebase api error on deployment to appengine: DownloadError: ApplicationError: 2 in which case adding an api key to the request could fix it. Though my attempt to add a key (using urlfetch) resulted in an error:
{u'code': 100, u'message': u'Invalid API Key (Key not found)', u'stat': u'fail'}.
I registered the freebase service and added the Simple API key for browser apps to the query: '&key=apikeystringhere'. I've added the key issue as a separate question: Setup api key for freebase queries from appengine
Why not use the urlfetch API rather than urllib2?
I have it working now. It was not working on the remote because I needed a key. My previous attempt to add the key failed because i was using the deprecated http://api.freebase.com API when I should have been using: https://www.googleapis.com/freebase/v1/search?q=bob&key=

Memcache not present in App-Engine-Patch?

I'm trying to store a date into memcache using the following code:
from datetime import date
from google.appengine.api.memcache import Client
MEMCACHE_DATE_KEY = 'date'
client = Client()
def last_date():
return client.get(MEMCACHE_DATE_KEY)
def new_date():
client.set(MEMCACHE_DATE_KEY, date.today())
I am getting this error:
Traceback (most recent call last):
File "manage.py", line 4, in
setup_env(manage_py_env=True)
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/aecmd.py", line 67, in setup_env
patch_all()
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/appenginepatcher/patch.py", line 29, in patch_all
patch_app_engine()
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/appenginepatcher/patch.py", line 520, in patch_app_engine
db.Model._meta = _meta(db.Model, ())
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/appenginepatcher/patch.py", line 258, in __init__
settings.INSTALLED_APPS
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/utils/functional.py", line 269, in __getattr__
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/conf/__init__.py", line 40, in _setup
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/conf/__init__.py", line 73, in __init__
File "/Users/benji/Projects/share-renting-engine/common/zip-packages/django-1.1.zip/django/utils/importlib.py", line 35, in import_module
File "/Users/benji/Projects/share-renting-engine/settings.py", line 120, in
from ragendja.settings_post import *
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/ragendja/settings_post.py", line 98, in
check_app_imports(app)
File "/Users/benji/Projects/app-engine-patch-sample/common/appenginepatch/ragendja/settings_post.py", line 63, in check_app_imports
__import__(app, {}, {}, [''])
File "/Users/benji/Projects/share-renting-engine/engine/__init__.py", line 5, in
if date.today() != last_date():
File "/Users/benji/Projects/share-renting-engine/engine/utils/date.py", line 12, in last_date
return client.get(MEMCACHE_DATE_KEY)
File "/Users/benji/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/memcache/__init__.py", line 428, in get
self._make_sync_call('memcache', 'Get', request, response)
File "/Users/benji/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 86, in MakeSyncCall
return stubmap.MakeSyncCall(service, call, request, response)
File "/Users/benji/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 279, in MakeSyncCall
assert stub, 'No api proxy found for service "%s"' % service
AssertionError: No api proxy found for service "memcache"
How can i use memcache with app-engine-patch?
Thanks for your time.
It looks like you're attempting to make a memcache call at import time. Judging from the stacktrace, Django imports your modules before it sets up the App Engine environment, and therefore any calls to App Engine services at the module level will fail on the development server.
Move the call to memcache inside a function that's called from a request handler, and it should resolve your problem.

Resources