Commit 1046ed1e authored by Philipp Auersperg's avatar Philipp Auersperg
parents 5a26fea0 d9b17d57
......@@ -35,8 +35,8 @@ version = 0.1
# version.filename = %(source.dir)s/main.py
# (list) Application requirements
# comma seperated e.g. requirements = sqlite3,kivy
requirements = kivy, plyer, jnius, android, git+https://github.com/zworkb/procbridge-python.git
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy,plyer, jnius
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
......@@ -51,11 +51,10 @@ requirements = kivy, plyer, jnius, android, git+https://github.com/zworkb/procbr
# (str) Icon of the application
#icon.filename = %(source.dir)s/data/icon.png
# (str) Supported orientation (one of landscape, portrait or all)
# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = portrait
# (list) List of service to declare
#services = NAME:ENTRYPOINT_TO_PY,NAME2:ENTRYPOINT2_TO_PY
services = TestServ:serv.py
#
# OSX Specific
......@@ -87,17 +86,20 @@ fullscreen = 0
# (list) Permissions
android.permissions = INTERNET
# (int) Android API to use
android.api = 19
# (int) Target Android API, should be as high as possible.
#android.api = 27
# (int) Minimum API required
android.minapi = 19
# (int) Minimum API your APK will support.
#android.minapi = 21
# (int) Android SDK version to use
android.sdk = 24
#android.sdk = 20
# (str) Android NDK version to use
android.ndk = 15b
#android.ndk = 17c
# (int) Android NDK API to use. This is the minimum API your app will support, it should usually match android.minapi.
#android.ndk_api = 21
# (bool) Use --private data storage (True) or --dir public storage (False)
#android.private_storage = True
......@@ -116,6 +118,12 @@ android.ndk = 15b
# when an update is due and you just want to test/build your package
# android.skip_update = False
# (bool) If True, then automatically accept SDK license
# agreements. This is intended for automation only. If set to False,
# the default, you will be shown the license when first running
# buildozer.
# android.accept_sdk_license = False
# (str) Android entry point, default is ok for Kivy-based app
#android.entrypoint = org.renpy.android.PythonActivity
......@@ -149,8 +157,8 @@ android.ndk = 15b
# (list) Java classes to add as activities to the manifest.
#android.add_activites = com.example.ExampleActivity
# (str) python-for-android branch to use, defaults to stable
#p4a.branch = stable
# (str) python-for-android branch to use, defaults to master
#p4a.branch = master
# (str) OUYA Console category. Should be one of GAME or APP
# If you leave this blank, OUYA support will not be enabled
......@@ -165,7 +173,7 @@ android.ndk = 15b
# (str) launchMode to set for the main activity
#android.manifest.launch_mode = standard
# (list) Android additionnal libraries to copy into libs/armeabi
# (list) Android additional libraries to copy into libs/armeabi
#android.add_libs_armeabi = libs/android/*.so
#android.add_libs_armeabi_v7a = libs/android-v7/*.so
#android.add_libs_x86 = libs/android-x86/*.so
......@@ -217,6 +225,16 @@ p4a.source_dir = /home/phil/p4a
# (str) Path to a custom kivy-ios folder
#ios.kivy_ios_dir = ../kivy-ios
# Alternately, specify the URL and branch of a git checkout:
ios.kivy_ios_url = https://github.com/kivy/kivy-ios
ios.kivy_ios_branch = master
# Another platform dependency: ios-deploy
# Uncomment to use a custom checkout
#ios.ios_deploy_dir = ../ios_deploy
# Or specify URL and branch
ios.ios_deploy_url = https://github.com/phonegap/ios-deploy
ios.ios_deploy_branch = 1.7.0
# (str) Name of the certificate to use for signing the debug version
# Get a list of available identities: buildozer ios list_identities
......
......@@ -8,17 +8,21 @@ from kivy.logger import Logger
Logger.setLevel(logging.INFO)
def start_service():
print 'starting service...'
print('starting service...')
if platform == 'android':
from jnius import autoclass
service = autoclass('org.bd.servicetest.ServiceTestserv')
mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
argument = ''
res=service.start(mActivity, argument)
print 'service started:', res
print('service started:', res)
else:
Logger.error("wrong platform:"+platform)
def start_service_locally():
import serv
serv.runit()
Builder.load_string("""
<MainWindow>:
Button:
......
......@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
......@@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
......@@ -20,7 +20,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
......@@ -33,12 +33,47 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"java.lang.RuntimeException: Socket can not be connected.\n",
"\tat co.gongzh.procbridge.ProcBridge.<init>(ProcBridge.java:64)\n",
"Caused by: java.net.SocketTimeoutException: connect timed out\n",
"\tat java.net.PlainSocketImpl.socketConnect(Native Method)\n",
"\tat java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)\n",
"\tat java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)\n",
"\tat java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)\n",
"\tat java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)\n",
"\tat java.net.Socket.connect(Socket.java:589)\n",
"\tat co.gongzh.procbridge.ProcBridge.<init>(ProcBridge.java:56)\n",
"\tat Line_10.<init>(Unknown Source)\n",
"\tat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)\n",
"\tat sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)\n",
"\tat sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)\n",
"\tat java.lang.reflect.Constructor.newInstance(Constructor.java:422)\n",
"\tat org.jetbrains.kotlin.cli.common.repl.GenericReplEvaluator.eval(GenericReplEvaluator.kt:95)\n",
"\tat org.jetbrains.kotlin.cli.common.repl.GenericReplCompilingEvaluator.eval(GenericReplCompilingEvaluator.kt:74)\n",
"\tat org.jetbrains.kotlin.cli.common.repl.GenericReplCompilingEvaluator.compileAndEval(GenericReplCompilingEvaluator.kt:49)\n",
"\tat uy.kohesive.keplin.kotlin.script.SimplifiedRepl.compileAndEval(SimplifiedRepl.kt:113)\n",
"\tat uy.kohesive.keplin.kotlin.script.SimplifiedRepl.compileAndEval$default(SimplifiedRepl.kt:112)\n",
"\tat org.jetbrains.kotlin.jupyter.ReplForJupyter.eval(repl.kt:41)\n",
"\tat org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt:61)\n",
"\tat org.jetbrains.kotlin.jupyter.ProtocolKt$shellMessagesHandler$res$1.invoke(protocol.kt)\n",
"\tat org.jetbrains.kotlin.jupyter.ProtocolKt.evalWithIO(protocol.kt:165)\n",
"\tat org.jetbrains.kotlin.jupyter.ProtocolKt.shellMessagesHandler(protocol.kt:60)\n",
"\tat org.jetbrains.kotlin.jupyter.IkotlinKt.kernelServer(ikotlin.kt:83)\n",
"\tat org.jetbrains.kotlin.jupyter.IkotlinKt.main(ikotlin.kt:41)"
]
}
],
"source": [
"// val host = \"127.0.0.1\"\n",
"val host = \"192.168.1.19\"\n",
"val host = \"192.168.1.29\"\n",
"// val host = \"idefix\"\n",
"\n",
"val port = 8077\n",
"val timeout = 10000 // 10 seconds\n",
......@@ -60,7 +95,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
......@@ -85,9 +120,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 9,
"metadata": {},
"outputs": [],
"outputs": [
{
"data": {
"text/plain": [
"{\"result\":15}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"res2.get()"
]
......
import socket
import json
import threading
import logging
logger=logging.getLogger("TestServ")
logger.setLevel(logging.INFO)
logger.info("hopp")
_STATUS_CODE_REQUEST = 0
_STATUS_CODE_GOOD_RESPONSE = 1
......@@ -300,6 +306,7 @@ class ProcBridgeServer:
self.runlock = threading.Lock()
def start(self):
print("procbridge start")
self.lock.acquire()
try:
if self.started:
......@@ -307,7 +314,8 @@ class ProcBridgeServer:
self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
self.socket.bind((self.host, self.port))
# self.socket.bind((self.host, self.port))
self.socket.bind(('', self.port))
self.socket.listen(0)
t = threading.Thread(target=_start_server_listener, args=(self,))
t.start()
......@@ -354,14 +362,19 @@ def _start_server_listener(server):
:return:
"""
try:
print("start_server_listener:",server)
while True:
print("start_server_listener: before server.lock")
server.lock.acquire()
print("start_server_listener: after server.lock, server started?:", server.started)
if not server.started:
return
server.lock.release()
# assert started == true:
print("start_server_listener: before socket accept: server socket:", server.socket)
conn, _ = server.socket.accept()
print("start_server_listener: after socket accept:", conn)
t = threading.Thread(target=_start_connection, args=(server, conn,))
t.start()
# except ConnectionAbortedError:
......@@ -419,8 +432,11 @@ def _start_connection(server, s):
:return: None
"""
try:
print("_start_connection")
while server.started:
print("start_connectino: before read_request")
api, body = _read_request(s)
print("start_connectino: after read_request:", api, body)
print('api:', api, body)
if api == API_CLOSE:
print('closing')
......@@ -451,6 +467,7 @@ def _start_connection(server, s):
_write_bad_response(s, str(ex), resp_to=resp_to)
except Exception as e: #TODO: fix that seriously
print("start_connection:",str(e))
raise
finally:
s.close()
......@@ -36,7 +36,7 @@ version = 0.1
# (list) Application requirements
# comma separated e.g. requirements = sqlite3,kivy
requirements = python3,kivy
requirements = python3
# (str) Custom source folders for requirements
# Sets custom source for any requirements with recipes
......@@ -52,7 +52,7 @@ requirements = python3,kivy
#icon.filename = %(source.dir)s/data/icon.png
# (str) Supported orientation (one of landscape, sensorLandscape, portrait or all)
orientation = portrait
# orientation = portrait
# (list) List of service to declare
services = TestP3Serv:servp3.py
......@@ -75,7 +75,7 @@ osx.kivy_version = 1.9.1
#
# (bool) Indicate if the application should be fullscreen or not
fullscreen = 0
# fullscreen = 0
# (string) Presplash background color (for new android toolchain)
# Supported formats are: #RRGGBB #AARRGGBB or one of the following names:
......@@ -205,7 +205,7 @@ android.arch = armeabi-v7a
#
# (str) python-for-android git clone directory (if empty, it will be automatically cloned from github)
#p4a.source_dir =
p4a.source_dir = /home/phil/p4a
# (str) The directory in which python-for-android should look for your own build recipes (if any)
#p4a.local_recipes =
......@@ -214,7 +214,7 @@ android.arch = armeabi-v7a
#p4a.hook =
# (str) Bootstrap to use for android builds
p4a.bootstrap = sdl2
p4a.bootstrap = service_only
# (int) port number to specify an explicit --port= p4a argument (eg for bootstrap flask)
#p4a.port =
......
......@@ -9,7 +9,7 @@ delegate = procbridge.Delegate()
@delegate.api
def echo(self, echo, **kw):
print("echo:", echo)
print(("echo:", echo))
# time.sleep(3)
return "Hello:" + echo
......@@ -39,5 +39,7 @@ def runit():
server.wait_for_stop()
print('bye!')
print('starting...')
runit()
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment