Kivy osc running server and gui on Android simultaneous - python-2.7

I want to run a simulation server and a GUI that responds to the messages of- and influences the server through messages on Android with Kivy and osc.
Question
Basically my problem comes down to: I can't run both scripts at the same time. How do I do this?
The GUI: https://github.com/PdeRooij/DMAS/blob/GUI/main.py
The server: https://github.com/PdeRooij/DMAS/blob/GUI/service/main.py#L55-L114
Relevant code GUI:
def start_service(self):
if platform == 'android':
from android import AndroidService
service = AndroidService('Agent emergence service', 'running')
service.start('service started')
self.service = service
If I build it with buildozer, only the GUI runs. In Ubuntu I would just open 2 terminals and run: python model/main.py and python main.py. How can I also let model/main.py run in the android .apk?
I think I should do something with: def start_service(self):, but I don't know what. Also for some reason PyCharm underlines this in red: from android import AndroidService.
Example that didn't work for me on Android
https://github.com/tshirtman/kivy_service_osc
Specs
Python 2.7.6
Ubuntu 14.04
PPA: Kivy-daily

The problem lays in that AndroidService looks for service/main.py. So renaming the folder 'model' to 'service' did the trick.
Interesting to know is that the service doesn't need to have any Kivy code in it. 'from kivy.lib import osc' can be replaced for 'import osc' (which is copied from kivy, but all dependencies removed/replaced).
https://github.com/PdeRooij/DMAS/tree/GUI/service/osc

Related

Why am I getting an import error when trying to use react-native-maps?

Quick version:
expo init MyNewProject
cd MyNewProject
expo install react-native-maps
add import MapView from 'react-native-maps' to the top of my App.js, save/reload and I get the following error screen, along with this warning in the Expo Dev Tools
C:/Users/MyUser/Projects/current/MapTest/node_modules/react-native-maps/lib/components/MapView.js
Attempted import error: 'requireNativeComponent' is not exported from 'react-native-web/dist/index'.
:
Long Version:
I created a brand new react-native app using expo, via expo init MyNewProject and chose a blank template. I then installed react-native-maps into my project directory as detailed here, https://docs.expo.io/versions/latest/sdk/map-view/, by running expo install react-native-maps. At this point I haven't touched the code, other than adding an import in my App.js for the MapView component import MapView from 'react-native-maps'. Now, when I save/reload the app, it dies. What's happening?? Am I missing something or is this a bug?
React Native Maps doesn’t support the web. You can use React Native Web Maps for the platform difference in the meantime.

compiled django application fails to run ASGI channels

I'm building a django application using Pyinstaller.
When I run the application i get an error from dapne server.
"daphne\server.py:13: UserWarning: Something has already installed a non-asyncio Twisted reactor. Attempting to uninstall it; you can fix this warning by importing daphne.server early in your codebase or finding the package that imports Twisted and importing it later on."
In addition, when I compare the console log of the EXE application and a regular run of the django application I notice the following difference.
In the regular run which works as expected I see the following print:
"Django version 2.1.5, using settings 'cfehome.settings'
Starting ASGI/Channels version 2.1.5 development server at http://0.0.0.0:8000/"
however, when I run the application from the EXE I see:
"Django version 2.1.5, using settings 'cfehome.settings'
Starting development server at http://0.0.0.0:8000/"
Appreciate any lead to understand this behavior and ways to fix it.
I know this is old but for others seeking answer. There's a simple fix:
Before importing raven in settings.py, import daphne.server So, your settings.py will look like this:
import daphne.server
import raven
For further information you can read: https://github.com/django/channels/issues/793
I hope it will help.

flask development single terminal: continue editing Code without quitting flask

Background: I am new to Flask (and fairly new to python, linux terminal, servers). I have gone through the tutorial http://flask.pocoo.org/docs/1.0/tutorial/.
I am developing on raspberry pi 3, via putty from my PC.
I run flask, according to the tutorial:
export FLASK_APP=flaskr
export FLASK_ENV=development
flask run
According to the tutorial I can make changes to the code and the server will automatically reload.
My issue: I don't know how to make changes to my code without stopping Flask (ctrl+c).
How can I leave Flask, return to the Linux Terminal, edit my code, and then return to the Flask Debugger without stopping Flask each time?
I have reviewed the Flask Docs http://flask.pocoo.org/docs/1.0/ to no avail.
Thanks,
You has to enable the debug mode. Default debug is True in flask
app.run(debug=True) or export DEBUG=True
you can go through this link for Flask configuration
http://flask.pocoo.org/docs/1.0/config/#configuring-from-environment-variables
If you are using Flask >=1.0v you need to set environment in development mode.
export FLASK_ENV='development'

Python 2.7.14 on Raspbian

My client has an application developed on python2.7.14, and I'm trying to run it on a raspberry.
When I run it on python2.7.9 it has some interface problems, so I installed python2.7.14 exactly as said in this link: https://tecadmin.net/install-python-2-7-on-ubuntu-and-linuxmint/
Now, when I run the application on python2.7.14 it says that I don't have module RPi.GPIO and PIL, and when I try to install/update it says it's already installed.
How can I solve this?

Flask running on a different console?

I am using Flask using pythonanywhere (https://www.pythonanywhere.com) and I noticed that everytime I launch a Flask application, it runs on Python3.4 console.
Is it possible to switch the console such that the Flask application I'm building would run on different python consoles such as python 2.7?
The reason is that one of the libraries I need to import is cv2 (opencv) and python3.4 console does not seem to have it installed while python 2.7 does.
Does anyone have any idea of how to do this?
Thank you in advance!