-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
60 lines (45 loc) · 1.42 KB
/
Copy pathmain.py
File metadata and controls
60 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'''
Created on Oct 23, 2011
@author: wblack
'''
# -*- coding: utf-8 -*-
import logging
# The multiprocessing package isn't
# part of the ASE installation so
# we must disable multiprocessing logging
logging.logMultiprocessing = 0
# Update path to point at cherrypy
import sys
import os
current_dir = os.path.dirname(os.path.abspath(__file__))
print current_dir
sys.path.append("/mnt/sdcard/sl4a/scripts/")
import android
import cherrypy
from templates import home
#cherrypy.config.update("/mnt/sdcard/sl4a/scripts/AndroidServer/site_config.txt")
droid = android.Android()
class Root(object):
def __init__(self):
self.droid = android.Android()
@cherrypy.expose
def index(self):
self.droid.vibrate()
return home
@cherrypy.expose
def take_pic(self):
rs = self.droid.cameraCapturePicture("/mnt/sdcard/DCIM/Camera/Webcam/")
return str(rs)
@cherrypy.expose
def location(self):
location = self.droid.getLastKnownLocation().result
location = location.get('network', location.get('gps'))
return "LAT: %s, LON: %s" % (location['latitude'],
location['longitude'])
def run():
cherrypy.config.update({'server.socket_host': '0.0.0.0'})
droid.makeToast("Running quickstart")
cherrypy.quickstart(Root(), '/')
if __name__ == '__main__':
droid.makeToast("Starting webserver")
run()