Advertising (This ad goes away for registered users. You can Login or Register)

[tutorial]python4android multithreaded http+jsmodem

Discuss about your favorite (gaming...or not) devices here. The most popular ones will end up getting their own categories
Programming discussions for your favorite Device
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
Post Reply
ivo2376
Posts: 30
Joined: Wed Jan 14, 2015 10:17 pm

[tutorial]python4android multithreaded http+jsmodem

Post by ivo2376 » Sun Sep 16, 2018 1:03 pm

hello,

pain installing this in msys2, linux should be okey with some minors adjustments

Code: Select all

https://python-for-android.readthedocs.io/en/latest/quickstart/
https://python-for-android.readthedocs. ... uickstart/
i have found only one obstacle in completeing the quickstart install in msys2
that is no openjdk-jdk7 binary installer for linux i could use in msys2
so my best bet is to try it all in ubuntu and install most with pip except some
in windows cmdline it works to but from sources since it lacks a package-manager

Code: Select all

verhoeve@E1230:~/.android/android-sdk-21/tools/bin$ ./sdkmanager --list
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
	at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
	at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
	at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
	... 5 more
verhoeve@E1230:~/.android/android-sdk-21/tools/bin$ sdkmanager "build-tools;26.0.2"
sdkmanager: opdracht niet gevonden
verhoeve@E1230:~/.android/android-sdk-21/tools/bin$ ./sdkmanager "build-tools;26.0.2"
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
	at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
	at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
	at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
	at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:190)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:499)
	... 5 more
verhoeve@E1230:~/.android/android-sdk-21/tools/bin$ 
im currently stuck on32bit linux on one machine since apt has no jdk7 so gonna retry with openjdsk7-from-oracle-installer


the python code for simplehttp
https://docs.python.org/2/library/simplehttpserver.html

Code: Select all

import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
https://github.com/kivy/python-for-android
p4a (pythonforandroid) on github to build the apk

code for threading python
https://www.tutorialspoint.com/python/p ... eading.htm

Code: Select all

#!/usr/bin/python
import thread
import time
# Define a function for the thread
def print_time( threadName, delay):
   count = 0
   while count < 5:
      time.sleep(delay)
      count += 1
      print "%s: %s" % ( threadName, time.ctime(time.time()) )
# Create two threads as follows
try:
   thread.start_new_thread( print_time, ("Thread-1", 2, ) )
   thread.start_new_thread( print_time, ("Thread-2", 4, ) )
except:
   print "Error: unable to start thread"
while 1:
   pass
code for the browercode
http://www.myegotraps.com/pywebview-2-0-released/

Code: Select all

import webview
from threading import Thread
class Api():
    def helloWorld(self, param):
        return 'Hello Python!'
def load_html():
  webview.load_html('<p>Hello World</p>')
  webview.evaluate_js("""
    pywebview.api.helloWorld().then(function(response) {
      alert(response)
    })
  """)
if __name__ == '__main__':
    api = Api()
    t = Thread(target=load_html)
    t.start()
    webview.create_window('Hello world', js_api=api)
or a better one ? https://stackoverflow.com/questions/284 ... ith-python

and last but not least the assets of the project
jsmodem working in simplehttpserver via python
https://github.com/ewiger/jsmodem

care to calloborate on this p4a assets ?
Advertising

Post Reply

Return to “Programming and Security”