Esempio n. 1
0
    def start_service(self):
        """Start the service"""
        self.save_settings()
        print("Starting service")
        self.service_running = False
        osc.sendMsg("/status", [], port=3000)
        osc.sendMsg("/progress", [], port=3000)
        sleep(0.1)
        osc.readQueue(self.oscid)
        if not self.service_status:
            # Wait a little longer and try again
            sleep(0.5)
            osc.readQueue(self.oscid)

        if not self.service_status:
            print("Start_service: Service is not running, starting")
            if self.service is None:

                if platform == "android":
                    from android import AndroidService
                    self.service = AndroidService("Optimal file sync service", "running")
                    self.service.start("service started")
                else:
                    # Start process on linux.
                    print("Running on !android initializing service using Popen.")
                    self.service = subprocess.Popen(args = ["python", "./service/main.py"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        else:
            print("Start_service: Service is already running, not starting.")
    def _test_2_test_service_control(self):
        # Run main
        _proc = subprocess.Popen(args = ["python", os.path.normpath(Test_Script_Dir + "/../main.py")], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)


        # Connect to it and sent message

        osc.init()
        self.oscid = osc.listen(ipAddr='0.0.0.0', port=3002)
        osc.bind(self.oscid, self._status_result, '/status')

        self.test_2_result = None
        sleep(1)
        osc.sendMsg(oscAddress ='/status', ipAddr="0.0.0.0", dataArray=[""], port=3000)

        while self.test_2_result is None:
            osc.readQueue(self.oscid)
            sleep(.1)
        if self.test_2_result is True:
            self.assertTrue(True)
        else:
            self.assertTrue(False, "Test failed, service returned:" + str(self.test_2_result))

        osc.sendMsg(oscAddress ='/stop', ipAddr="0.0.0.0", dataArray=[], port=3000)
        osc.dontListen(self.oscid)
Esempio n. 3
0
    def sleep_and_check_stop(self, nexttime):
        waitsec = (max((nexttime - datetime.utcnow()),
                       timedelta())).total_seconds()
        print "wait for:", waitsec
        #time.sleep(waitsec)
        stop = False
        while (datetime.utcnow() < nexttime):
            osc.readQueue(self.oscid)
            if self.rpcin_message == "stop":
                stop = True
                break
            time.sleep(.5)

        osc.readQueue(self.oscid)
        if self.rpcin_message == "stop":
            stop = True

        if (not stop):
            print "continue on loop"
            return

        print "start shutdown background process"
        try:
            self.on_stop()
        except:
            print "error on_stop"
        print "retuned from on_stop"

        print "RPC send stoppped"
        self.rpcout("stopped")
        print "background exit"
        raise SystemExit(0)
Esempio n. 4
0
    def _listen(self):
        # Logger.debug('Appix: started and listening')
        count = 0
        while self.keep_listening:
            osc.readQueue(self.oscid)
            #print osc.readQueue(self.oscid)
            sleep(.1)
            count += 1
            if count >= 20:
                count = 0
                # if service and not self.is_app_running():
                #     self.stop()
                #     break
                # print " "
                # print " "
                # print os.environ
                # print " "
                # print " "

                if service and "APPIX_SERVICE" in os.environ and not self.is_app_running():
                    self.keep_listening = False
                    self.stop()
                    break
            if not service:
                #print '>>', autoclass('android.os.Process').myPid(), '<<'
                continue
            self.bluetooth_standby_time -= 1
            # print "self.bluetooth_standby_time", self.bluetooth_standby_time
            if self.bluetooth_standby_time == 0:
                AppixBT.initiate_bluetooth()
Esempio n. 5
0
    def sleep_and_check_stop(self,nexttime):
        waitsec=(max((nexttime - datetime.utcnow()),timedelta())).total_seconds()
        print "wait for:",waitsec
        #time.sleep(waitsec)
        stop=False
        while (datetime.utcnow() < nexttime):
            osc.readQueue(self.oscid)
            print ">>>>> ----- rpcin background message: ", self.rpcin_message
            if self.rpcin_message == "stop":
                stop=True
                break
            time.sleep(.5)

        osc.readQueue(self.oscid)
        if self.rpcin_message == "stop":
            stop=True

        if (not stop):
            print "continue on loop"
            return

        print "start shutdown background process"
        try:
            self.on_stop()
        except:
            print "error on_stop"
        print "retuned from on_stop"

        print "RPC send stoppped"
        self.rpcout("stopped")
        print "background exit"
        raise SystemExit(0)
Esempio n. 6
0
	def start_service(self):
		while True:
			while self.client_id == '' or self.server_ip == '':
				osc.readQueue(self.oscid)
			if not self.connected:
				self.mqtt_connect() 
			osc.readQueue(self.oscid)
Esempio n. 7
0
def first_auth():
    global authorized
    authorized = False

    osc.sendMsg('/first auth', [], port=3002)

    while not authorized:
        time.sleep(0.5)
        osc.readQueue(oscid)
Esempio n. 8
0
def captcha_handler(captcha):
    global captcha_code
    captcha_code = None
    osc.sendMsg('/auth captcha needed', [captcha.get_url(), ], port=3002)

    while not captcha_code:
        time.sleep(0.5)
        osc.readQueue(oscid)

    send_log_line(u'Повторяю запрос с капчей', 0)
    captcha.try_again(captcha_code)
Esempio n. 9
0
def twofactor_handler():
    global twofactor_code
    twofactor_code = None
    osc.sendMsg('/auth twofactor needed', [], port=3002)

    while not twofactor_code:
        time.sleep(0.5)
        osc.readQueue(oscid)

    send_log_line(u'Повторяю запрос с кодом', 0)
    return twofactor_code, True
Esempio n. 10
0
    def boot(self, configurestation=False):

        print "background boot station"

        ####   osc IPC   ####
        osc.init()
        self.oscid = osc.listen(ipAddr='0.0.0.0', port=3000)
        osc.bind(self.oscid, self.rpcin, '/rpc')

        #force trip for mobile station in background
        self.trip = self.ismobile()

        try:
            self.starttransport()
        except:
            print "start transport failed"

        notok = True
        while notok:
            try:
                if configurestation:
                    self.configurestation()
                try:
                    self.sensorssetup()
                except:
                    print "sensorssetup failed"

                if self.trip:
                    self.gps.start()
                self.startmqtt()
                notok = False
            except:
                print "Error booting station"
                time.sleep(5)

                osc.readQueue(self.oscid)
                if self.rpcin_message == "stop":
                    print "received stop message from rpc"
                    self.on_stop()
                    print "send stopped message to rpc"
                    self.rpcout("stopped")
                    raise SystemExit(0)
                    #time.sleep(60) # wait for kill from father

                if self.transport_name == "bluetooth":
                    self.bluetooth.close()
                    self.transport = self.bluetooth.connect()
                    try:
                        self.sensorssetup()
                    except:
                        print "sensorssetup failed"

        print "background end boot"
Esempio n. 11
0
def message_reader(rx_queue, oscid, should_run):
    print('connection process message reader started')
    
    while should_run.is_set():
        try:
            osc.readQueue(oscid)
            sleep(0.1)
        except:
            print('Exception in message_reader')
            traceback.print_exc()
            #_rx_queue.put('##ERROR##')
            sleep(0.5)
    print('connection process message reader exited')            
Esempio n. 12
0
def _main():
    osc.init()
    start_time = int(time.time())
    oscid = osc.listen(ipAddr='0.0.0.0', port=MAIN_PROG_RCV)
    osc.bind(oscid, play, '/play')
    osc.bind(oscid, pause, '/pause')
    osc.bind(oscid, stop, '/stop')
    osc.bind(oscid, volume, '/volume')
    osc.bind(oscid, kill, '/kill')
    while True:
        osc.readQueue(oscid)
        osc.sendMsg('/ping', [start_time], port=MAIN_PROG_PORT)
        sleep(.1)
Esempio n. 13
0
def main():

    oscid = osc.listen(ipAddr=hostname, port=serviceport)
    osc.init()

    osc.bind(oscid, update_notification, '/update')

    br = BroadcastReceiver(intent_callback,["GET_CONTENT",]) # no prefix ACTION_ required
    br.start()

    while True:
        osc.readQueue(oscid)
        time.sleep( .1 )
Esempio n. 14
0
 def run(self):
     while not self.stopped:
         try:
             # First check the osc
             if self.oscid is not None:
                 osc.readQueue(self.oscid)
                 event = self.queue.get(block=True, timeout=1)
                 event.call(self)
                 self.check_timeout()
                 sleep(.1)
             else:
                 sleep(.1)
         except Empty:
             self.check_timeout()
Esempio n. 15
0
    def update(self, dispatch_fn):
        '''Update the TUIO provider (pop events from the queue)'''

        # deque osc queue
        osc.readQueue(self.oscid)

        # read the Queue with event
        while True:
            try:
                value = self.tuio_event_q.pop()
            except IndexError:
                # queue is empty, we're done for now
                return
            self._update(dispatch_fn, value)
Esempio n. 16
0
    def boot(self,configurestation=False):

        print "background boot station"

        ####   osc IPC   ####
        osc.init()
        self.oscid = osc.listen(ipAddr='0.0.0.0', port=3000)
        osc.bind(self.oscid, self.rpcin, '/rpc')

        try:
            self.starttransport()
        except:
            print "start transport failed"

        notok=True
        while notok:
            try:
                if configurestation:
                    self.configurestation()
                try:
                    self.sensorssetup()
                except:
                    print "sensorssetup failed"

                if self.trip:
                    self.gps.start()
                self.startmqtt()
                notok=False
            except:
                print "Error booting station"
                time.sleep(5)

                osc.readQueue(self.oscid)
                if self.rpcin_message == "stop":
                    print "received stop message from rpc"
                    self.on_stop()
                    print "send stopped message to rpc"
                    self.rpcout("stopped")
                    raise SystemExit(0)
                    #time.sleep(60) # wait for kill from father

                if self.transport_name == "bluetooth":
                    self.bluetooth.close()
                    self.transport=self.bluetooth.connect()
                    try:
                        self.sensorssetup()
                    except:
                        print "sensorssetup failed"

        print "background end boot"
Esempio n. 17
0
    def update(self, dispatch_fn):
        '''Update the TUIO provider (pop events from the queue)'''

        # deque osc queue
        osc.readQueue(self.oscid)

        # read the Queue with event
        while True:
            try:
                value = self.tuio_event_q.pop()
            except IndexError:
                # queue is empty, we're done for now
                return
            self._update(dispatch_fn, value)
Esempio n. 18
0
    def stop_service(self):
        """Stop the service"""
        print("Asking service to stop.")
        self.service_running = False

        osc.sendMsg("/status", [], port=3000)
        sleep(0.2)
        osc.readQueue(self.oscid)

        osc.sendMsg("/stop", [], port=3000)
        sleep(0.2)
        osc.readQueue(self.oscid)
        if self.service is not None and platform == "android":
            self.service.stop()
            self.service = None
Esempio n. 19
0
    def build(self):
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('irc1\'s service', 'running')
            service.start('service started')
            self.service = service

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        osc.bind(oscid, self.main_api_callback, '/api/main')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.1)

        self.icon = 'data/icon.png'
        self.servers = DictStore('servers.db')
        self.msg_animation = Animation(opacity=1, transition='out_cubic')
        self.screenmain = ScreenMain()
        self.running = {}
        self.boxes = {}

        for name in sorted(dict(self.servers.find()).keys()):
            data = self.servers.get(name)
            box = ServerBox(name=name)
            self.boxes[name] = box
            self.screenmain.ids.servers.add_widget(box)

        manager = ScreenManager(transition=SlideTransition(duration=0.2))
        manager.add_widget(self.screenmain)
        return manager
Esempio n. 20
0
	def build(self):
		if platform == 'android':
			self.start_service()
			from jnius import autoclass
			self.Locale = autoclass('java.util.Locale')
			self.PythonActivity = autoclass('org.renpy.android.PythonActivity')
			self.TextToSpeech = autoclass('android.speech.tts.TextToSpeech')
			self.tts = self.TextToSpeech(self.PythonActivity.mActivity, None)
			self.locales = {
				'CANADA':self.Locale.CANADA,
				'FRANCE':self.Locale.FRANCE,
				'GERMANY':self.Locale.GERMANY,
				'ITALY':self.Locale.ITALY,
				'JAPAN':self.Locale.JAPAN,
				'KOREA':self.Locale.KOREA,
				'CHINA':self.Locale.SIMPLIFIED_CHINESE,
				'UK':self.Locale.UK,
				'US':self.Locale.US
				}
		osc.init()
		oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
		osc.bind(oscid, self.some_api_callback, '/some_api')
		Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
		self.service_enabled = False
		self.toggle_service()
		self.load_settings()
		self.chosen_locale = self.config.get('example','optionsexample')
		self.tts_enabled = bool(int(self.config.get('example','boolexample')))
		return
Esempio n. 21
0
 def build(self):
     super(Booth, self).build()
     self.oscid = oscid = osc.listen(ipAddr='0.0.0.0', port=8000)
     osc.bind(oscid, self.update_data, '/update')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
     self.root.ids.particle._parse_config('data/implosion.pex')
     self.root.ids.particle.start()
Esempio n. 22
0
	def build(self):
		self.service = None
		self.start_service()
		global RootApp
		RootApp = self

		# NavigationDrawer
		self.navigationdrawer = NavDrawer()

		# SidePanel
		side_panel = SidePanel()
		self.navigationdrawer.add_widget(side_panel)

		# MainPanel
		self.main_panel = MainPanel()

		# color picker
		self.color_selector = ColorSelector()

		# size selector
		self.size_selector = SizeSelector()

		self.navigationdrawer.anim_type = 'slide_above_simple'
		self.navigationdrawer.add_widget(self.main_panel)

		osc.init()
		oscid = osc.listen(port=3002)
		osc.bind(oscid, self.reCallback, '/date')
		Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

		return self.navigationdrawer
Esempio n. 23
0
 def run(self):
     while True:
         try:
             osc.readQueue(self.oscid)
             if not self.notified:
                 self.update_notification("Intento: " + self.last_time.strftime('%Y-%m-%d %H:%M'))
                 self.notified = True
             if self.check_pattern():
                 self.add_pattern()
             # Pending operations
             if self.check_interval():
                 # Update last_time here to avoid repeated requests
                 self.last_time = datetime.datetime.now(tz=self.met)
                 self.internal_queue.put(lambda: self.modify(-1))
         except:
             L.error("Exception:\n" + traceback.format_exc())
         sleep(.1)
    def __init__(self):
        sleep(1)
        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=3001)
        try:
            osc.sendMsg('/some_api', ['Init'], port=3002)
            self.mplayer = M_Player(self)
            osc.bind(oscid, self.mplayer.osc_callback, '/some_api')
            self.queue = ''

            while True:
                osc.readQueue(oscid)
                if self.queue != '':
                    self.mplayer.osc_callback(['','',self.queue])
                    self.queue = ''
                    sleep(.3)
        except Exception as e:
            osc.sendMsg('/some_api', ['Service crash '+str(e)], port=3002)
Esempio n. 25
0
 def build(self):
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(ipAddr='127.0.0.1', port=3002)
     osc.bind(oscid, self.temp_data, '/sensordata')
     osc.bind(oscid, self.notification_data, '/notification')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.7)
     return presentation
Esempio n. 26
0
    def __init__(self, **kwargs):
        super(UpdateClient, self).__init__(**kwargs)

        osc.init()
        oscid = osc.listen('127.0.0.1', CLIENT_PORT)
        osc.bind(oscid, self.recv_osc, SERVICE_PATH)
        Clock.schedule_interval(lambda _: osc.readQueue(oscid), 0)

        self.current_version = str(get_current_version())
Esempio n. 27
0
 def init_osc(self):
     """Initialisation of the OSC communication.
     Bindings are donne for some kings of messages.
     """
     osc.init()
     oscid = osc.listen(ipAddr='127.0.0.1', port=kivytrek_port)
     osc.bind(oscid, self.gps_pos_callback, '/gps_pos')
     osc.bind(oscid, self.gps_daemon_recording_callback, '/gpx_status')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)
Esempio n. 28
0
	def __init__(self, **kwargs):
		super(UpdateClient, self).__init__(**kwargs)
		
		osc.init()
		oscid = osc.listen('127.0.0.1', CLIENT_PORT)
		osc.bind(oscid, self.recv_osc, SERVICE_PATH)
		Clock.schedule_interval(lambda _: osc.readQueue(oscid), 0)
		
		self.current_version = str(get_current_version())
Esempio n. 29
0
 def build(self):
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=3002)
     osc.bind(oscid, self.display_message, '/message')
     osc.bind(oscid, self.date, '/date')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
     self.root = Builder.load_string(kv)
     return self.root
Esempio n. 30
0
    def init(self, _cfg_file=None):
        self.ids.destination_host.ids.input_selection.bind(text=self._update_host)
        self.ids.destination_path.on_status = self.do_on_smbselector_status
        self.load_settings(_cfg_file)
        self.service = None
        osc.init()
        self.oscid = osc.listen(port=3002)
        osc.bind(self.oscid, self.progress_callback, "/progress_callback")
        osc.bind(self.oscid, self.status_callback, "/status_callback")

        # Check if service is running
        self.service_running = False
        osc.sendMsg("/status", [], port=3000)
        osc.sendMsg("/progress", [], port=3000)
        sleep(0.3)
        osc.readQueue(self.oscid)


        Clock.schedule_interval(self.process_messages, 1)
Esempio n. 31
0
    def build(self):
        self.start_service()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        # activity port
        osc.bind(oscid, self.api_callback, '/some_api')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)

        return ServiceInterface()
Esempio n. 32
0
 def build(self):
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=3002)
     osc.bind(oscid, self.display_message, '/message')
     osc.bind(oscid, self.date, '/date')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
     self.root = Builder.load_string(kv)
     return self.root
Esempio n. 33
0
    def build(self):
        self.start_service()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        # activity port
        osc.bind(oscid, self.api_callback, '/some_api')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)

        return ServiceInterface()
Esempio n. 34
0
	def run(self):
		print 'updater run'
		osc.init()
		oscid = osc.listen('127.0.0.1', SERVICE_PORT)
		osc.bind(oscid, self.recv_osc, SERVICE_PATH)
		print 'listening for OSC'
		self.current_version = self.downloaded_version = self.get_current_version()
		
		while True:
			if not self.last_check or (self.last_check + self.frequency) < time():
				if self.check_for_update():
					self.download_update()
			
			if self.dlready.is_set():
				self.notify_client()
				self.dlready.clear()
			
			osc.readQueue(oscid)
			
			sleep(.1)
Esempio n. 35
0
File: main.py Progetto: synctext/AT3
    def start(self, blocking=True):
        """
        Starts the anontunnel service
        :param blocking: True if this method should block or False to continue execution
        """

        self.setup_logging()
        self.log.info('Starting the anonymous tunnels...')
        
        socks5_port = None
        proxy_settings = ProxySettings()
        crawl = False

        self.anon_tunnel = AnonTunnel(socks5_port, proxy_settings, crawl)
        self.anon_tunnel.run()

        self.status(setup=True)

        while blocking:
            osc.readQueue()
            sleep(1)
Esempio n. 36
0
 def get_curency(self,req,data):
     currency=json.loads(data.decode("utf-8")) if  isinstance(data,dict) else data
     self.load_currency(currency)
     if self.started==True:
         return
     self.started=True
     self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=self.port)#3002
     osc.bind(oscid, self.get_currency_from_service, '/currency')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
    def __init__(self, **kwargs):
        super(BoxLayout, self).__init__( **kwargs)
        self.scroller = self.children[-1]

        self.grid = GridLayout(cols=1, spacing=1, size_hint_y=None)
        self.scroller.add_widget(self.grid)
        self.grid.bind(minimum_height=self.grid.setter('height'))

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=3002)
        osc.bind(oscid, self.add_more, '/some_api')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0.3)
Esempio n. 38
0
    def start(self, blocking=True):
        """
        Starts the anontunnel service
        :param blocking: True if this method should block or False to continue execution
        """

        self.setup_logging()
        self.log.info('Starting the anonymous tunnels...')

        socks5_port = None
        proxy_settings = ProxySettings()
        crawl = False

        self.tribler_start = clock()
        self.cpu_status(setup=True)

        self.NRHOPS = 3
        self.NRCIRCUITS = 3

        self.anon_tunnel = AnonTunnel(socks5_port,
                                      proxy_settings,
                                      crawl,
                                      hops=self.NRHOPS,
                                      circuits=self.NRCIRCUITS)
        self.anon_tunnel.run()

        self.cpu_status(stop=True)
        self.tribler_end = clock()

        # Store the basic setup
        self.startup_cpu_benchmark = self.cpu_benchmark

        # During download, run the cpu_status
        self.download_start = clock()
        self.cpu_status(setup=True)
        self.status(setup=True)

        while blocking:
            osc.readQueue()
            sleep(1)
Esempio n. 39
0
    def run(self):
        print 'updater run'
        osc.init()
        oscid = osc.listen('127.0.0.1', SERVICE_PORT)
        osc.bind(oscid, self.recv_osc, SERVICE_PATH)
        print 'listening for OSC'
        self.current_version = self.downloaded_version = self.get_current_version(
        )

        while True:
            if not self.last_check or (self.last_check +
                                       self.frequency) < time():
                if self.check_for_update():
                    self.download_update()

            if self.dlready.is_set():
                self.notify_client()
                self.dlready.clear()

            osc.readQueue(oscid)

            sleep(.1)
Esempio n. 40
0
 def build(self):
     self.title = "GoshenApp"
     #from kivy.core.window import Window
     #Window.size = (450, 600)
     #self.service = None
     self.start_service()
     osc.init()
     oscid = osc.listen(port=3002)
     osc.bind(oscid, self.display_message, '/message')
     Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
     self.theme_cls.theme_style = 'Dark'
     self.theme_cls.primary_palette = 'Indigo'
     self.nav_drawer = Drawer()
     return GbeeRoot()
Esempio n. 41
0
File: main.py Progetto: javto/AT3
    def start(self, blocking=True):
        """
        Starts the anontunnel service
        :param blocking: True if this method should block or False to continue execution
        """

        self.setup_logging()
        self.log.info('Starting the anonymous tunnels...')
        
        socks5_port = None
        proxy_settings = ProxySettings()
        crawl = False

        self.tribler_start = clock()
        self.cpu_status(setup=True)

        self.NRHOPS = 3
        self.NRCIRCUITS = 3

        self.anon_tunnel = AnonTunnel(socks5_port, proxy_settings, crawl, hops=self.NRHOPS, circuits=self.NRCIRCUITS)
        self.anon_tunnel.run()

        self.cpu_status(stop=True)
        self.tribler_end = clock()

        # Store the basic setup
        self.startup_cpu_benchmark = self.cpu_benchmark

        # During download, run the cpu_status 
        self.download_start = clock()
        self.cpu_status(setup=True)
        self.status(setup=True)

        while blocking:
            osc.readQueue()
            sleep(1)
Esempio n. 42
0
    def build(self):
        self.service = None
        #self.start_service()
        global interface
        osc.init()
        oscid = osc.listen(port=3002)
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

        if settings.exists("db"):
            pass
        else:
            settings.put("db", created=True)
            db.create_table(Todo)
        interface = Interface()
        return interface
Esempio n. 43
0
 def start_client(self):
     osc.init()
     oscid = osc.listen(ipAddr=self.net.client_host,
                        port=self.net.client_port)
     osc.bind(oscid, self.osc_handle_pong, '/pong')
     osc.bind(oscid, self.osc_handle_log, '/log')
     osc.bind(oscid, self.osc_handle_players, '/players')
     osc.bind(oscid, self.osc_handle_joined, '/joined')
     osc.bind(oscid, self.osc_handle_left, '/left')
     osc.bind(oscid, self.osc_handle_draw, '/draw')
     osc.bind(oscid, self.osc_handle_pos, '/pos')
     osc.bind(oscid, self.osc_handle_go, '/go')
     osc.bind(oscid, self.osc_handle_win, '/win')
     Clock.schedule_interval(lambda dt: osc.readQueue(oscid), 0)
     Clock.schedule_interval(lambda dt: self.gui.update(), 1 / 60.0)
     Clock.schedule_interval(lambda dt: self.osc_send_ping(), 0.25)
Esempio n. 44
0
    def build(self):
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('My Activity', 'running')
            service.start('service started')
            self.service = service

        osc.init()
        osc_id = osc.listen(ipAddr='127.0.0.1', port=activity_port)
        osc.bind(osc_id, self.my_callback, '/message')

        # Listen for messages regularly
        Clock.schedule_interval(lambda *x: osc.readQueue(osc_id), 0)

        btn = Button(text='Push me to see OSC working')
        btn.bind(on_release=self.send_msg_to_service)
        return btn
Esempio n. 45
0
    def build(self):
        #EventLoop.window.bind(on_keyboard=self.hook_keyboard)

        if platform == 'android':
            service = AndroidService('Sister Radio', 'running')
            service.start('service started!')
            self.service = service
            self.wakelock.start()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        osc.bind(oscid, self.is_playing, '/is_playing')
        osc.bind(oscid, self.is_stopped, '/is_stopped')

        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

        menu = Menu()
        return menu
Esempio n. 46
0
    def start_service(self):

        if platform == "android":
            Logger.info("main: Creating Android Service")
            from android import AndroidService
            service = AndroidService('Notification Demo', 'running')
            service.start('service started')
            self.service = service
        else:
            # purely for testing on non-android platforms,
            # although notification will not work
            Logger.info("main: Creating Service as Secondary Process")
            self.pid = Popen([sys.executable, "service/main.py"])

        osc.init()
        oscid = osc.listen(ipAddr=hostname, port=activityport)

        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
Esempio n. 47
0
    def __init__(self, **kargs):
        super(PedidosWidget, self).__init__(**kargs)
        Logger.debug('Cagada')
        self.listapedidos = []
        self.modify_pedidos = []
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('TpvB3 receptor', 'running')
            service.start('service started')
            self.service = service
        else:
            import os, threading
            #threading.Thread(target=os.system, args=("python ./service/main.py",)).start()

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=activityport)
        osc.bind(oscid, self.mostrar_pedidos, '/sync_pedidos')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
        self.mostrar_pedidos('ok')
Esempio n. 48
0
File: main.py Progetto: brussee/AT3
    def build(self):
        """
        Construct the screen manager with the appropriate screens
        """
        Window.clearcolor = (1, 1, 1, 1)
        
        self.lines = deque([])
        self.screens = {'anontunnels': AnonTunnelScreen(name='anontunnels'),
                        'settings': SettingsScreen(name='settings')}
        self.screen_manager = ScreenManager()
        for screen in self.screens.values():
            self.screen_manager.add_widget(screen)
        
        osc.init()
        self.oscid = osc.listen(ipAddr='127.0.0.1', port=9000)
        osc.bind(self.oscid, self.received_status, '/status')
        Clock.schedule_interval(lambda *x: osc.readQueue(), 0)

        return self.screen_manager
Esempio n. 49
0
    def build(self):
        """
        Construct the screen manager with the appropriate screens
        """
        Window.clearcolor = (1, 1, 1, 1)

        self.lines = deque([])
        self.screens = {
            'anontunnels': AnonTunnelScreen(name='anontunnels'),
            'settings': SettingsScreen(name='settings')
        }
        self.screen_manager = ScreenManager()
        for screen in self.screens.values():
            self.screen_manager.add_widget(screen)

        osc.init()
        self.oscid = osc.listen(ipAddr='127.0.0.1', port=9000)
        osc.bind(self.oscid, self.received_status, '/status')
        Clock.schedule_interval(lambda *x: osc.readQueue(), 0)

        return self.screen_manager
Esempio n. 50
0
    def __init__(self, **args):
        global _wna

        super(WhiteNoiseBackground, self).__init__(**args)
        self.setup_config()
        _wna = self
        
        self.last_ping = time.time()
        self.service_start = 0

        self.service = None
        self.start_service()
        osc.init()
        oscid = osc.listen(port=SERVICE_SND_PORT)
        
        osc.bind(oscid, self.service_ping, '/ping')
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
        Clock.schedule_interval(self.check_for_srvc, 0.5)
        self.service_warn = False

        self.init_gui()
Esempio n. 51
0
    def build(self):
        self.title = "Traffic simulator"

        # Android
        self.service = None
        self.start_service()

        # osc messages init
        osc.init()
        oscid = osc.listen(port=3002)
        # Send start/stop simulation
        osc.bind(oscid, self.start_simulation, '/send_start')
        # Receive hello world
        osc.bind(oscid, self.output_hello, '/receive_hello')
        # Retrieve simulation status
        osc.bind(oscid, self.simulation_status_receive, '/simu-status')
        # Retrieve server stopped
        osc.bind(oscid, self.server_stopped, '/server-stop')
        # Read received messages
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
        # Receive grid status
        osc.bind(oscid, self.grid_update, '/states')

        # Send message asking for simulation status
        osc.sendMsg('/simu-status_ask', [], port=3000)

        # Grid changes
        # self._size_handler_trigger = Clock.schedule_once(self._size_handler)  # Clock.create_trigger
        # self.bind(grid=self._size_handler_trigger)

        # normal variables
        self.grid_spots = []

        if not self.server_running:
            print("Simulation server not running")
            self.root.ids.label.text = "Simulation server not running :(\n"
Esempio n. 52
0
def exit_service():
    osc.sendMsg('/off', [
        'exit service',
    ], port=activityport)


def start(message, *args):
    if not mPlayer.isPlaying():
        mPlayer.prepare()  #prepareAsync()
        mPlayer.start()
        print 'Start'


def stop(message, *args):
    if mPlayer.isPlaying():
        mPlayer.stop()
        print 'Stop'


if __name__ == '__main__':
    osc.init()
    oscid = osc.listen(ipAddr='127.0.0.1', port=serviceport)
    osc.bind(oscid, start, '/play')
    osc.bind(oscid, stop, '/stop')
    osc.bind(oscid, check_state, '/check')

    while True:
        osc.readQueue(oscid)
        sleep(.1)
Esempio n. 53
0
 def read_osc_queue(self, *args):
     osc.readQueue(self.oscid)
Esempio n. 54
0
    def build(self):
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('my pong service', 'running')
            service.start('service started')
            self.service = service

        osc.init()
        oscid = osc.listen(ipAddr='127.0.0.1', port=ACTIVITY_PORT)
        osc.bind(oscid, self.some_api_callback, API_OFFSET)
        osc.bind(oscid, self.handle_alerts, API_OFFSET + "pending-alerts")
        Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)

        Window.size = 640, 480

        self.layout = TabbedPanel()
        self.layout.do_default_tab = True


        #self.status_tab = GridLayout()
        #self.layout.default_tab_content = self.status_tab
        #self.layout.default_tab_text = "Status"
        #self.status_tab.add_widget(Button(text="TODO make this page..."))

        #self.alert_tab = TabbedPanelHeader(text="Alert")
        self.alert_tab_box = BoxLayout()
        self.alert_tab_box.orientation = 'vertical'
        self.alert_tab_box.size_hint = 1, 1
        #self.alert_tab.content = self.alert_tab_box

        self.alert_tab_scroll = ScrollView(
                        size_hint=(1, 1),
                        size=self.alert_tab_box.size,
                        #size=Window.size,
                        scroll_type=['bars', 'content'],
                        do_scroll_y=True,
                        do_scroll_x=False
                    )
        self.alert_tab_box.add_widget(self.alert_tab_scroll)


        self.alert_tab_alert_buttons = ButtonList()
        self.alert_tab_alert_buttons.bind(minimum_height=self.alert_tab_alert_buttons.setter('height'))
        self.alert_tab_alert_buttons.cols = 1
        self.alert_tab_alert_buttons.size_hint_y = None
        self.alert_tab_alert_buttons.row_default_height = '30dp'
        self.alert_tab_alert_buttons.row_force_default = True
        self.alert_tab_alert_buttons.spacing = 0, 0
        self.alert_tab_alert_buttons.padding = 0, 0

        self.alert_tab_scroll.add_widget(self.alert_tab_alert_buttons)


        #self.requests_tab = TabbedPanelHeader(text="Requests")

        self.layout.default_tab_content = self.alert_tab_box
        self.layout.default_tab_text = "Alerts"
        #self.layout.add_widget(self.status_tab)
        #self.layout.add_widget(self.alert_tab)
        #self.layout.add_widget(self.requests_tab)

        self.request_pending_alerts()

        return self.layout
Esempio n. 55
0
 def wait(self):
     """ Start the loop where we wait for messages. """
     while True:
         osc.readQueue(self.osc_id)
         sleep(.1)
Esempio n. 56
0
		
	@mainthread
	def _run_vibrator_schema(self, period, gap):
		if platform=="android":
			vibrator.pattern(pattern=[0, period, gap], repeat=0)
		
	def stop_vibrator(self, message, *args):
		self._stop_vibrator()
		
	@mainthread
	def _stop_vibrator(self):
		if platform=="android":
			if self._callback:
				Clock.unschedule(self._callback)
				self._callback=None
			vibrator.cancel()

serviceVibratorController=BestVibratorAppServiceVibratorController()

if __name__=="__main__":

	osc.init()
	oscid=osc.listen(ipAddr="0.0.0.0", port=SERVICE_PORT)
	osc.bind(oscid, serviceVibratorController.run_vibrator, "/run_vibrator")
	osc.bind(oscid, serviceVibratorController.run_vibrator_schema, "/run_vibrator_schema")
	osc.bind(oscid, serviceVibratorController.stop_vibrator, "/stop_vibrator")
	
	while True:
		osc.readQueue(oscid)
		Clock.tick()
Esempio n. 57
0
 def __init__(self, rx_port, tx_port):
     self._rx_port, self._tx_port = rx_port, tx_port
     osc.init()
     self.oscid = osc.listen(port=rx_port)
     Clock.schedule_interval(lambda *x: osc.readQueue(self.oscid), 0)
Esempio n. 58
0
 def timed_ops(self, dt):
     osc.readQueue(self.osc_id)
Esempio n. 59
0
        my_id.locked = 1
        stopAll()
        sleep(random.uniform(0, 3))
        if f9.is_available == 0:
            f9.is_available = 1
            f9.videoPlay()
        print ('id 9 touched')
    if int(message[2]) == 0:
        stopAll()
        sleep(random.uniform(0, 3))
        if my_video.is_available == 0:
            my_video.is_available = 1
            my_video.self_video_play()
        my_id.locked = 0
        print ('Play My video')


if __name__ == '__main__':
    osc.init()
    oscid = osc.listen(ipAddr='0.0.0.0', port=serviceport)
    osc.bind(oscid, derrick_osc, '/derrick/osc')

    Clock.schedule_interval(lambda *x: osc.readQueue(oscid), 0)
    print (my_id.id_to_set, 'id_to_set')
    print (croparea_setter(my_id.id_to_set))

    if my_video.is_available == 0:
        my_video.is_available = 1
        my_video.self_video_play()

    DerrickApp().run()