Exemple #1
0
def dbg_init():
    global dbg_active
    global dbg_initialized
    global dbg_modes
    global __callgate

    try:
        dbg_active = os.environ[dbg_env_var].split(",")
    except KeyError:
        dbg_active = []
    if "all" in dbg_active:
        dbg_active = dbg_modes.keys()
    for item in dbg_modes.keys():
        if item not in dbg_active: dbg_active.append(item)
    for item in dbg_active:
        if item[0] == "-":
            if item[1:] in dbg_modes.keys():
                dbg_active.remove(item[1:])
            else:
                print "debug mode %s not found" % item[1:]
        elif item not in dbg_modes.keys():
            dbg_active.remove(item)
            print "debug mode %s not found" % item
            dbg_active.remove(item)
    dbg_initialized = True

    __callgate = e32.ao_callgate(__dbg)
Exemple #2
0
def dbg_init():
    global dbg_active
    global dbg_initialized
    global dbg_modes
    global __callgate

    try:
        dbg_active = os.environ[dbg_env_var].split(",")
    except KeyError:
        dbg_active = []
    if "all" in dbg_active:
        dbg_active = dbg_modes.keys()
    for item in dbg_modes.keys():
        if item not in dbg_active:
            dbg_active.append(item)
    for item in dbg_active:
        if item[0] == "-":
            if item[1:] in dbg_modes.keys():
                dbg_active.remove(item[1:])
            else:
                print "debug mode %s not found" % item[1:]
        elif item not in dbg_modes.keys():
            dbg_active.remove(item)
            print "debug mode %s not found" % item
            dbg_active.remove(item)
    dbg_initialized = True

    __callgate = e32.ao_callgate(__dbg)
Exemple #3
0
    def __init__(self):
        from e32 import Ao_lock
        from key_codes import EKeyEnter
        self.input_wait_lock = Ao_lock()
        self.input_stopped = False
        self.control = self.text = appuifw.Text()
        self.text.bind(EKeyEnter, self.input_wait_lock.signal)
        self.savestderr = sys.stderr
        self.savestdout = sys.stdout
        self.savestdin = sys.stdin
        sys.stderr = self
        sys.stdout = self
        sys.stdin = self
        self.writebuf = []

        def make_flusher(text, buf):
            def doflush():
                text.add(unicode(''.join(buf)))
                del buf[:]
                if text.len() > 1500:
                    text.delete(0, text.len() - 500)

            return doflush

        self._doflush = make_flusher(self.text, self.writebuf)
        self._flushgate = e32.ao_callgate(self._doflush)
Exemple #4
0
    def __init__(self, logger = False):
        self.logger = logger
        from e32 import Ao_lock
        from key_codes import EKeyEnter
        self.input_wait_lock = Ao_lock()
        self.input_stopped = False
        self.control = self.text = appuifw.Text()
        self.text.font = ('title', 16, None)
        self.text.color = 0
        self.savestderr = sys.stderr
        self.savestdout = sys.stdout
        self.savestdin = sys.stdin
        sys.stderr = self
        sys.stdout = self
        sys.stdin = self
        self.writebuf = []
        self._doflush = self.clear()
        self._flushgate = self.clear()
        if self.logger :

            def make_flusher(text, buf):

                def doflush():
                    text.set_pos(text.len())
                    text.add(ru(''.join(buf)))
                    del buf[:]

                return doflush

            self._doflush = make_flusher(self.text, self.writebuf)
            self._flushgate = e32.ao_callgate(self._doflush)
        else:
            self.logger = False
            self.clear()
        return None
Exemple #5
0
    def test_Ao_lock(self):
        """Test for Ao_callgate and Ao_lock"""
        def modify_data_and_signal_lock():
            # A helper function that is called asynchronously
            # via the active object mechanism.
            self.modify_test_data(changed_val)
            lock.signal()

        func = e32.ao_callgate(modify_data_and_signal_lock)
        func()
        lock.wait()
        self.failUnlessEqual(self.test_data, changed_val)
Exemple #6
0
def communicate():
    global to_server, keep_talking, thread_send_message, app_lock
    thread_send_message = e32.ao_callgate(send_message)
    to_server = None
    while keep_talking:
        if to_server:
            read_message()
        else:
            try:
                connect()
                thread_handle_message(\
                        {"note": u"Waiting for messages..."})
            except:
                print "Could not connect to server"
                to_server = None
                if keep_talking:
                    e32.ao_sleep(10)
    if conn: conn.close()
    if to_server: to_server.close()
Exemple #7
0
	def port_setup(self):
		# create the port (this is done inside the thread started by connect())
		try:	
			self.port = pyshake_serial.serial_port(self.device_address)
			baud = 230400
			if self.device_type == SHAKE_SK7:
				baud = 460800
			
			if not self.port.open(baud):
				debug("port creation failed")
				self.thread_done = True
				return SHAKE_ERROR

			# 	ao_callgate sets up an Active Object that is used to trigger calls
			# 	to self.port.write from the thread the object was created in. 
			if platform == "S60":
				self.write_to_port = ao_callgate(self.port.write)
			else:
				self.write_to_port = self.port.write
		except pyshake_serial.pyshake_serial_error:
			debug('error; port creation failed')
			self.thread_done = True
			return SHAKE_ERROR
def RemoveAccessPointSelection():
    if os.path.exists(apidFile):
        os.remove(apidFile)


#Define the exit function
def Quit():
    stopServer
    app_lock.signal()
    appuifw.app.orientation = 'portrait'
    appuifw.app.set_exit()


#
# try it out
print camera.image_sizes("JPEG_Exif")

ap = RetrieveAccessPointSelection()

appuifw.app.exit_key_handler = quit
appuifw.app.menu = [(u"Stop server", stopServer),
                    (u"Remove saved AP", RemoveAccessPointSelection),
                    (u"Exit", Quit)]

#startup()
handle_request_in_UI_thread = e32.ao_callgate(_handle_request_in_UI_thread)
thread.start_new_thread(startupInThread, ())

app_lock.wait()
 def register_accel(self):
     axyz.connect(e32.ao_callgate(self.printout_)) 
Exemple #10
0
def Callgate(callable):
    return e32.ao_callgate(callable)
		socket.set_default_access_point(apo)
		return apo
	else:		
		return None

def RemoveAccessPointSelection():
	if os.path.exists(apidFile):
		os.remove(apidFile)

		
#Define the exit function
def Quit():
	stopServer
	app_lock.signal()
	appuifw.app.orientation = 'portrait'
	appuifw.app.set_exit()

#
# try it out
print camera.image_sizes("JPEG_Exif")

ap = RetrieveAccessPointSelection()

appuifw.app.exit_key_handler = quit
appuifw.app.menu=[(u"Stop server", stopServer),(u"Remove saved AP", RemoveAccessPointSelection),(u"Exit", Quit)]

#startup()
handle_request_in_UI_thread = e32.ao_callgate(_handle_request_in_UI_thread)
thread.start_new_thread(startupInThread, ())

app_lock.wait()	
Exemple #12
0
 def register_accel(self):
     axyz.connect(e32.ao_callgate(self.printout_))
Exemple #13
0
def Callgate(callable):
    return e32.ao_callgate(callable)
Exemple #14
0
    canvas.clear((255, 255, 255))
    if img:
        canvas.blit(img, scale=1)
    if note:
        canvas.text((10, canvas.size[1] - 30), note,\
                fill = RED, font = "title")
    if text:
        canvas.text((10, 80), u"From: %s" % text["from"],\
                fill = GREEN, font = "title")
        canvas.text((10, 110), unicode(text["txt"]),\
                fill = BLUE, font = "title")


img = text = note = None
keep_talking = True
thread_handle_message = e32.ao_callgate(handle_message)
appuifw.app.exit_key_handler = quit
appuifw.app.title = u"Instant Messenger"
appuifw.app.menu = [(u"Send Photo", send_photo),\
                    (u"Send Text", send_text)]

canvas = appuifw.Canvas(redraw_callback=redraw)
appuifw.app.body = canvas

me = appuifw.query(u"Login name", "text")
handle_message({"note": u"Contacting server..."})
if me:
    app_lock = e32.Ao_lock()
    thread.start_new_thread(communicate, ())
    if keep_talking:
        app_lock.wait()
Exemple #15
0
 def __init__(self):
     self.app_lock = e32.Ao_lock()
     self.fb = chm_filebrowser.Filebrowser()
     self.load_recent()
     self.hhc_callback = e32.ao_callgate(self.load_hhc_viewer)
Exemple #16
0
from threading import Thread
import e32


def my_callback():
    azimuth = str(magnetic_north.azimuth)
    print azimuth

def start_magnetic():
    import sensor
    global magnetic_north
    magnetic_north = sensor.MagneticNorthData()
    magnetic_north.set_callback(data_callback=my_callback)
    magnetic_north.start_listening()
    print 'jedziemy'


sm = e32.ao_callgate(start_magnetic)

t = Thread(target=sm)
t.start()

e32.ao_sleep(8)