Esempio n. 1
0
# -*- coding: utf-8 -*-

import sys, imp, os
from os import path

try:
    import bluetooth
except:
    bluetooth = None

parent = path.dirname(path.realpath(__file__))
sys.path.pop(0)
sys.path.insert(0, path.join(parent, "python.zip"))

if not bluetooth:
    imp.load_dynamic("_bluetooth", "%s/bluetooth.so" % parent)
    import bluetooth

os.environ["DATA_PATH"] = parent

try:
    from customer import main
    main()
except Exception, err:
    from android import API
    from traceback import format_exc
    API().log(str(err))
    API().log(format_exc())
    import time
    time.sleep(10)
Esempio n. 2
0
import sys, os, socket, json, errno, time
from android import API
from twisted.internet import reactor
from twisted.python import log
droid = API()
os.environ["HOME"] = "/data/data/net.aircable.airi/files"

class EventSocket(object):
    # based on https://github.com/jdavisp3/twisted-intro/raw/master/twisted-client-1/get-poetry.py
    socket = None
    bytes = ""

    def __init__(self, address):
        self.address = address
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        self.socket.connect(address)
        self.socket.setblocking(0)
        self.bytes = ""

        # tell the Twisted reactor to monitor this socket for reading
        from twisted.internet import reactor
        reactor.addReader(self)

    def fileno(self):
        try:
            return self.socket.fileno()
        except socket.error:
            return -1

    def connectionLost(self, reason):
        self.socket.close()
Esempio n. 3
0
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#

import bluetooth, os, sys, select, socket, json
from webserver import register_server
from base64 import b64encode as b64e
from PyOBEX import responses, headers
from PyOBEX import server as obex_server
from functools import partial
from time import time, sleep
from android import API
import mimetypes
droid = API(debug=True)

ENTRY = 10
ARGS = 20
RESULT = 30


class report:
    """
  Decorator that prints information about function calls.
  Based on: http://paulbutler.org/archives/python-debugging-with-decorators/
  """
    def __init__(self, level=ENTRY):
        self.level = level

    def __call__(self, fn):