[web2py] Re: AWS Lambda Serverless and Zappa
On Saturday, September 8, 2018 at 2:47:55 PM UTC-5, Anthony wrote: > > You can use InDBMigrator (see > https://groups.google.com/d/msg/web2py/lZnL4hRloSc/SSEBnIM0CQAJ). Also, > rather than edit main.py, you can just ensure all the folders are there to > begin with. Finally, make sure to put sessions in cookies or the database. > > Anthony > > On Saturday, September 8, 2018 at 3:30:28 AM UTC-4, appj...@gmail.com > wrote: >> >> I am trying to migrate my Web2Py app from Heroku to AWS Lambda, using >> Zappa. I can get it to start running, but I'm running into errors because >> web2py is trying to write to the filesystem: >> >> >> [Errno 30] Read-only file system: '/var/task/deposit': OSError >> Traceback (most recent call last): >> File "/var/task/handler.py", line 574, in lambda_handler >> return LambdaHandler.lambda_handler(event, context) >> File "/var/task/handler.py", line 244, in lambda_handler >> handler = cls() >> File "/var/task/handler.py", line 150, in __init__ >> import gluon.main >> File "/var/task/gluon/main.py", line 64, in >> create_missing_folders() >> File "C:\web2py\gluon\admin.py", line 460, in create_missing_folders >> File "C:\web2py\gluon\admin.py", line 454, in try_mkdir >> OSError: [Errno 30] Read-only file system: '/var/task/deposit'. >> >> So I commented out the following functions from gluon/main.py >> >> create_missing_app_folders() >> and >> create_missing_folders() >> >> >> However, now I'm getting stuck with the DB trying to create tables: >> >> >> [ERROR] 2018-09-08T07:05:35.270Z 905ef1e6-b335-11e8-816d-07b31200db80 >> Traceback (most recent call last): >> File "/var/task/gluon/restricted.py", line 219, in restricted >> exec(ccode, environment) >> File "/var/task/applications/ads/models/db.py", line 72, in >> session.connect(request, response, db=db) >> File "C:\web2py\gluon\globals.py", line 946, in connect >> File "/var/task/gluon/packages/dal/pydal/base.py", line 587, in >> define_table >> table = self.lazy_define_table(tablename, *fields, **args) >> File "/var/task/gluon/packages/dal/pydal/base.py", line 621, in >> lazy_define_table >> polymodel=polymodel) >> File "/var/task/gluon/packages/dal/pydal/adapters/base.py", line 797, in >> create_table >> return self.migrator.create_table(*args, **kwargs) >> File "/var/task/gluon/packages/dal/pydal/migrator.py", line 275, in >> create_table >> query), table) >> File "/var/task/gluon/packages/dal/pydal/migrator.py", line 483, in log >> logfile = self.file_open(table._loggername, 'ab') >> File "/var/task/gluon/packages/dal/pydal/migrator.py", line 491, in >> file_open >> fileobj = portalocker.LockedFile(filename, mode) >> File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line >> 185, in __init__ >> File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line >> 170, in open_file >> IOError: [Errno 2] No such file or directory: >> '/var/task/applications/ads/databases/sql.log' >> >> >> Is this a never-ending rabbit hole or is there a way to tell web2py that >> it cannot write to the filesystem. I tried >> global_setttings.web2py_runtime_gae=True >> >> but that causes a bunch of other problems because GAE resources are not >> present. >> >> I'd love to get this on AWS Lambda because my application can have >> temporary 1000x spikes in traffic and Serverless lets me handle this >> without ops and without paying for idle server time in the evenings. >> >> If I can get this working I will post a deployment recipe. >> >> Thanks, >> -Mike >> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: AWS Lambda Serverless and Zappa
Thank you Anthony! That got me past the filesystem issues. Now it seems like I'm stuck in gluon._compat and urllib. It is having problems importing. cannot import name urllib_quote_plus: ImportError Traceback (most recent call last): File "/var/task/handler.py", line 585, in lambda_handler return LambdaHandler.lambda_handler(event, context) File "/var/task/handler.py", line 255, in lambda_handler handler = cls() File "/var/task/handler.py", line 138, in __init__ self.app_module = importlib.import_module(self.settings.APP_MODULE) File "/usr/lib64/python2.7/importlib/__init__.py", line 37, in import_module __import__(name) File "C:\web2py\gluon\__init__.py", line 40, in File "C:\web2py\gluon\compileapp.py", line 44, in File "/var/task/gluon/rewrite.py", line 29, in from gluon._compat import urllib_unquote, urllib_quote, iteritems, xrange, urllib_quote_plus ImportError: cannot import name urllib_quote_plus Here is my sys.path: ['/var/task', '/var/runtime/awslambda', '/var/runtime', '/usr/lib/python27.zip', '/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2', '/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old', '/usr/lib64/python2.7/lib-dynload', '/usr/local/lib64/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages', '/usr/lib64/python2.7/site-packages', '/usr/lib/python2.7/site-packages', '/usr/lib64/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages'] I was worried this is because the vitualenv has urllib3 a requirement for zappa. However, I had a similar problem on importing "reload" from gluon._compat as well and had to comment out that import along with its usage in utf8.py. On Saturday, September 8, 2018 at 2:47:55 PM UTC-5, Anthony wrote: > > You can use InDBMigrator (see > https://groups.google.com/d/msg/web2py/lZnL4hRloSc/SSEBnIM0CQAJ). Also, > rather than edit main.py, you can just ensure all the folders are there to > begin with. Finally, make sure to put sessions in cookies or the database. > > Anthony > > On Saturday, September 8, 2018 at 3:30:28 AM UTC-4, appj...@gmail.com > wrote: >> >> I am trying to migrate my Web2Py app from Heroku to AWS Lambda, using >> Zappa. I can get it to start running, but I'm running into errors because >> web2py is trying to write to the filesystem: >> >> >> [Errno 30] Read-only file system: '/var/task/deposit': OSError >> Traceback (most recent call last): >> File "/var/task/handler.py", line 574, in lambda_handler >> return LambdaHandler.lambda_handler(event, context) >> File "/var/task/handler.py", line 244, in lambda_handler >> handler = cls() >> File "/var/task/handler.py", line 150, in __init__ >> import gluon.main >> File "/var/task/gluon/main.py", line 64, in >> create_missing_folders() >> File "C:\web2py\gluon\admin.py", line 460, in create_missing_folders >> File "C:\web2py\gluon\admin.py", line 454, in try_mkdir >> OSError: [Errno 30] Read-only file system: '/var/task/deposit'. >> >> So I commented out the following functions from gluon/main.py >> >> create_missing_app_folders() >> and >> create_missing_folders() >> >> >> However, now I'm getting stuck with the DB trying to create tables: >> >> >> [ERROR] 2018-09-08T07:05:35.270Z 905ef1e6-b335-11e8-816d-07b31200db80 >> Traceback (most recent call last): >> File "/var/task/gluon/restricted.py", line 219, in restricted >> exec(ccode, environment) >> File "/var/task/applications/ads/models/db.py", line 72, in >> session.connect(request, response, db=db) >> File "C:\web2py\gluon\globals.py", line 946, in connect >> File "/var/task/gluon/packages/dal/pydal/base.py", line 587, in >> define_table >> table = self.lazy_define_table(tablename, *fields, **args) >> File "/var/task/gluon/packages/dal/pydal/base.py", line 621, in >> lazy_define_table >> polymodel=polymodel) >> File "/var/task/gluon/packages/dal/pydal/adapters/base.py", line 797, in >> create_table >> return self.migrator.create_table(*args, **kwargs) >> File "/var/task/gluon/packages/dal/pydal/migrator.py", line 275, in >> create_table >> query), table) >> File "/var/task/gluon/packages/dal/pydal/migrator.py", line 483, in log >> logfile = self.file_open(table._loggername, 'ab') >> File "/var/task/gluon/packages/dal/pydal/migrator.py", line 491, in >> file_open >> fileobj = portalocker.LockedFile(filename, mode) >> File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line >> 185, in __init__ >> File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line >> 170, in open_file >> IOError: [Errno 2] No such file or directory: >> '/var/task/applications/ads/databases/sql.log' >> >> >> Is this a never-ending rabbit hole or is there a way to tell web2py that >> it cannot write to the filesystem. I tried >> global_setttings.web2py_runtime_gae=True >> >> but that causes a bunch of other problems because GAE resources are not >> present. >> >> I'd love to get this on AWS Lambda because my application can have >> temporary 1000x spikes in traffic
[web2py] Re: AWS Lambda Serverless and Zappa
You can use InDBMigrator (see https://groups.google.com/d/msg/web2py/lZnL4hRloSc/SSEBnIM0CQAJ). Also, rather than edit main.py, you can just ensure all the folders are there to begin with. Finally, make sure to put sessions in cookies or the database. Anthony On Saturday, September 8, 2018 at 3:30:28 AM UTC-4, appjar...@gmail.com wrote: > > I am trying to migrate my Web2Py app from Heroku to AWS Lambda, using > Zappa. I can get it to start running, but I'm running into errors because > web2py is trying to write to the filesystem: > > > [Errno 30] Read-only file system: '/var/task/deposit': OSError > Traceback (most recent call last): > File "/var/task/handler.py", line 574, in lambda_handler > return LambdaHandler.lambda_handler(event, context) > File "/var/task/handler.py", line 244, in lambda_handler > handler = cls() > File "/var/task/handler.py", line 150, in __init__ > import gluon.main > File "/var/task/gluon/main.py", line 64, in > create_missing_folders() > File "C:\web2py\gluon\admin.py", line 460, in create_missing_folders > File "C:\web2py\gluon\admin.py", line 454, in try_mkdir > OSError: [Errno 30] Read-only file system: '/var/task/deposit'. > > So I commented out the following functions from gluon/main.py > > create_missing_app_folders() > and > create_missing_folders() > > > However, now I'm getting stuck with the DB trying to create tables: > > > [ERROR] 2018-09-08T07:05:35.270Z 905ef1e6-b335-11e8-816d-07b31200db80 > Traceback (most recent call last): > File "/var/task/gluon/restricted.py", line 219, in restricted > exec(ccode, environment) > File "/var/task/applications/ads/models/db.py", line 72, in > session.connect(request, response, db=db) > File "C:\web2py\gluon\globals.py", line 946, in connect > File "/var/task/gluon/packages/dal/pydal/base.py", line 587, in > define_table > table = self.lazy_define_table(tablename, *fields, **args) > File "/var/task/gluon/packages/dal/pydal/base.py", line 621, in > lazy_define_table > polymodel=polymodel) > File "/var/task/gluon/packages/dal/pydal/adapters/base.py", line 797, in > create_table > return self.migrator.create_table(*args, **kwargs) > File "/var/task/gluon/packages/dal/pydal/migrator.py", line 275, in > create_table > query), table) > File "/var/task/gluon/packages/dal/pydal/migrator.py", line 483, in log > logfile = self.file_open(table._loggername, 'ab') > File "/var/task/gluon/packages/dal/pydal/migrator.py", line 491, in > file_open > fileobj = portalocker.LockedFile(filename, mode) > File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line > 185, in __init__ > File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line > 170, in open_file > IOError: [Errno 2] No such file or directory: > '/var/task/applications/ads/databases/sql.log' > > > Is this a never-ending rabbit hole or is there a way to tell web2py that > it cannot write to the filesystem. I tried > global_setttings.web2py_runtime_gae=True > > but that causes a bunch of other problems because GAE resources are not > present. > > I'd love to get this on AWS Lambda because my application can have > temporary 1000x spikes in traffic and Serverless lets me handle this > without ops and without paying for idle server time in the evenings. > > If I can get this working I will post a deployment recipe. > > Thanks, > -Mike > > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Re: Problem with wsgihandler.py Apache/Python3
Try to remove all session files. I think that problem is in pickle which is different in python 2 and python 3 (data type is not same in python 2 and python 3). -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] Python loop brings an error
AM trying out a now game that involves a continuous input of data with an instant display to the user of an image or data from the db. How ever, when trying out a small bit of code, before I developed it to full scale, I noticed something strange. This is the code: results = [] r_lst = [] rlst3 = [] m = [] ffvector = ['vector','vectors','transmit','transmission','port','pots'] ffdef = ['mercedes','bmw','ford','honda','gmc',] def report(): db = DAL('sqlite://storage.sqlite')#, migrate=False) db = current.db auth = Auth(db, hmac_key=Auth.get_or_create_key()) auth.define_tables() rows = db(db.post.author == auth.user.id).select(db.post.ALL) for row in rows: id = row.message m.append(id) rlst = [' '.join(grams)for grams in ngrams(word_tokenize(m[0]),1)] rlst3.extend(rlst) for item in rlst3: if item not in ffvector: pass else: vects = 'We will be getting vectors values here.' results.append(vects) if item not in ffdef: pass else: defi = 'first thoughts will be here' results.append(defi) return results if results else 'Item not found here again, ', rlst3 controller code form = FORM(INPUT(_name='message'), INPUT(_type='submit')) if request.vars: r.append(request.vars.message) codes.append(r[0]) db.post.insert(message=codes[0]) return dict(form=form, cars=cars) This is what I note: 1. If I post values in the ffvector or ffdef, the reply back to the user is ok. 2. The moment I type any text not in the above lists, I start getting the same previously replies data. 3. When continuously typing text not in the lists, the replies are ok as coded, but typing randomly text in and not in the lists the replies are not as expected. What could be the error and how do i correct them. Regards -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[web2py] AWS Lambda Serverless and Zappa
I am trying to migrate my Web2Py app from Heroku to AWS Lambda, using Zappa. I can get it to start running, but I'm running into errors because web2py is trying to write to the filesystem. I commented out create_missing_app_folders() and create_missing_folders() from gluon/main.py, however, now I'm getting stuck with the DB trying to create tables. [ERROR] 2018-09-08T07:05:35.270Z 905ef1e6-b335-11e8-816d-07b31200db80 Traceback (most recent call last): File "/var/task/gluon/restricted.py", line 219, in restricted exec(ccode, environment) File "/var/task/applications/ads/models/db.py", line 72, in session.connect(request, response, db=db) File "C:\web2py\gluon\globals.py", line 946, in connect File "/var/task/gluon/packages/dal/pydal/base.py", line 587, in define_table table = self.lazy_define_table(tablename, *fields, **args) File "/var/task/gluon/packages/dal/pydal/base.py", line 621, in lazy_define_table polymodel=polymodel) File "/var/task/gluon/packages/dal/pydal/adapters/base.py", line 797, in create_table return self.migrator.create_table(*args, **kwargs) File "/var/task/gluon/packages/dal/pydal/migrator.py", line 275, in create_table query), table) File "/var/task/gluon/packages/dal/pydal/migrator.py", line 483, in log logfile = self.file_open(table._loggername, 'ab') File "/var/task/gluon/packages/dal/pydal/migrator.py", line 491, in file_open fileobj = portalocker.LockedFile(filename, mode) File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line 185, in __init__ File "C:\web2py\gluon\packages\dal\pydal\contrib\portalocker.py", line 170, in open_file IOError: [Errno 2] No such file or directory: '/var/task/applications/ads/databases/sql.log' Is this a never-ending rabbit hole or is there a way to tell web2py that it cannot write to the filesystem. I tried global_setttings.web2py_runtime_gae=True but that causes a bunch of other problems because GAE resources are not present. I'd love to get this on AWS Lambda because my application can have temporary 1000x spikes in traffic and Serverless lets me handle this without ops and without paying for idle server time in the evenings. If I can get this working I will post a deployment recipe. Thanks, -Mike -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.