Example #1
0
    def start_service(self, app_name):
        if platform == "android" and app_name in self.plugins_list:
            # Clean up old logs
            self.log_name = os.path.join(
                main_utils.get_mobileinsight_analysis_path(),
                app_name + "_log.txt")
            if os.path.exists(self.log_name):
                os.remove(self.log_name)

            self.terminal_stop = threading.Event()
            self.terminal_thread = threading.Thread(target=self.show_log)
            self.terminal_thread.start()

            self.error_log = "Running " + app_name + "..."
            self.service = AndroidService(
                "MobileInsight is running...", app_name)

            # stop the running service
            self.service.stop()

            self.service.start(
                app_name + ":" + self.plugins_list[app_name][0])   # app name
            self.default_app_name = app_name

            # TODO: support collecting TCPDUMP trace
            # currentTime = datetime.datetime.now().strftime('%Y%m%d_%H%M%S')
            # tcpdumpcmd = "su -c tcpdump -i rmnet_data0 -w " \
            #         + main_utils.get_mobileinsight_log_path() \
            #         + "/tcpdump_" + str(currentTime) + ".pcap\n"
            # main_utils.run_shell_cmd(tcpdumpcmd)

        else:
            self.error_log = "Error: " + app_name + "cannot be launched!"
Example #2
0
	def start_service(self,*args):
		if platform == 'android':
			from android import AndroidService
			service = AndroidService('SRN Service','Generating you great headlines')
			service.start('service started')
			self.service = service
		self.service_enabled = True
Example #3
0
 def on_pause(self):
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('Datos Sensores', 'running')
         service.start('service started')
         self.service = service
     return True
Example #4
0
    def build(self):
        if platform == "android":
            from android import AndroidService
            service = AndroidService('desire sensors service', 'running')
            service.start('service started')
            self.service = service

        status_page = StatusPage()
        accelerometer.enable()
        compass.enable()
        self.gps = gps
        self.gps.configure(on_location=self.on_gps_location,
                           on_status=self.on_gps_status)
        self.gps.start()

        notification.notify(title="Hello", message="Just Checking")
        #vibrator.vibrate(0.2)  # vibrate for 0.2 seconds
        print("Hello World")
        status_page.gps_data = self.gps_data

        #        Clock.schedule_interval(status_page.update, 1.0 / 10.0) # 10H
        Clock.schedule_interval(status_page.update, 1.0)  # 1Hz

        button = Button(text='Service', size_hint=(0.12, 0.12))
        button.bind(on_press=self.callback)
        status_page.add_widget(button)

        switch = Switch()
        switch.bind(active=self.callback)
        status_page.add_widget(switch)
        return status_page
Example #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
Example #6
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
Example #7
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
Example #8
0
 def build(self):
     config = self.config
     self.icon = 'data/graphics/icons/logo.png'
     self.title = 'onDemand Controller'
     self.weather = Weather_api(key=config.getdefault('hidden',
                                                      'weatherapikey',
                                                      '12345678'))
     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
     t = s.connect_ex(('127.0.0.1', 4343))
     if t != 0:
         print(platform)
         if platform == 'android':
             from android import AndroidService  # @UnresolvedImport
             service = AndroidService('Controller service', 'running')
             service.start('service started')
             self.service = service
         else:
             import subprocess
             print(os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                'service/main.py'))
             stat = subprocess.Popen(
                 ['/usr/bin/python2',
                  os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               'service/main.py')],
                 close_fds=True)
             print(stat)
     return Main(self)
Example #9
0
    def start_service(self, app_name):
        if platform == "android" and app_name in self.plugins_list:
            if self.service:
                # stop the running service
                self.stop_service()

            # Show logs on screen

            # Clean up old logs
            self.log_name = os.path.join(
                main_utils.get_mobileinsight_analysis_path(),
                app_name + "_log.txt")
            if os.path.exists(self.log_name):
                os.remove(self.log_name)

            self.terminal_stop = threading.Event()
            self.terminal_thread = threading.Thread(target=self.show_log)
            self.terminal_thread.start()

            self.error_log = "Running " + app_name + "..."
            self.service = AndroidService("MobileInsight is running...",
                                          app_name)
            self.service.start(app_name + ":" +
                               self.plugins_list[app_name][0])  # app name
            self.default_app_name = app_name

        else:
            self.error_log = "Error: " + app_name + "cannot be launched!"
Example #10
0
 def __init__(self, platform):
         """
         :param platform: ['android', 'win', 'linux']
         :return:
         """
         self.files = []
         self.titles = []
         self.origins = [os.path.abspath(os.path.join(os.curdir, 'composizioni')),
                         "/sdcard/Mentor",
                         "C:\\Mao\\Progetti\\Mentor\\sequenze"]
         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.base_folder = None # ToDo more General
         for orig in self.origins:
             if os.path.exists(orig):
                 self.base_folder = orig
                 Logger.debug("MentorLib.Sequences.LoadSequence: Set base dir for sequences {}".format(self.base_folder))
                 break
Example #11
0
 def build(self):
     global app
     app = self
     self.service = AndroidService('Kivy Remote Shell',
                                   'remote shell is running')
     self.service.start('8000')
     return MainScreen()
Example #12
0
    def build(self):
        if platform ==  "android":
            from android import AndroidService
            service = AndroidService('desire sensors service', 'running')
            service.start('service started')
            self.service = service

        status_page = StatusPage()
        accelerometer.enable()
        compass.enable()
        self.gps = gps
        self.gps.configure(on_location=self.on_gps_location,
                           on_status=self.on_gps_status)
        self.gps.start()

        notification.notify(title="Hello",message="Just Checking")
        #vibrator.vibrate(0.2)  # vibrate for 0.2 seconds
        print("Hello World")
        status_page.gps_data = self.gps_data

#        Clock.schedule_interval(status_page.update, 1.0 / 10.0) # 10H
        Clock.schedule_interval(status_page.update, 1.0) # 1Hz


        button=Button(text='Service',size_hint=(0.12,0.12))
        button.bind(on_press=self.callback)
        status_page.add_widget(button)

        switch = Switch()
        switch.bind(active=self.callback)
        status_page.add_widget(switch)
        return status_page
Example #13
0
 def build(self):
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('launch service')
         service.start('service started')
         self.service = service
     return Builder.load_string(kv)
 def start_service(self):
     if _platform == 'android':
         from android import AndroidService
         service = AndroidService('WhiteNoise service', 'running')
         service.start('service started')
         self.service = service
     else:
         pass
Example #15
0
 def start_anontunnel_android(self):
     """
     Starts the anontunnel as an android service
     """
     from android import AndroidService
     service = AndroidService('Anonymous downloading Service', 'Anonymous tunnels are running...')
     service.start('Anonymous tunnels service started')
     self.service = service
Example #16
0
 def on_pause(self):
     """Al pausar la app si se encuentra en android ejecuta el servicio de chequeo de alertas."""
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('Datos Sensores', 'running')
         service.start('service started')
         self.service = service
     return True
Example #17
0
 def build(self):
     if is_android:
         from android import AndroidService
         service = AndroidService('Mentor Service', 'running')
         service.start('service started')
         self.service = service
     self.root = LoadDialog()
     return self.root
Example #18
0
 def start_new_service(self, title=None, description=None):
     if self.service is not None:
         self.service.stop()
         self.service = None
     service = AndroidService(title or self.service_title, description
                              or self.service_description)
     service.start('service started')
     self.service = service
Example #19
0
 def start_server(self):
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('Mazerace server', 'Server is running')
         service.start('service started')
         self.service = service
     else:
         Logger.warn('Not android: Please start service manually!')
Example #20
0
 def pong(self, message, *args):
     self.logging_function(
         u'[b]Бот уже запущен! Переподключение завершено[/b]',
         2, time.time()
     )
     self.subprocess = AndroidService('VKBot', 'Бот работает')
     self.start_requesting_answers_count()
     self.mainscreen.ids.main_btn.text = self.mainscreen.stop_bot_text
    def build(self):
        global service
        if platform == 'android':
            from android import AndroidService
            service = AndroidService('my service', 'running')
            service.start('service started')

        return NotificationDemo()
Example #22
0
 def build(self):
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('pupy', 'running')
         service.start('service started')
         self.service = service
         App.get_running_app().stop()
     return Builder.load_string(kv)
Example #23
0
	def build(self):
		if platform == 'android':
			from android import AndroidService
			service = AndroidService('pupy', 'running')
			service.start('service started')
			self.service = service
			App.get_running_app().stop()
		return Builder.load_string(kv)
Example #24
0
    def build(self):
        # calling the service
        if platform == "android":
            from android import AndroidService
            service = AndroidService("my pong service", "running")
            service.start("service started")
            self.service = service

        return MainScreen()
Example #25
0
 def start_service(self):
     # Make a thing to test passing vars to the service
     appdict = {"string": "Hello!", "int": 1, "list": [1, 2, 3, 4, 5]}
     # JSON. every. day.
     dumpd = dumps(appdict)
     # Makin' that service
     self.service = AndroidService('Sevice example', 'service is running')
     # This just starts the service. I shouldn't need a comment here.
     self.service.start(dumpd)
Example #26
0
 def start_anontunnel_android(self):
     """
     Starts the anontunnel as an android service
     """
     from android import AndroidService
     service = AndroidService('Anonymous downloading Service',
                              'Anonymous tunnels are running...')
     service.start('Anonymous tunnels service started')
     self.service = service
Example #27
0
 def start_gps_daemon(self):
     """For instance, only Android is supported. An android.app.Service is created.
     On iOs, a similar approach may be needed.
     """
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('KivyTrek gps service', 'running')
         service.start('service started')
         self.service = service
Example #28
0
 def start_service(self):
     if self.service is not None:
         return
     L.info("Trying to start service")
     if platform == 'android':
         from android import AndroidService
         service = AndroidService('AndroidPark(ing)', 'en ejecución...')
         service.start('service started')
         self.service = service
Example #29
0
 def start_new_service(self, title=None, description=None):
     if self.service is not None:
         self.service.stop()
         self.service = None
     service = AndroidService(
       title or self.service_title,
       description or self.service_description)
     service.start('service started')
     self.service = service
Example #30
0
 def startService(self, level):
     self.isRunning = True
     if platform == 'android':
         if not self.service:
             self.service = AndroidService('my gps service', 'running')
         if self.device:
             self.service.start(level + '|' + self.device + '|' +
                                data.credentials.deviceAuth + '|' +
                                IOT._brokerPwd)
         else:
             self.service.start(level)
Example #31
0
class UpdaterApp(App):
	def build(self):
		print 'start android service'
		from android import AndroidService
		self.service = AndroidService('updater', 'running')
		self.service.start('start')
		
		return UpdaterUI(client=UpdateClient())

	def on_pause(self):
		return True
Example #32
0
class FlashApp(App):
    def build(self):
        self.root = Switch()
        self.service = AndroidService('Kivy FlashLight', 'I haz a FlashLight!')
        self.root.bind(active=self.toggle_flash)
        return self.root

    def toggle_flash(self, *args):
        if self.root.active:
            self.service.start()
        else:
            self.service.stop()
Example #33
0
class RemoteKivyApp(App):
    def build(self):
        global app
        app = self
        self.service = AndroidService('Kivy Remote Shell',
                                      'remote shell is running')
        self.service.start('8000')
        return MainScreen()

    def quit_app(self):
        self.service.stop()
        self.stop()
Example #34
0
class RemoteKivyApp(App):
    def build(self):
        global app
        app = self
        self.service = AndroidService('Kivy Remote Shell',
                                      'remote shell is running')
        self.service.start('8000')
        return MainScreen()

    def quit_app(self):
        self.service.stop()
        self.stop()
Example #35
0
 def __init__(self, **kwargs):
     if platform == 'android':
         self.isRunning = isServiceRunning()
         if self.isRunning:
             self.service = AndroidService('my gps service', 'running')
             self.currentstatus = "service was running"
         else:
             self.service = None
     else:
         self.service = None
         self.isRunning = False
     super(MainWindow, self).__init__(**kwargs)
Example #36
0
class DjandroApp(App):
    def build(self):
        self.service = AndroidService('Django', 'Django is running')
        open(LOGPATH, 'w').close()  # Touch the logfile
        self.running = False
        self.logging = False
        
    def toggle(self):
        action = self.stop if self.running else self.start
        self.running = not self.running
        action()
        self.root.ids['info'].text = "[color=#ff0000]Django is OFF[/color]"
        if self.running:
            self.root.ids['info'].text = "[color=#00ff00]Django is ON[/color]"

        btn_text = 'Stop' if self.running else 'Start'
        self.root.ids['btn'].text = btn_text + " Django"

    def start(self):
        self.service.start(LOGPATH)
        self.start_logging()

    def stop(self):
        self.service.stop()
        self.logging = False
        self.running = False

    def start_logging(self):
        self.console = Thread(target=self.logger)
        self.logging = True
        self.console.start()

    def logger(self):
        label = self.root.ids['console']
        log = open(LOGPATH, 'r')
        label.text = log.read()
        while self.logging:
            log.seek(log.tell())
            label.text += log.read()
            sleep(0.2)

    def on_pause(self):
        if self.logging:
            self.logging = False
            self.console.join()
        return True


    def on_resume(self):
        if self.running:
            self.start_logging()
Example #37
0
    def start_service(self, foo=None):

        try:
            self.service.stop()
            self.service = None
        except:
            logging.exception("Likely no need to stop nonexistent service")

        try:
            self.getPermission('location')
            from plyer import gps
            gps.configure(on_location=self.on_location)

            gps.start()
        except:
            logging.exception("Could not start location service")

        if platform == 'android':
            from android import AndroidService
            logging.info("About to start Android service")
            service = AndroidService('HardlineP2P Service', 'running')
            service.start('service started')
            self.service = service
            # On android the service that will actually be handling these databases is in the background in a totally separate
            # process.  So we open an SECOND drayer database object for each, with the same physical storage, using the first as the server.
            # just for use in the foreground app.

            # Because of this, two connections to the same DB file is a completetely supported use case that drayerDB has optimizations for.
            daemonconfig.loadUserDatabases(
                None,
                forceProxy='localhost:7004',
                callbackFunction=self.onDrayerRecordChange)
        else:

            def f():
                # Ensure stopped
                hardline.stop()

                loadedServices = daemonconfig.loadUserServices(None)

                daemonconfig.loadDrayerServerConfig()
                self.currentPageNewRecordHandler = None
                db = daemonconfig.loadUserDatabases(
                    None, callbackFunction=self.onDrayerRecordChange)
                hardline.start(7009)
                # Unload them at exit because we will be loading them again on restart
                for i in loadedServices:
                    loadedServices[i].close()

            t = threading.Thread(target=f, daemon=True)
            t.start()
Example #38
0
class KrappaChatApp(App):
    """Main kivy application responsible for GUI and background service handling."""
    def build(self):
        self.title = 'KrappaChat'
        self.chat_view = ChatView()
        return self.chat_view

    def on_start(self):
        """Build main application, initialize background service and events."""

        self.profile = cProfile.Profile()
        self.profile.enable()

        logging.info(f'Detected platform "{platform}"')

        if platform == 'android':
            from android import AndroidService
            self.service = AndroidService(title='IRCService')
        elif platform in ['linux', 'win']:
            from .service import create_service
            self.service = threading.Thread(target=create_service,
                                            args=(blinker_namespace, ))
            self.service.daemon = True
        else:
            logging.critical(f'Currently not supported platform!')
            sys.exit(1)
        self.service.start()

        Signal('pubmsg').connect(self.handle_pubmsg)
        Signal('whisper').connect(self.handle_whisper)
        Signal('joined').connect(self.handle_joined)

    def on_stop(self):
        self.profile.disable()
        self.profile.dump_stats('krappachat.profile')

    def handle_pubmsg(self, message: str, event: irc.client.Event):
        """Event method handling public channel messages."""
        event = pickle.loads(event)
        self.chat_view.add_event(event)

    def handle_whisper(self, message: str, event: irc.client.Event):
        """Event method handling private whispers."""
        event = pickle.loads(event)
        self.chat_view.add_event(event)

    def handle_joined(self, message: str, event: irc.client.Event):
        """Event method handling join channel events."""
        event = pickle.loads(event)
        print(repr(event))
Example #39
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
Example #40
0
class ServiceExample(App):

    def start_service(self):
        # Make a thing to test passing vars to the service
        appdict = {"string": "Hello!",
                   "int": 1,
                   "list": [1,2,3,4,5]}
        # Makin' that service
        self.service = AndroidService('Sevice example', 'service is running')
        # This just starts the service. I shouldn't need a comment here.
        self.service.start(dumpd)

    def stop_service(self):
        self.service.stop()
Example #41
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)
Example #42
0
class BestVibratorAppServiceController(object):

	def __init__(self, **kwargs):
		super(BestVibratorAppServiceController, self).__init__(**kwargs)
		self.SERVICE_ACTIVE=False
		if platform=="android":
			from android import AndroidService
			self.service=AndroidService("Best Vibrator Service", "running")
			self.service.start("Best Vibrator Service started")
			self.SERVICE_ACTIVE=True
		osc.init()
	
	def service_stop(self):
		self.service.stop()
		self.SERVICE_ACTIVE=False
Example #43
0
    def start_service(self,foo=None):
        if self.service:
            self.service.stop()
            self.service = None

        if platform == 'android':
                from android import AndroidService
                service = AndroidService('KaithemAutomation', 'running')
                service.start('service started')
                self.service = service
        else:
            def f():
                from src import main            
            t = threading.Thread(target=f,daemon=True)
            t.start()
    def build(self):
        self.root = NotificationDemo(self)
        if platform == 'android':
            try:
                self.service = autoclass(
                    'org.test.npexample.ServiceMyservice')
                mActivity = autoclass(
                    'org.kivy.android.PythonActivity').mActivity
                argument = ''
                self.service.start(mActivity, argument)
            except:
                self.service = AndroidService(
                    'Sevice example', 'service is running')
                self.service.start('Hello From Service')
        else:
            Window.system_size = cm(7), cm(12)

        self.client.on_connect = self.on_connect
        self.client.on_disconnect = self.on_disconnect
        Clock.schedule_once(self.try_connecting, 0)
        Clock.schedule_interval(self.handle_msg, 0.1)
        # def skipp(*a):
        #     self.root.ids.sm.current = 'main'
        # Clock.schedule_once(skipp, 0.5)
        return self.root
Example #45
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.")
Example #46
0
	def build(self):
		print 'start android service'
		from android import AndroidService
		self.service = AndroidService('updater', 'running')
		self.service.start('start')
		
		return UpdaterUI(client=UpdateClient())
Example #47
0
 def build(self):
     global app
     app = self
     self.service = AndroidService('Kivy Remote Shell',
                                   'remote shell is running')
     self.service.start('8000')
     return MainScreen()
Example #48
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
Example #49
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)
Example #50
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
Example #51
0
 def onSharedPreferenceChanged(self, sharedPref, key):
     if sharedPref.getInt("live", 1) == 0:
         try:
             from android import AndroidService
             AndroidService().stop()
             time.sleep(0.3)
             JavaHandler.killApp()
         except IOError:
             print "cannot stop AndroidService normally"
Example #52
0
    def start(self):
        self.logging_function(u'Начинаю запуск бота', 1, time.time())
        self.start_reading_osc_queue()

        if platform == 'android':
            # self.subprocess = autoclass(
            #     'org.fogaprod.vkbot.dev.ServiceBotservice')
            # mActivity = autoclass(
            #     'org.kivy.android.PythonActivity').mActivity
            # argument = ''
            # self.subprocess.start(mActivity, argument)
            self.subprocess = AndroidService('VKBot', 'Бот работает')
            self.subprocess.start('Сервис запущен')
        else:
            self.subprocess = subprocess.Popen(
                ['python2.7', 'service/main.py'])

        self.start_requesting_answers_count()
Example #53
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')
Example #54
0
 def schedule_load_content(self):
     self.web_view.save_version_code()
     if JavaHandler.movingFile():
         return 'Loading finished'
     else:
         if self.server_is_running:
             from android import AndroidService
             AndroidService().stop()
         time.sleep(0.5)
         self.web_view.content_not_found_dialog()
Example #55
0
 def build(self):
     global sm, CLASS
     if platform == 'android':
         if sys.platform != "win32":
             from android import AndroidService
             service = AndroidService('Vertretungsplan wird kontrolliert', 'Keine Benachrichtigung, Wenn Meldung weg ist.')
             service.start('service started')
             self.service = service
     if os.path.isfile("/sdcard/.schollgymde/licac"):
         if os.path.isfile("/sdcard/.schollgymde/sets"):
             clf = open( "/sdcard/.schollgymde/sets","r")
             CLASS = clf.read()
             clf.close()
             sleep(1,goto_start)
         else:
             sm.add_widget(settingss)
             sm.current = "settings"
     else:
         sm.add_widget(licscreen)
         sleep(1,acceptlic)
     return sm
Example #56
0
 def _stopAndroid(self):
     Debug().note('service._stopAndroid()')
     if (platform == 'android') and (self.getFormerState() == STATE_CONNECTEDREMOTE):
         from android import AndroidService
         self._androidService = AndroidService('SigmaWeb+', 'Monitorando')
     
     if (self._androidService != None):
         Debug().note('service._stopAndroid(): Esperando o _androidTriggerEnd') 
         self._androidTriggerEnd = True
         if currentThread().name == 'service._restart()':
             while self._androidTriggerEnd: sleep(0.1)
         else:
             self._startAndroid()
Example #57
0
class ServiceTestApp(App):
    def start_service(self):
        self.service = AndroidService('Sevice example', 'service is running')
        self.service.start('Hello From Service')

    def stop_service(self):
        self.service.stop()

    def on_start(self, *l):
        Logger.info('start')
        self.start_service()
        pass

    def on_stop(self, *l):
        Logger.info('stop')
        self.stop_service()

    def on_pause(self):
        return True

    def on_resume(self):
        pass
Example #58
0
 def schedule_reload_content(self):
     if self.server_is_running:
         time.sleep(2)
         self.stop_server()
     if JavaHandler.movingFile():
         self.setup_environment()
         self.start_server('threads=18')
         return 'Loading finished'
     else:
         if self.server_is_running:
             from android import AndroidService
             AndroidService().stop()
         time.sleep(0.5)
         self.web_view.content_not_found_dialog()
Example #59
0
class PhotoRiverApp(App):
    flashair_uri = ""
    folder = ""
    album_name = ""

    def on_start(self):
        self.service = AndroidService()

    def start_service(self):
        service_args = dict(
            flashair_uri=self.flashair_uri,
            folder=self.folder,
            album_name=self.album_name,
        )
        self.service.start(json.dumps(service_args))

    def stop_service(self):
        self.service.stop()

    def on_pause(self):
        return True

    def on_resume(self):
        return True
Example #60
0
 def _startAndroid(self):
     if self._androidTrigger:
         Debug().note('service._startAndroid(): Iniciando o service no Android')
         from android import AndroidService
         self._androidService = AndroidService('SigmaWeb+', 'Monitorando') 
         self._androidService.start()
         self._androidTrigger = False
     
     if self._androidTriggerEnd:
         Debug().note('service._startAndroid(): Finalizando o service no Android')
         if self._androidService is not None:
             self._androidService.stop()
         else:
             Debug().warn('service._startAndroid(): Service nao pode ser finalizado. Nao esta aberto')
         self._androidService = None
         self._androidTriggerEnd = False