Exemplo n.º 1
0
    class GrupoApp(App):
        def build(self):
            self.screen_manager = ScreenManager()
            import os
            if 'MANTENCIONES_VERBOSE' in os.environ:
                verbose=1
            else:
                verbose=0
            if 'DEVELOPMENT_SERVER' in os.environ:
                # domain_url='http://192.168.43.150:5000'
                domain_url='http://192.168.1.39:5000'
            else:
                domain_url='http://kheitmann.webfactional.com'
            from webserver import WebServer
            from kivy.storage.jsonstore import JsonStore
            self.ws = WebServer(domain_url, verbose)
            self.store = JsonStore('base_de_datos.json')

            if self.store.exists('session'):
                session = self.store.get('session')
                if session['auth_token'] is None:
                    print("AUTH TOKEN ES NONE")
                    return None
                else:
                    self.ws.set_auth_token(session['auth_token'])
            else:
                print("NO HAY BASE DE DATOS")
                return None

            self.screen_manager.add_widget(Grupo(name='grupo'))
            self.screen_manager.add_widget(Informe(name='informe'))

            return self.screen_manager
Exemplo n.º 2
0
class MantencionesApp(App):
    def __init__(self, **kwargs):
        super(MantencionesApp, self).__init__(**kwargs)

        Window.bind(on_keyboard=self.Android_back_click)

    def set_informe_actual(self, _informe_actual):
        self.informe_actual = _informe_actual

    def get_informe_actual(self):
        return self.informe_actual

    def build(self):
        # self.ws = WebServer("http://192.168.43.150:5000", 1)
        self.screen_manager = ScreenManager()
        if 'MANTENCIONES_VERBOSE' in os.environ:
            verbose=1
        else:
            verbose=0
        if 'DEVELOPMENT_SERVER' in os.environ:
            domain_url='http://192.168.43.150:5000'
            # domain_url='http://192.168.1.39:5000'
        else:
            domain_url='http://kheitmann.webfactional.com'
        self.ws = WebServer(domain_url, verbose)
        self.informe_actual = ""
        self.store = JsonStore('base_de_datos.json')
        if self.store.exists('session'):
            session = self.store.get('session')
            if session['auth_token'] is None:
                print("No hay login")
                self.screen_manager.add_widget(Login(name="login"))
                self.screen_manager.add_widget(Grupos(name="grupos"))
            else:
                print("Si hay login")
                self.ws.set_auth_token(session['auth_token'])
                self.screen_manager.add_widget(Grupos(name="grupos"))
                self.screen_manager.add_widget(Login(name="login"))
        else:
            print("no hay")
            self.store.put('session', auth_token=None)
            self.screen_manager.add_widget(Login(name="login"))
            self.screen_manager.add_widget(Grupos(name="grupos"))
        agregar_screens(self.screen_manager)
        return self.screen_manager

    def Android_back_click(self,window,key,*largs):
        # Codigo del boton back de android
        if key == 27:
            print("BACK!")
            # self.manager.transition = SlideTransition(direction="right")
            # self.manager.current = 'grupo'
            return True