예제 #1
0
파일: main.py 프로젝트: Mau21710/Mentor
 def build(self):
     # the root is created in pictures.kv
     self.root
     self.osc_id = osc.listen(ipAddr='0.0.0.0', port=activity_port)
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('Mentor Service', 'running')
         service.start('service started')
         self.service = service
     # get any files into images directory
     curdir = dirname(__file__)
     list = glob(join(curdir, 'images', '*'))
     Logger.debug("{}".format(list))
     shuffle(list)
     Logger.debug("{}".format(list))
     for filename in list:
         try:
             # load the image
             picture = Picture(source=filename, id=filename, rotation=randint(-30, 30))
             # add to the main field
             self.root.add_widget(picture)
         except Exception as e:
             Logger.exception('Pictures: Unable to load <%s>' % filename)
     osc.init()
     self.last_name = ""
     osc.sendMsg('/say', ["La ap di Michele e' pronta", ], port=service_port)
     return self.root
예제 #2
0
파일: main.py 프로젝트: Mau21710/Mentor
 def build(self):
     """config = ConfigParser()
     config.read('conf.ini')
     self.config = Settings()
     # s.add_json_panel('My custom panel', config, 'settings_custom.json')"""
     self.icon = 'images/ic_launcher.png'
     self.osc_activities = []
     self.speechs = []
     self.osc_id = osc.listen(ipAddr='0.0.0.0', port=activity_port)
     self.count_requests = 0
     self.timer_value = "40.10.10.1"
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('Mentor Service', 'running')
         service.start('service started')
         self.service = service
         self.folder_music = "/storage/emulated/legacy/Music/PerAttivita"
     elif platform == 'win':
         self.folder_music = "C:\\Mao\\Progetti\\Musica\\MusicaSuNexus\\PerAttivita"
     else:
         self.folder_music = ".\\music"
     Logger.info("Folder music: {}".format(self.folder_music))
     self.sequences = mentor_lib.Sequences()
     self.sequences.load_sequences()
     self.root = MentorWidget()
     text_input = TextInput(text=self.timer_value, font_size=40, multiline=False)  #, size_hint=(None, None))  # font_size=20,
     text_input.foreground_color = [1, 1, 1, 1]
     text_input.background_color = [0, 0, 0, 0]
     text_input.shorten_from = 'center'
     #text_input.center_x = True
     #text_input.center_y = True
     text_input.bind(text=self.on_text_input_text)
     self.root.ids.grid_main.add_widget(text_input)
     btn = Button(text="Custom Timer")  #, size_hint_y=None, height=40)
     #btn.height = text_input.content_height
     btn.bind(on_press=partial(self.start_sequence, "timer"))
     self.root.ids.grid_main.add_widget(btn)
     for title in self.sequences.titles:
         btn = Button(text=title)#, size_hint_y=None, height=40)
         btn.bind(on_press=partial(self.start_sequence, title))
         self.root.ids.grid_main.add_widget(btn)
     #if len(self.sequences.titles)%2:
     #    btn = Button(text="_     _", id='pippo')  #, size_hint_y=None, height=40)
     #    self.root.ids.grid_main.add_widget(btn)
     #self.start_sequence_ok = False
     #self.sequence_buttons = []
     #for i in self.sequences.titles:
         #self.sequence_buttons.append(Button(text=str(i)))
         #self.sequence_buttons[-1].bind(on_press=self.start_sequence(str(i)))
         #self.sequence_buttons[-1].bind(on_release=self.start_sequence(str(i)))
         #btn.bind(state=self.start_sequence(str(i)))
         #btn.bind(on_release=self.root.start_sequence(btn.text))
         #self.root.ids.grid_main.add_widget(self.sequence_buttons[-1])
         #self.root.ids.grid_main.add_widget(Button(text=str(i), on_press=self.start_sequence(str(i))))
     #self.start_sequence_ok = True
     osc.init()
     osc.bind(self.osc_id, self.msg_from_server, '/msg')
     osc.bind(self.osc_id, self.root.write_cockpit, '/osd')
     Clock.schedule_interval(self.timed_ops, .1)
     return self.root
예제 #3
0
파일: main.py 프로젝트: jiemde/GPSTracker
def startOsc():
    """start up the communication between service and main app"""
    osc.init()
    oscid = osc.listen(ipAddr='127.0.0.1', port=IPCServicePort)
    osc.bind(oscid, device_callback, '/device')
    osc.bind(oscid, stop_callback, '/stop')
    return oscid
    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)
예제 #5
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
예제 #6
0
 def __init__(self):
     osc.init()
     self.last_update = 0
     self.oscid = osc.listen(ipAddr='localhost', port=SERVICE_PORT)
     osc.bind(self.oscid, self.pocket_connect, '/pocket/connect')
     osc.bind(self.oscid, self.pocket_list, '/pocket/list')
     osc.bind(self.oscid, self.pocket_mark_read, '/pocket/mark_read')
예제 #7
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
예제 #8
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()
예제 #9
0
파일: main.py 프로젝트: Tarliton/tcclousa
	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
예제 #10
0
 def __init__(self):
     osc.init()
     self.oscid = osc.listen(ipAddr='127.0.0.1', port=SERVICE_PORT)
     osc.bind(self.oscid, self.handle_incoming_message, API_OFFSET)
     osc.bind(self.oscid, self.handle_request_for_pending_alerts,
              API_OFFSET + "pending-alerts")
     osc.bind(self.oscid, self.handle_classify_alert,
              API_OFFSET + "classify-alert")
예제 #11
0
파일: gps.py 프로젝트: ameursh/kivymd
 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)
예제 #12
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())
예제 #13
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())
예제 #14
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
예제 #15
0
    def init_osc(self):
        from kivy.lib import osc
        osc.init()
        self.oscid = osc.listen(ipAddr='127.0.0.1', port=self.receive_port)

        osc.bind(self.oscid, self.receive_osc_message, b'/stdout')
        osc.bind(self.oscid, self.receive_osc_message, b'/stderr')
        osc.bind(self.oscid, self.receive_osc_message, b'/interpreter')
        osc.bind(self.oscid, self.receive_osc_message, b'/pong')
예제 #16
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
예제 #17
0
 def __init__(self, queue):
     self.queue = queue
     self.stopped = False
     self.thread = threading.Thread(name='query', target=self.run)
     osc.init()
     self.oscid = osc.listen(ipAddr='127.0.0.1', port=3334)
     osc.bind(self.oscid, self.handle_message, '/android_park')
     self.thread.start()
     self.pending = {}
     self.next_id = 0
예제 #18
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
예제 #19
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()
예제 #20
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()
예제 #21
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"
예제 #22
0
파일: main.py 프로젝트: thedod/mazerace
 def serve(self):
     self.state = 'open'
     osc.init()
     self.oscid = osc.listen(ipAddr=self.net.server_host, port=self.net.server_port)
     osc.bind(self.oscid, self.osc_handle_ping, '/ping')
     osc.bind(self.oscid, self.osc_handle_join, '/join')
     osc.bind(self.oscid, self.osc_handle_leave, '/leave')
     osc.bind(self.oscid, self.osc_handle_start, '/start')
     osc.bind(self.oscid, self.osc_handle_pos, '/pos')
     while True:
         self.loop()
         sleep(.05)
예제 #23
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)
예제 #24
0
파일: main.py 프로젝트: yahyakesenek/Book
 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)
예제 #25
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)
예제 #26
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 )
예제 #27
0
파일: main.py 프로젝트: iamtomc/kivy_gosh
 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()
예제 #28
0
파일: main.py 프로젝트: Mau21710/Mentor
 def _init_services(self):
     osc.init()
     self.osc_id = osc.listen(ipAddr='0.0.0.0', port=activity_port)
     osc.bind(self.osc_id, self._msg_from_server, '/msg')
     osc.bind(self.osc_id, self._sequence_loaded, '/sld')
     osc.bind(self.osc_id, self._write_cockpit, '/osd')
     osc.bind(self.osc_id, self._write_timer, '/tmr')
     #osc.bind(self.osc_id, self.root.write_cockpit, '/osd')
     if is_android:
         from android import AndroidService
         service = AndroidService('Mentor Service', 'running')
         service.start('service started')
         self.service = service
     Clock.schedule_interval(self.timed_ops, 1.0)
예제 #29
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"
예제 #30
0
 def __init__(self, **kwargs):
     self.port = kwargs.get('port')
     _reader_should_run = None
     _reader_thread = None
     self._rx_queue = Queue.Queue()
     osc.init()
     oscid = osc.listen(ipAddr='0.0.0.0', port=CLIENT_API_PORT)
     osc.bind(oscid, self.on_rx, RX_API)
     osc.bind(oscid, self.on_command, CMD_API)
     self._oscid = oscid
     
     service = AndroidService('RC comms service', 'running')
     service.start('service started')
     self._service = service
예제 #31
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
예제 #32
0
	def __init__(self,**kwargs):
		super(testapp, self).__init__(**kwargs)
		self.client_id = '001'
		self.mqtt_topics = []
		self.server_ip = ''
		self.broker_1 = ''
		self.broker_2 = ''
		self.send_topic = ''
		self.ack_topic = ''
		self.connected = False
		osc.init()
		self.oscid = osc.listen(ipAddr='127.0.0.1', port=3000)	
		osc.bind(self.oscid, self.get_serverIP, '/serverIP')
		osc.bind(self.oscid, self.get_clientID, '/clientID')
		osc.bind(self.oscid, self.send_command, '/command')
예제 #33
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)
    def _test_3_test_service_job(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")

        sleep(1)

        osc.sendMsg(oscAddress ='/run_job', ipAddr="0.0.0.0", dataArray=["Default", ], port=3000)

        sleep(10)

        osc.sendMsg(oscAddress ='/stop', ipAddr="0.0.0.0", dataArray=[], port=3000)
예제 #35
0
파일: main.py 프로젝트: shivan1b/kivy_osc
    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
예제 #36
0
파일: main.py 프로젝트: RahulJain7/IOT_App
	def __init__(self,**kwargs):
		super(NotificationDemo, self).__init__(**kwargs)
		self.temp = [0,0,0,0]
		self.tempchg = None
		self.humchg = None
		self.dataRecv = '[0,0,0,0]'
		self.broker='106.201.235.43'
		self.service = 3000
		osc.init()
		self.oscid = osc.listen(ipAddr='127.0.0.1', port=3000)
		osc.bind(self.oscid, self.settings_data, '/settings_data')
		self.alert_settings = [20,40,20,50]
		self.notifications_received = ObjectProperty(None)
		self.notification_title = ObjectProperty(None)
		self.notification_text = ObjectProperty(None)
		self.olddat = [0,0,0,0]
		self.notification_msg = ['No Notification', '', '','down2.png']
		self.a = 0
예제 #37
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
예제 #38
0
    def __init__(self, **kwargs):
        if platform == 'android':
            sp = {'service':3000, 'app':3001}
            serv = 'APPIX_SERVICE' in os.environ
            self.send_port = sp['service' if serv else 'app']
            self.listen_port = sp['service' if not serv else 'app']
            print self.listen_port, 'port', serv,  'APPIX_APP' in os.environ
            super(AppixComm, self).__init__()
            osc.init()
            self.keep_listening = False
            self.oscid = osc.listen(ipAddr='127.0.0.1', port=self.listen_port)
            osc.bind(self.oscid, self.read_message, '/AppixCom')
            self.bluetooth_standby_time = 0
            self.app = App.get_running_app()
            self.time_since_app_paused = 0

            self.debug = DEBUG
            self.admin_app = ADMIN_APP
예제 #39
0
    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)
예제 #40
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)
예제 #41
0
파일: main.py 프로젝트: 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
예제 #42
0
파일: main.py 프로젝트: vallemrv/tpvB3
    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')
예제 #43
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)
예제 #44
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)
예제 #45
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()
예제 #46
0
파일: main.py 프로젝트: rjagerman/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
예제 #47
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)
예제 #48
0
 def __init__(self):
     L.debug("Service is running")
     # Initialize internal queue
     self.thread = threading.Thread(name='execution', target=self.async_run)
     self.internal_queue = Queue()
     self.thread.start()
     # Initialize OSC
     osc.init()
     self.oscid = osc.listen(ipAddr='127.0.0.1', port=3333)
     osc.bind(self.oscid, self.handle_message, '/android_park')
     self.server = ServerInterface()
     self.pending = {}
     self.last_time = None
     self.notified = True
     self.config = None
     # set to indicate that a month has been processed by the pattern
     self.pattern_processed=set()
     # Initialize timezones
     self.met = pytz.timezone('Europe/Madrid')
     self.t1 = datetime.time(hour=0, minute=0, second=0, tzinfo=self.met)  # 00:00
     self.t2 = datetime.time(hour=15, minute=0, second=0, tzinfo=self.met)  # 15:00
     self.t3 = datetime.time(hour=17, minute=30, second=0, tzinfo=self.met)  # 17:30
     self.t4 = datetime.time(hour=23, minute=59, second=59, tzinfo=self.met)  # 23:59
예제 #49
0
파일: main.py 프로젝트: PdeRooij/DMAS
    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"
예제 #50
0
파일: main.py 프로젝트: Tarliton/tcclousa
#Copyright (C) 2015  Tarliton Godoy
#
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

from kivy.lib import osc
from time import localtime, asctime, sleep


def send_date():
	osc.sendMsg('/date', [asctime(localtime()), ], port=3002)


if __name__ == '__main__':
	osc.init()
	oscid = osc.listen(ipAddr='0.0.0.0', port=3000)
	while True:
		osc.readQueue(oscid)
		send_date()
		sleep(.1)
예제 #51
0
파일: notify.py 프로젝트: bix709/MobileApps
# -*- coding: utf-8 -*-
"""
    author: Tomasz Teter
    copyright : 5517 Company
"""
import os
from kivy.lib import osc
from adventureskiing.notification_service.notification_manager import NotificationManager


def stop_service(*args):
    notification_listener.stop()
    exit(0)


if __name__ == '__main__':
    session_id = int(os.getenv('PYTHON_SERVICE_ARGUMENT'))
    notification_listener = NotificationManager(session_id)
    notification_listener.start()
    osc.init()
    oscid = osc.listen(ipAddr='0.0.0.0', port=3000)
    osc.bind(oscid, stop_service, '/stop')
    while True:  # Needs to be alive, because broadcast_receiver will no longer exist.
        osc.readQueue(oscid)
예제 #52
0
파일: tuio.py 프로젝트: 15huangtimothy/kivy
 def start(self):
     '''Start the TUIO provider'''
     self.oscid = osc.listen(self.ip, self.port)
     for oscpath in TuioMotionEventProvider.__handlers__:
         self.touches[oscpath] = {}
         osc.bind(self.oscid, self._osc_tuio_cb, oscpath)
예제 #53
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)
예제 #54
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()
예제 #55
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)
예제 #56
0
 def start(self):
     '''Start the TUIO provider'''
     self.oscid = osc.listen(self.ip, self.port)
     for oscpath in TuioMotionEventProvider.__handlers__:
         self.touches[oscpath] = {}
         osc.bind(self.oscid, self._osc_tuio_cb, oscpath)
예제 #57
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()
예제 #58
0
파일: server.py 프로젝트: EMATech/kivybits
 def __init__(self):
     """ Create a listener and start managing comms. """
     osc.init()
     self.osc_id = osc.listen(ipAddr='127.0.0.1', port=OSCServer.server_port)
     osc.bind(self.osc_id, self.kivy_server, 'kivy_server')