Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Web2py
-
I downloaded Web2py and, lo and behold, it runs without Tk by starting a web server and all editing can be done there. The problem is that after a short time the script stops and I get the notification that the script has been stopped by the background timer. Is there any way to disable the timer or any other clever way to keep the server running?
-
As far as I know that is the iOS background process management shutting Pythonista down because it has been in background for too long, so there's nothing you can directly do against that. I think RAM usage somehow influences how long apps are kept alive, i. e. if the foreground app needs RAM iOS starts kicking out some background apps.
A possible way to keep Pythonista alive would be to get some audio file into the script library and play it with quick look on infinite loop. That should make Pythonista the active background audio app and prevent it from being terminated automatically.
-
Interesting idea that is definitely worth trying. So I move an audio file into the script library and then do exactly what to play it in a loop while running the web2py script?
-
The clip should be in a format that can be opened by the default file viewer, e. g. wav, mp3, m4a. Open that and you should get the regular playback controls, one of which is repeat. (I might be mistaken, perhaps the repeat button is only available in the Music app and not in the iOS file viewer...)
-
I placed a .aiff file in the script library. When I open it the ios player starts and I can play the file but there is no option for looping.
-
This won't work. Audio playback has to be declared as a background mode explicitly, and Pythonista doesn't do this.
-
@omz so, there is no way to keep the web2py webserver running in Pythonista?
-
I thought I'd try a way around this problem of the background timer by opening the browser from Pythonista. I thought that maybe that would appear to IOS as Pythonista being in the foreground and therefore would not terminate the script. However, when I added a line to web2py to say webbrowser.open('http://127.0.0.1:8000'), it says server could not be found. I tried adding a delay with the same result. However, if I switch to Safari it opens just fine. What am I missing?
-
Have you tried sebastian's browser?
-
@omz so, there is no way to keep the web2py webserver running in Pythonista?
No, there is no way to do that except for keeping the app open in the foreground.
-
I may be mistaken but based on my limited testing, opening the browser from Pythonista does indeed keep the IOS background timer from terminating the thread. However, a further problem is that the browser window that web2py opens is using Safari which does not seem to be able to display all of the page (maybe frames are not showing up). Opening the server from Atomic Web works fine so the next problem would be finding a way to open the server page from Pythonista using something other than Safari.
If anyone has the time/inclination, try downloading web2y (I used wget http://www.web2py.com/examples/static/web2py_src.zip using stash, unzipped the file and simply ran web2py.py. You can then switch to Safari to see the page at localhost:8000 but IOS will stop the script after a bit. In order to open a browser window from Pythonista and thereby avoid the IOS background timer, I added a webbrowser.open line in gluon.widget.py.
-
The problem I am having seems to be the useragent string that Webkit is using. It needs to be a desktop useragent. I tested changing the useragent string for Safari and with that change Safari works properly with web2py. However, if I am to use the Pythonista instance of the browser, then webkit must send a modified useragent string. There may be a way to change the webkit invocation to provide this string as an option. Any chance that Pythonista could permit this? I am also looking into how web2py can be made to treat the default mobile safari useragent from iPad as a dekstop.