def on_added(self):
        s = PkgInstaller()

        def execute_conn_commands():
            execute = True

            # Obtain sudo permission if needed.
            for command in self.__conn_commands__:
                if command.strip().startswith('sudo'):
                    if not get_sudo():
                        execute = False
                    break

            if execute:
                for command in self.__conn_commands__:
                    os.system(command)

        def install_packages():
            s.install(self.__packages__)
            execute_conn_commands()

        if s.check(self.__packages__):
            if self.__conn_commands__:
                actions = {self.__device_use_title__: execute_conn_commands}
            else:
                actions = {}
        else:
            actions = {_("Install required packages"): install_packages}

        self.msg_render.show(self.__device_title__, 
                self.__device_conn_description__,
             self.__icon_path__, actions = actions)
示例#2
0
    def on_added(self):
        s = PkgInstaller()

        def execute_conn_commands():
            execute = True

            # Obtain sudo permission if needed.
            for command in self.__conn_commands__:
                if command.strip().startswith('sudo'):
                    if not get_sudo():
                        execute = False
                    break

            if execute:
                for command in self.__conn_commands__:
                    os.system(command)

        def install_packages():
            s.install(self.__packages__)
            execute_conn_commands()

        if s.check(self.__packages__):
            if self.__conn_commands__:
                actions = {_("Use device"): execute_conn_commands}
            else:
                actions = {}
        else:
            actions = {_("Install required packages"): install_packages}

        self.msg_render.show(self.__device_title__,
                             self.__device_conn_description__,
                             self.__icon_path__,
                             actions=actions)
 def _install_packages(self):
     """ 
     [es] Instala todos los paquetes en __packages__
     -----------------------------------------------------------------------
     [en] Installs all the packages in __packages__
     """
     s = PkgInstaller()
     s.install(self.__packages__)
示例#4
0
 def _install_packages(self):
     """ 
     [es] Instala todos los paquetes en __packages__
     -----------------------------------------------------------------------
     [en] Installs all the packages in __packages__
     """
     s = PkgInstaller()
     s.install(self.__packages__)
示例#5
0
    def on_added(self):
        """
        [es] Se lanza cuando se detecta la conexion de un dispositivo que
             que requiere algun software instalado.
        -----------------------------------------------------------------------
        [en] Runs when a device that needs some software installation is 
             detected.
        """
        s = PkgInstaller()

        def execute_conn_commands():
            """ 
            [es] Ejecuta los comandos necesarios para conectar el dispositivo
            -------------------------------------------------------------------
            [en] Runs the needed commands when the device is connected
            """
            execute = True

            # [es] Obtiene permisos mediante sudo si es necesario instalar algo
            # [en] Obtain sudo permission if needed to install something
            for command in self.__conn_commands__:
                if command.strip().startswith('sudo'):
                    if not get_sudo():
                        execute = False
                    break

            if execute:
                for command in self.__conn_commands__:
                    os.system(command)

        def install_packages():
            """ 
            [es] Ejecuta la instalacion de los paquetes en __packages__
            -------------------------------------------------------------------
            [en] Installs packages from __packages__
            """
            s.install(self.__packages__)
            execute_conn_commands()

        if s.check(self.__packages__):
            if self.__conn_commands__:
                actions = {self.__device_use_title__: execute_conn_commands}
            else:
                actions = {}
        else:
            actions = {_("Install required packages"): install_packages}

        self.msg_render.show(self.__device_title__,
                             self.__device_conn_description__,
                             self.__icon_path__,
                             actions=actions)
    def on_added(self):
        """
        [es] Se lanza cuando se detecta la conexion de un dispositivo que
             que requiere algun software instalado.
        -----------------------------------------------------------------------
        [en] Runs when a device that needs some software installation is 
             detected.
        """
        s = PkgInstaller()

        def execute_conn_commands():
            """ 
            [es] Ejecuta los comandos necesarios para conectar el dispositivo
            -------------------------------------------------------------------
            [en] Runs the needed commands when the device is connected
            """
            execute = True

            # [es] Obtiene permisos mediante sudo si es necesario instalar algo
            # [en] Obtain sudo permission if needed to install something
            for command in self.__conn_commands__:
                if command.strip().startswith('sudo'):
                    if not get_sudo():
                        execute = False
                    break

            if execute:
                for command in self.__conn_commands__:
                    os.system(command)

        def install_packages():
            """ 
            [es] Ejecuta la instalacion de los paquetes en __packages__
            -------------------------------------------------------------------
            [en] Installs packages from __packages__
            """
            s.install(self.__packages__)
            execute_conn_commands()

        if s.check(self.__packages__):
            if self.__conn_commands__:
                actions = {self.__device_use_title__: execute_conn_commands}
            else:
                actions = {}
        else:
            actions = {_("Install required packages"): install_packages}

        self.msg_render.show(self.__device_title__, 
                self.__device_conn_description__,
             self.__icon_path__, actions = actions)
    def hack_on_added(self, usb_actor):
        "usbdevice.Actor.on_added hack"
        assert isinstance(usb_actor, Actor)

        def run_xsane():
            os.system("xsane & ")

        def install_packages():
            if synaptic.install(UsbScannerActorHack.PACKAGES):
                run_xsane()

        synaptic = PkgInstaller()

        actions = {}
        if synaptic.check(UsbScannerActorHack.PACKAGES):
            actions = {_("Run rendering program"): run_xsane}
        else:
            actions = {_("Install required packages"): install_packages}

        usb_actor.msg_render.show(_("SCANNER"), _("Scanner device connected"), SCANNERICON, actions=actions)
示例#8
0
    def hack_on_added(self, usb_actor):
        "usbdevice.Actor.on_added hack"
        assert (isinstance(usb_actor, Actor))

        def run_xsane():
            os.system('xsane & ')

        def install_packages():
            if synaptic.install(UsbScannerActorHack.PACKAGES):
                run_xsane()

        synaptic = PkgInstaller()

        actions = {}
        if synaptic.check(UsbScannerActorHack.PACKAGES):
            actions = {_("Run rendering program"): run_xsane}
        else:
            actions = {_("Install required packages"): install_packages}

        usb_actor.msg_render.show(_("SCANNER"),
                                  _("Scanner device connected"),
                                  SCANNERICON,
                                  actions=actions)
 def _install_packages(self):
     s = PkgInstaller()
     s.install(self.__packages__)
示例#10
0
 def _install_packages(self):
     s = PkgInstaller()
     s.install(self.__packages__)