2016-03-21 48 views
0

我有这个项目运行在Google App Engine上,但是当我在本地运行代码以在部署它之前测试错误时,日志不会给出任何错误,代码工作正常。GAE给出了一个错误,没有收到本地测试

当我部署它,GAE给我一个NoneType错误。我有一个修复这个错误,但我不明白的是为什么我会在部署后得到错误,而不是本地?

logal日志:

2016-03-21 21:00:34,466 urlfetch_stub.py:540] Stripped prohibited headers from URLFetch request: ['Host', 'Content-Length'] 
INFO  2016-03-21 21:00:34,671 module.py:787] default: "GET /testmsg HTTP/1.1" 200 - 

成功,没有任何错误。

GAE日志:

Traceback (most recent call last): 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1535, in __call__ 
rv = self.handle_exception(request, response, e) 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1529, in __call__ 
rv = self.router.dispatch(request, response) 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1278, in default_dispatcher 
return route.handler_adapter(request, response) 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 1102, in __call__ 
return handler.dispatch() 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 572, in dispatch 
return self.handle_exception(e, self.app.debug) 
File "/base/data/home/runtimes/python27/python27_lib/versions/third_party/webapp2-2.5.2/webapp2.py", line 570, in dispatch 
return method(*args, **kwargs) 
File "/base/data/home/apps/e~thalia-bot/1.391538208721323325/main.py", line 84, in post 
textlower = text.lower() 
AttributeError: 'NoneType' object has no attribute 'lower' 

代码:

text = message.get('text') #Text that the bot will receive 
textlower = text.lower() #Convert the text to lowercase 

编辑:

几个重新部署后(使用不同的代码),它在不改变原来的代码工作正常。在GAE上给我错误的代码现在正常工作。但是它的不确定性,因为未来的部署将再次引发同样的问题。现在我更加困惑,有没有人发现这里出了什么问题?

回答

0

GAE错误与部署本身没有太大关系,但与text(即message.get('text')的结果)是None或没有关系。

相同的代码在重新部署后工作的事实很可能只是其他被更改的指示,例如它可能是请求正在进行。

在致电text.lower()之前,尝试显示text的值,在两种情况下您可能会看到它的值不同 - 再次,与部署本身无关。

+0

我明白你的意思了,这很有道理,生病了吧,谢谢! – Kevin

相关问题