예제 #1
0
파일: base.py 프로젝트: rvykydal/anaconda
class MainModule(BaseModule):
    """Implementation of the main module.

    The main module is an owner of the main loop, so it is
    able to start and stop the application.
    """

    def __init__(self):
        super().__init__()
        self._loop = EventLoop()

    @property
    def loop(self):
        """Return the loop."""
        return self._loop

    def run(self):
        """Run the module's loop."""
        log.debug("Schedule publishing.")
        run_in_loop(self.publish)
        log.debug("Start the loop.")
        self._loop.run()

    def stop(self):
        """Stop the module's loop."""
        DBus.disconnect()
        Timer().timeout_sec(1, self.loop.quit)
예제 #2
0
class MainModule(BaseModule):
    """Implementation of the main module.

    The main module is an owner of the main loop, so it is
    able to start and stop the application.
    """
    def __init__(self):
        super().__init__()
        self._loop = EventLoop()

    @property
    def loop(self):
        """Return the loop."""
        return self._loop

    def run(self):
        """Run the module's loop."""
        log.debug("Schedule publishing.")
        run_in_loop(self.publish)
        log.debug("Start the loop.")
        self._loop.run()

    def stop(self):
        """Stop the module's loop."""
        DBus.disconnect()
        Timer().timeout_sec(1, self.loop.quit)
예제 #3
0
파일: base.py 프로젝트: sanjitchak/anaconda
class BaseModule(ABC):
    """Base implementation of a module."""
    def __init__(self):
        self._loop = EventLoop()

    @property
    def loop(self):
        """Return the loop."""
        return self._loop

    def run(self):
        """Run the module's loop."""
        log.debug("Schedule publishing.")
        run_in_loop(self.publish)
        log.debug("Start the loop.")
        self._loop.run()

    def publish(self):
        """Publish DBus objects and register a DBus service.

        Nothing is published by default.
        """
        pass

    def stop(self):
        """Stop the module's loop."""
        DBus.disconnect()
        Timer().timeout_sec(1, self.loop.quit)
예제 #4
0
class MainModule(BaseModule):
    """Implementation of the main module.

    The main module is an owner of the main loop, so it is
    able to start and stop the application.
    """

    def __init__(self):
        super().__init__()
        self._loop = EventLoop()

    @property
    def loop(self):
        """Return the loop."""
        return self._loop

    def run(self):
        """Run the module's loop."""
        log.debug("Publish the module.")
        self.publish()
        log.debug("Start the loop.")
        self._loop.run()

    def stop(self):
        """Stop the module's loop."""
        DBus.disconnect()
        Timer().timeout_sec(1, self.loop.quit)

    def set_locale(self, locale):
        """Set the locale for the module.

        This function modifies the process environment, which is not thread-safe.
        It should be called before any threads are run.

        We cannot get around setting $LANG. Python's gettext implementation
        differs from C in that consults only the environment for the current
        language and not the data set via setlocale. If we want translations
        from python modules to work, something needs to be set in the
        environment when the language changes.

        :param str locale: locale to set
        """
        os.environ["LANG"] = locale  # pylint: disable=environment-modify
        setlocale(LC_ALL, locale)
        # Set locale for child processes
        setenv("LANG", locale)
        log.debug("Locale is set to %s.", locale)
예제 #5
0
 def __init__(self):
     super().__init__()
     self._loop = EventLoop()
예제 #6
0
파일: base.py 프로젝트: rvykydal/anaconda
 def __init__(self):
     super().__init__()
     self._loop = EventLoop()
예제 #7
0
파일: base.py 프로젝트: sanjitchak/anaconda
 def __init__(self):
     self._loop = EventLoop()