コード例 #1
0
ファイル: achievements.py プロジェクト: endlessm/clubhouse
    def add_points(self, skillset, points, record_points=False):
        skillset = skillset.upper()

        if skillset not in self._points_per_skillset:
            logger.warning(
                'Not adding points to skillset %s, no achievements requiring it.',
                skillset)
            return

        previous_points = self._points_per_skillset.copy()
        self._points_per_skillset[skillset] += points
        if record_points:
            self._record_points(skillset, points)

        logger.info('Skillset %s incremented by %r, now at %r', skillset,
                    points, self._points_per_skillset[skillset])

        for achievement in self._achievements.values():
            if skillset not in achievement.points_needed_per_skillset:
                # Filter the achievements that won't get achieved by
                # this skillset.
                continue

            if not self.achieved(
                    achievement,
                    previous_points) and self.achieved(achievement):
                self.emit('achievement-achieved', achievement)
                if record_points:
                    self._record_achievement(skillset, achievement)
コード例 #2
0
ファイル: system.py プロジェクト: endlessm/clubhouse
        def _on_shell_proxy_ready(proxy, result):
            try:
                klass._shell_proxy = proxy.new_finish(result)
            except GLib.Error as e:
                logger.warning("Error: Failed to get Shell proxy:", e.message)
                return

            callback(klass._shell_proxy, *callback_args)
コード例 #3
0
ファイル: system.py プロジェクト: endlessm/clubhouse
 def get_hack_property(klass, prop_name):
     try:
         return klass._get_hack_properties_proxy().Get(
             '(ss)', klass._HACK_DBUS, prop_name)
     except GLib.Error:
         logger.warning(f"Failed to get '{prop_name}' property"
                        " from  %s", klass._HACK_DBUS)
         return None
コード例 #4
0
ファイル: system.py プロジェクト: endlessm/clubhouse
 def get_shell_property(klass, prop_name):
     try:
         return klass._get_shell_properties_proxy().Get(
             '(ss)', 'org.gnome.Shell', prop_name)
     except GLib.Error:
         logger.warning(
             f"Failed to get '{prop_name}' property from  org.gnome.Shell")
         return None
コード例 #5
0
 def _sprite_file_read_async_cb(self, file, result, sprite_path, scale,
                                metadata):
     try:
         stream = file.read_finish(result)
         GdkPixbuf.Pixbuf.new_from_stream_async(
             stream, None, self._sprite_pixbuf_read_async_cb, sprite_path,
             scale, metadata)
     except GLib.Error:
         logger.warning("Error: Failed to read file:", sprite_path)
コード例 #6
0
ファイル: system.py プロジェクト: endlessm/clubhouse
 def _get_shell_schema(klass):
     schema_source = Gio.SettingsSchemaSource.get_default()
     if klass._shell_schema is None:
         klass._shell_schema = schema_source.lookup(
             klass.SHELL_SETTINGS_SCHEMA_ID, False)
     if klass._shell_schema is None:
         logger.warning('Schema \'%s\' not found.',
                        klass.SHELL_SETTINGS_SCHEMA_ID)
     return klass._shell_schema
コード例 #7
0
ファイル: system.py プロジェクト: endlessm/clubhouse
 def get_sensitive(self):
     try:
         return self._get_properties_proxy().Get('(ss)',
                                                 self._INTERFACE_NAME,
                                                 'sensitive')
     except GLib.Error:
         logger.warning(
             "Failed to get 'sensitive' property"
             " from toolbox topic %s", self._dbus_path)
コード例 #8
0
    def reset(self):
        proxy = self.get_gtk_actions_proxy()
        if proxy.props.g_name_owner is None:
            logger.warning('Cannot call reset on Fizzics. It is not running.')
            return

        proxy.call_sync('Activate',
                        GLib.Variant('(sava{sv})', ('reset', (), {})),
                        Gio.DBusCallFlags.NO_AUTO_START, -1, None)
コード例 #9
0
ファイル: system.py プロジェクト: endlessm/clubhouse
    def remove_flatpak_override(self):
        filename = f'~/.local/share/flatpak/overrides/{self.dbus_name}'
        full_filename = os.path.expanduser(filename)

        if os.path.exists(full_filename):
            try:
                os.remove(full_filename)
            except FileNotFoundError:
                logger.warning(
                    f'Can not remove the override file {self.dbus_name}')
コード例 #10
0
    def _sprite_pixbuf_read_async_cb(self, _stream, result, sprite_path, scale,
                                     metadata):
        try:
            sprite_pixbuf = GdkPixbuf.Pixbuf.new_from_stream_finish(result)
        except GLib.Error:
            logger.warning("Error: Failed to extract pixel data from file:",
                           sprite_pixbuf)
            return

        self._pixbuf_cache[sprite_path] = sprite_pixbuf
        self._do_load(sprite_path, sprite_pixbuf, scale, metadata)
コード例 #11
0
ファイル: system.py プロジェクト: endlessm/clubhouse
    def get_os(klass):
        if klass._os_name:
            return klass._os_name, klass._os_version

        prop = klass.proxy().get_cached_property('OperatingSystemPrettyName')
        if not prop:
            logger.warning(
                'Can not get the OperatingSystemPrettyName property')
            return 'unknown', ''

        os_name = prop.unpack()

        if ' ' in os_name:
            klass._os_name, klass._os_version = os_name.split(' ', 1)

        return klass._os_name, klass._os_version
コード例 #12
0
    def load(self, subpath, prefix=None, scale=1, name=None):
        if self._loading:
            logger.warning(
                'Cannot load animations for the subpath: \'%s\'. Already loading.',
                subpath)
            return
        self._loading = True
        self._animation_after_load = None
        self._animations = {}

        for sprites_path in get_character_animation_dirs(subpath):
            # If animation name is specified then only load that one
            if name is not None:
                sprite_path = os.path.join(sprites_path, name + '.json')
                if os.path.exists(sprite_path):
                    self._do_load_animation(sprite_path, prefix, scale)
            else:
                # Load All the animations for this path/character
                for sprite in glob.glob(os.path.join(sprites_path, '*json')):
                    self._do_load_animation(sprite, prefix, scale)