예제 #1
0
파일: script.py 프로젝트: aircable/AIRi
#!/usr/bin/env python 
# -*- coding: utf-8 -*-

import sys, imp, os
from android import API
from os import path, listdir
droid = API()

class stdout():
    def __init__(self):
        self.stdout = sys.stdout
        self.stderr = sys.stderr

    def write(self, what):
        droid.log(what)
        self.stdout.write(what)

    def writelines(self, lines):
        for l in lines:
           droid.log(l)
        self.stdout.writelines(lines)

    def __getattr__(self, name):
        #droid.log("stdout get %s" % name)
        return getattr(self.stdout, name)

out = stdout()
sys.stdout = out
sys.stderr = out

예제 #2
0
#!/usr/bin/env python 
# -*- coding: utf-8 -*-

import sys, imp, os
from android import API
from os import path, listdir
droid = API()

class stdout():
    def __init__(self):
        self.f = file(
            os.path.join(os.environ["EXTERNAL_STORAGE"], "airi.log"),
            "wb")
        self.stdout = sys.stdout
        self.stderr = sys.stderr

    def write(self, what):
        droid.log(what)
        self.f.write(what)
        self.f.flush()
        self.stdout.write(what)

    def writelines(self, lines):
        for l in lines:
           droid.log(l)
        self.stdout.writelines(lines)
        self.f.writelines(what)
        self.f.flush()

    def __getattr__(self, name):
        #droid.log("stdout get %s" % name)
예제 #3
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()
예제 #4
0
파일: script.py 프로젝트: ygl-rg/AIRi
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, imp, os
from android import API
from os import path, listdir
droid = API()


class stdout():
    def __init__(self):
        self.f = file(os.path.join(os.environ["EXTERNAL_STORAGE"], "airi.log"),
                      "wb")
        self.stdout = sys.stdout
        self.stderr = sys.stderr

    def write(self, what):
        droid.log(what)
        self.f.write(what)
        self.f.flush()
        self.stdout.write(what)

    def writelines(self, lines):
        for l in lines:
            droid.log(l)
        self.stdout.writelines(lines)
        self.f.writelines(what)
        self.f.flush()

    def __getattr__(self, name):
        #droid.log("stdout get %s" % name)
예제 #5
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)
예제 #6
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):
예제 #7
0
#!/usr/bin/env python 
# -*- coding: utf-8 -*-

import sys, imp, os
from android import API
from os import path
droid = API()

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

import pkg_resources
pkg_resources.set_extraction_path(droid.environment()["appcache"])

os.environ["DATA_PATH"]=parent

try:
  import bluetooth
  import 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)