Exemple #1
0
 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
Exemple #2
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')
Exemple #3
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
    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)
Exemple #5
0
 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
Exemple #6
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
Exemple #7
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())
Exemple #8
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
Exemple #9
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
Exemple #10
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()
    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)
Exemple #12
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)
Exemple #13
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)
Exemple #14
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 )
Exemple #15
0
 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)
Exemple #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"
    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)
    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)
Exemple #19
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)
    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)
Exemple #21
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
Exemple #22
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)
    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()
Exemple #24
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
Exemple #25
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"
Exemple #26
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)
Exemple #27
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()
Exemple #28
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()
Exemple #29
0
 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')
Exemple #30
0
#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)