Beispiel #1
0
    def mark_completed(self):
        """
            Mark a fulfilled quest complete to claim the reward.
            This will set the state of the quest to COMPLETED in the quest
            store.
            :raises QuestError: If the quest isn't ready to be marked complete.
        """

        if self.is_completed():
            return

        if self.is_fulfilled():
            self._state = self.COMPLETED
            self._save_state()

            run_cmd('kdesk -a profile')

            for reward in self._rewards:
                n = reward.notification
                if n:
                    display_generic_notification(
                        n['title'],
                        n['byline'],
                        n['image'],
                        n['command']
                    )
        else:
            raise QuestError('Quest not ready to be completed.')
Beispiel #2
0
    def is_fulfilled(self):
        """
            Evaluate whether all the steps required to complete the quest
            were fulfulled. If yes, the status of the quest is changed
            to FULFILLED and saved into the quest store.

            :returns: True if fulfilled.
            :rtype: Boolean
        """

        if self._state in [self.FULFILLED, self.COMPLETED]:
            return True

        fulfilled = True
        for step in self._steps:
            fulfilled = fulfilled and step.is_fulfilled()

        if fulfilled:
            self._state = self.FULFILLED
            self._save_state()

            display_generic_notification(
                'Quest complete!',
                'Click here to claim your rewards.',
                profile_media('images/quests/quest-complete-notification.png'),
                'kano-profile-gui quests'
            )
        return fulfilled
Beispiel #3
0
    def is_fulfilled(self):
        """
            Evaluate whether all the steps required to complete the quest
            were fulfulled. If yes, the status of the quest is changed
            to FULFILLED and saved into the quest store.

            :returns: True if fulfilled.
            :rtype: Boolean
        """

        if self._state in [self.FULFILLED, self.COMPLETED]:
            return True

        fulfilled = True
        for step in self._steps:
            fulfilled = fulfilled and step.is_fulfilled()

        if fulfilled:
            self._state = self.FULFILLED
            self._save_state()

            display_generic_notification(
                _("Quest complete!"), _("Click here to claim your rewards."),
                profile_media('images/quests/quest-complete-notification.png'),
                'kano-profile-gui quests')
        return fulfilled
    def _update_countdown(time_remaining, create=False):
        '''
        Provides an update on the shutdown timer via a notification
        '''

        shutdown_title = 'Kit is shutting down!'
        shutdown_msg = 'Your kit will shutdown in {sec} seconds'

        if create:
            close_current_notification()
            display_generic_notification(
                shutdown_title,
                shutdown_msg.format(sec=time_remaining),
                image=ERROR_NOTIF_IMAGE,
                sound=ERROR_NOTIF_SOUND,
                urgency='critical')
        else:
            update_current_notification(desc=shutdown_msg.format(
                sec=time_remaining))
    def create_notif(self):
        '''
        Triggers a notification to be opened or removed based on the battery
        state

        NB: Must be called from the main thread as the notification has a
            timeout which fails if called from a threading.Thread or
            multiprocessing.Process, as such, it should be `idle_add`ed from
            `Thread`s and requires a more complicated procedure from
            `Process`es.
        '''

        if self._is_battery_low():
            if self._notif_open.is_set():
                return

            # Track low battery detected
            generate_event('low-battery')

            display_generic_notification(
                'Plug In Your Kit!',
                'Your kit has a low battery and will turn off soon!',
                image=ERROR_NOTIF_IMAGE,
                sound=ERROR_NOTIF_SOUND,
                urgency='critical')

            if self._shutdown_enabled.value:
                # Lazy import to avoid issue of importing from this module externally.
                from gi.repository import GLib

                GLib.timeout_add_seconds(SHUTDOWN_WARN_TIME,
                                         self._low_power_shutdown)

            self._notif_open.set()
        else:
            close_current_notification()
            self._notif_open.clear()
Beispiel #6
0
    def mark_completed(self):
        """
            Mark a fulfilled quest complete to claim the reward.
            This will set the state of the quest to COMPLETED in the quest
            store.
            :raises QuestError: If the quest isn't ready to be marked complete.
        """

        if self.is_completed():
            return

        if self.is_fulfilled():
            self._state = self.COMPLETED
            self._save_state()

            run_cmd('kdesk -a profile')

            for reward in self._rewards:
                n = reward.notification
                if n:
                    display_generic_notification(n['title'], n['byline'],
                                                 n['image'], n['command'])
        else:
            raise QuestError(_("Quest not ready to be completed."))