Skip to content

Commit 47e4b72

Browse files
inclementopacam
authored andcommitted
Add a test app for service_only's bootstrap
This is almost a clone from one of @inclement's test apps, with the addition of a function which prints the current date/time.
1 parent 0e700c4 commit 47e4b72

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

testapps/setup_testapp_service.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
from distutils.core import setup
3+
from setuptools import find_packages
4+
5+
options = {'apk': {'debug': None,
6+
'requirements': 'python2,genericndkbuild',
7+
'android-api': 27,
8+
'ndk-api': 21,
9+
'ndk-dir': '/home/asandy/android/crystax-ndk-10.3.2',
10+
'dist-name': 'testapp_service',
11+
'ndk-version': '10.3.2',
12+
'bootstrap': 'service_only',
13+
'permissions': ['INTERNET', 'VIBRATE'],
14+
'arch': 'armeabi-v7a',
15+
'window': None,
16+
}}
17+
18+
package_data = {'': ['*.py']}
19+
20+
packages = find_packages()
21+
print('packages are', packages)
22+
23+
setup(
24+
name='testapp_service',
25+
version='1.0',
26+
description='p4a service testapp',
27+
author='Alexander Taylor',
28+
author_email='[email protected]',
29+
packages=find_packages(),
30+
options=options,
31+
package_data={'testapp_service': ['*.py']}
32+
)

testapps/testapp_service/main.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
print('main.py was successfully called')
2+
3+
import sys
4+
print('python version is: ', sys.version)
5+
print('python sys.path is: ', sys.path)
6+
7+
from math import sqrt
8+
print('import math worked')
9+
10+
for i in range(45, 50):
11+
print(i, sqrt(i))
12+
13+
print('Just printing stuff apparently worked, trying a simple service')
14+
import datetime, threading, time
15+
16+
next_call = time.time()
17+
18+
19+
def service_timer():
20+
global next_call
21+
print('P4a datetime service: {}'.format(datetime.datetime.now()))
22+
next_call = next_call + 1
23+
threading.Timer(next_call - time.time(), service_timer).start()
24+
25+
26+
print('Starting the service timer...')
27+
service_timer()

0 commit comments

Comments
 (0)