• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python settings.get_option函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xl.settings.get_option函数的典型用法代码示例。如果您正苦于以下问题:Python get_option函数的具体用法?Python get_option怎么用?Python get_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了get_option函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: check_login

    def check_login(self):
        """
            Tries to connect to the AudioScrobbler
            service with the existing login data
        """
        username = settings.get_option('plugin/ascrobbler/user', '')
        password = settings.get_option('plugin/ascrobbler/password', '')
        url = settings.get_option(
            'plugin/ascrobbler/url', 'http://post.audioscrobbler.com/'
        )
        login_verified = False

        try:
            _scrobbler.login(username, password, post_url=url)
        except _scrobbler.AuthError:
            try:
                _scrobbler.login(username, password, hashpw=True, post_url=url)
            except _scrobbler.AuthError:
                pass
            else:
                login_verified = True
        else:
            login_verified = True

        if login_verified:
            GLib.idle_add(self.message.show_info, _('Verification successful'), '')
        else:
            GLib.idle_add(
                self.message.show_error,
                _('Verification failed'),
                _('Please make sure the entered data is correct.'),
            )

        GLib.idle_add(self.widget.set_sensitive, True)
开发者ID:exaile,项目名称:exaile,代码行数:34,代码来源:asprefs.py


示例2: __autoconfig

def __autoconfig():
    '''
        If the user hasn't used our plugin before, then try to
        autoconfig their audio settings to use a different audio
        device if possible.. 
        
        TODO: It would be cool if we could notify the user that
        a new device was plugged in...
    '''
    
    from xl import settings

    if settings.get_option('preview_device/audiosink', None) is not None:
        return
        
    sink = settings.get_option('player/audiosink', None)    
    if sink is None:
        return
        
    settings.set_option( 'preview_device/audiosink', sink )
    
    main_device = settings.get_option('player/audiosink_device', None)
    if main_device is None:
        return
    
    from xl.player import pipe
    devices = pipe.sink_enumerate_devices(sink)
    if devices is not None:
        # pick the first one that isn't the main device and isn't 'Auto'
        # -> if the main device is '', then it's auto. So... we actually
        # iterate backwards, assuming that the ordering matters
        for device,name in reversed(devices):
            if device != main_device and name != _('Auto'):
                settings.set_option( 'preview_device/audiosink_device', device )
                break
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:35,代码来源:previewprefs.py


示例3: setup_network

    def setup_network(self):
        """
            Tries to set up the network, retrieve the user
            and the initial list of loved tracks
        """
        try:
            self.network = pylast.LastFMNetwork(
                api_key=settings.get_option('plugin/lastfmlove/api_key', 'K'),
                api_secret=settings.get_option('plugin/lastfmlove/api_secret', 'S'),
                username=settings.get_option('plugin/ascrobbler/user', ''),
                password_hash=settings.get_option('plugin/ascrobbler/password', ''),
            )
            self.user = self.network.get_user(self.network.username)
        except Exception as e:
            self.network = None
            self.user = None

            if self.timer is not None and self.timer.is_alive():
                self.timer.cancel()

            logger.warning('Error while connecting to Last.fm network: {0}'.format(e))
        else:
            thread = Thread(target=self.get_loved_tracks)
            thread.daemon = True
            thread.start()

            logger.info('Connection to Last.fm network successful')
开发者ID:exaile,项目名称:exaile,代码行数:27,代码来源:__init__.py


示例4: on_gui_loaded

    def on_gui_loaded(self):
        save_on_exit = settings.get_option(
            'plugin/history/save_on_exit', history_preferences.save_on_exit_default
        )
        shown = settings.get_option('plugin/history/shown', False)

        # immutable playlist that stores everything we've played
        self.history_loc = os.path.join(xdg.get_data_dir(), 'history')

        self.history_playlist = HistoryPlaylist(player.PLAYER)

        if save_on_exit:
            self.history_playlist.load_from_location(self.history_loc)

        self.history_page = HistoryPlaylistPage(self.history_playlist, player.PLAYER)
        self.history_tab = NotebookTab(main.get_playlist_notebook(), self.history_page)

        # add menu item to 'view' to display our playlist
        self.menu = menu.check_menu_item(
            'history',
            '',
            _('Playback history'),
            lambda *e: self.is_shown(),
            self.on_playback_history,
        )

        providers.register('menubar-view-menu', self.menu)

        # add the history playlist to the primary notebook
        if save_on_exit and shown:
            self.show_history(True)
开发者ID:exaile,项目名称:exaile,代码行数:31,代码来源:__init__.py


示例5: _on_option_set

    def _on_option_set(self, name, object, option):
        """
           Handles changes of settings
        """
        if option == "gui/main_window_title_format":
            self.title_formatter.props.format = settings.get_option(option, self.title_formatter.props.format)

        if option == "gui/use_tray":
            usetray = settings.get_option(option, False)
            if self.controller.tray_icon and not usetray:
                glib.idle_add(self.controller.tray_icon.destroy)
                self.controller.tray_icon = None
            elif not self.controller.tray_icon and usetray:
                self.controller.tray_icon = tray.TrayIcon(self)

        if option == "gui/show_info_area":
            glib.idle_add(self.info_area.set_no_show_all, False)
            if settings.get_option(option, True):
                glib.idle_add(self.info_area.show_all)
            else:
                glib.idle_add(self.info_area.hide_all)
            glib.idle_add(self.info_area.set_no_show_all, True)

        if option == "gui/show_info_area_covers":

            def _setup_info_covers():
                cover = self.info_area.cover
                cover.set_no_show_all(False)
                if settings.get_option(option, True):
                    cover.show_all()
                else:
                    cover.hide_all()
                cover.set_no_show_all(True)

            glib.idle_add(_setup_info_covers)
开发者ID:thiblahute,项目名称:exaile,代码行数:35,代码来源:main.py


示例6: find_covers

    def find_covers(self, track, limit=-1):
        """
            Searches amazon for album covers
        """
        try:
            artist = track.get_tag_raw('artist')[0]
            album = track.get_tag_raw('album')[0]
        except (AttributeError, TypeError):
            return []

        # get the settings for amazon key and secret key
        api_key = settings.get_option('plugin/amazoncovers/api_key', '')
        secret_key = settings.get_option('plugin/amazoncovers/secret_key', '')
        if not api_key or not secret_key:
            logger.warning(
                'Please enter your Amazon API and secret '
                'keys in the Amazon Covers preferences'
            )
            return []

        # wait at least 1 second until the next attempt
        waittime = 1 - (time.time() - self.starttime)
        if waittime > 0:
            time.sleep(waittime)
        self.starttime = time.time()

        search = "%s - %s" % (artist, album)
        try:
            albums = ecs.search_covers(search, api_key, secret_key, USER_AGENT)
        except ecs.AmazonSearchError:
            return []
        return albums
开发者ID:exaile,项目名称:exaile,代码行数:32,代码来源:__init__.py


示例7: set_cover_from_track

    def set_cover_from_track(self, track):
        """
            Updates the cover image and triggers cross-fading
        """
        cover_data = covers.MANAGER.get_cover(track, set_only=True)

        if cover_data is None:
            self.hide()
            return

        if not self.props.visible:
            self.show()

        size = settings.get_option('plugin/desktopcover/size', 200)
        upscale = settings.get_option('plugin/desktopcover/override_size', False)
        pixbuf = self.image.get_pixbuf()
        next_pixbuf = icons.MANAGER.pixbuf_from_data(
            cover_data, size=(size, size), upscale=upscale)
        fading = settings.get_option('plugin/desktopcover/fading', False)

        if fading and pixbuf is not None and self._cross_fade_id is None:
            # Prescale to allow for proper crossfading
            width, height = next_pixbuf.get_width(), next_pixbuf.get_height()
            pixbuf = pixbuf.scale_simple(width, height, gtk.gdk.INTERP_BILINEAR)
            glib.idle_add(self.image.set_from_pixbuf, pixbuf)

            duration = settings.get_option(
                'plugin/desktopcover/fading_duration', 50)

            self._cross_fade_id = glib.timeout_add(int(duration),
                self.cross_fade, pixbuf, next_pixbuf, duration)
        else:
            glib.idle_add(self.image.set_from_pixbuf, next_pixbuf)
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:33,代码来源:__init__.py


示例8: __init__

    def __init__(self, location):
        """
            :param location: The directory to load and store data in.
        """
        providers.ProviderHandler.__init__(self, "covers")
        self.__cache = Cacher(os.path.join(location, 'cache'))
        self.location = location
        self.methods = {}
        self.order = settings.get_option(
                'covers/preferred_order', [])
        self.db = {}
        self.load()
        for method in self.get_providers():
            self.on_provider_added(method)

        default_cover_file = open(xdg.get_data_path('images', 'nocover.png'), 'rb')
        self.default_cover_data = default_cover_file.read()
        default_cover_file.close()

        self.tag_fetcher = TagCoverFetcher()
        self.localfile_fetcher = LocalFileCoverFetcher()

        if settings.get_option('covers/use_tags', True):
            providers.register('covers', self.tag_fetcher)
        if settings.get_option('covers/use_localfile', True):
            providers.register('covers', self.localfile_fetcher)

        event.add_callback(self._on_option_set, 'covers_option_set')
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:28,代码来源:covers.py


示例9: _on_option_set

    def _on_option_set(self, name, object, option):
        """
           Handles changes of settings
        """
        if option == 'gui/main_window_title_format':
            self.title_formatter.props.format = settings.get_option(
                option, self.title_formatter.props.format)

        elif option == 'gui/use_tray':
            usetray = settings.get_option(option, False)
            if self.controller.tray_icon and not usetray:
                self.controller.tray_icon.destroy()
                self.controller.tray_icon = None
            elif not self.controller.tray_icon and usetray:
                self.controller.tray_icon = tray.TrayIcon(self)
    
        elif option == 'gui/show_info_area':
            self.info_area.set_no_show_all(False)
            if settings.get_option(option, True):
                self.info_area.show_all()
            else:
                self.info_area.hide()
            self.info_area.set_no_show_all(True)
            
        elif option == 'gui/show_info_area_covers':
            cover = self.info_area.cover
            cover.set_no_show_all(False)
            if settings.get_option(option, True):
                cover.show_all()
            else:
                cover.hide()
            cover.set_no_show_all(True)
            
        elif option == 'gui/transparency':
            self._update_alpha()
开发者ID:learnstation,项目名称:exaile,代码行数:35,代码来源:main.py


示例10: do_init

    def do_init(self, captcha_id=None, captcha_solution=None):
        username = settings.get_option("plugin/douban_radio/username")
        password = settings.get_option("plugin/douban_radio/password")
        try:
            self.doubanfm = DoubanFM(username, password, captcha_id, captcha_solution)
        except DoubanLoginException as e:
            if e.data['captcha_id'] is None:
                self.exaile.gui.main.message.show_error(
                    _('Douban FM Error'),
                    _('Failed to login to douban.fm with your credential'))
                return
            else:
                captcha_id = e.data['captcha_id']
                self.show_captcha_dialog(captcha_id)
                return

        self.channels = self.doubanfm.channels

        self.__create_menu_item__()

        self.check_to_enable_dbus()

        self.__register_events()

        self.doubanfm_cover = DoubanFMCover()
        providers.register('covers', self.doubanfm_cover)

        self.doubanfm_mode = DoubanFMMode(self.exaile, self)
开发者ID:lovesnow,项目名称:exaile-doubanfm-plugin,代码行数:28,代码来源:__init__.py


示例11: _on_option_set

 def _on_option_set(self, evtype, settings, option):
     if option == self.__opt_remove_item_when_played:
         self.__remove_item_on_playback = settings.get_option(option, True)
         if len(self):
             self.__queue_has_tracks = True
     elif option == self.__opt_disable_new_track_when_playing:
         self.__disable_new_track_when_playing = settings.get_option(option, False)
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:7,代码来源:queue.py


示例12: _restore_player_state

    def _restore_player_state(self, location):
        if not settings.get_option("%s/resume_playback" % self.player._name, True):
            return

        try:
            f = open(location, 'rb')
            state = pickle.load(f)
            f.close()
        except:
            return

        for req in ['state', 'position', '_playtime_stamp']:
            if req not in state:
                return

        if state['state'] in ['playing', 'paused']:
            event.log_event("playback_player_resume", self.player, None)
            vol = self.player._get_volume()
            self.player._set_volume(0)
            self.play(self.get_current())

            if self.player.current:
                self.player.seek(state['position'])
                if state['state'] == 'paused' or \
                        settings.get_option("%s/resume_paused" % self.player._name, False):
                    self.player.toggle_pause()
                self.player._playtime_stamp = state['_playtime_stamp']

            self.player._set_volume(vol)
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:29,代码来源:queue.py


示例13: _on_option_set

 def _on_option_set(self, name, object, data):
     if data == "replaygain/album-mode":
         self.rgvol.set_property("album-mode", settings.get_option("replaygain/album-mode", True))
     elif data == "replaygain/pre-amp":
         self.rgvol.set_property("pre-amp", settings.get_option("replaygain/pre-amp", 0))
     elif data == "replaygain/fallback-gain":
         self.rgvol.set_property("fallback-gain", settings.get_option("replaygain/fallback-gain", 0))
开发者ID:dangmai,项目名称:exaile,代码行数:7,代码来源:__init__.py


示例14: update_position

    def update_position(self):
        """
            Updates the position based
            on gravity and offsets
        """
        gravity = self.gravity_map[settings.get_option(
            'plugin/desktopcover/anchor', 'topleft')]
        cover_offset_x = settings.get_option('plugin/desktopcover/x', 0)
        cover_offset_y = settings.get_option('plugin/desktopcover/y', 0)
        allocation = self.get_allocation()
        workarea = get_workarea_dimensions()
        x, y = workarea.offset_x, workarea.offset_y

        if gravity in (gtk.gdk.GRAVITY_NORTH_WEST, gtk.gdk.GRAVITY_SOUTH_WEST):
            x += cover_offset_x
        else:
            x += workarea.width - allocation.width - cover_offset_x

        if gravity in (gtk.gdk.GRAVITY_NORTH_WEST, gtk.gdk.GRAVITY_NORTH_EAST):
            y += cover_offset_y
        else:
            y += workarea.height - allocation.height - cover_offset_y

        self.set_gravity(gravity)
        self.move(int(x), int(y))
开发者ID:eri-trabiccolo,项目名称:exaile,代码行数:25,代码来源:__init__.py


示例15: sink_from_preset

def sink_from_preset(player, preset):
    if preset == "custom":
        pipe = settings.get_option("%s/custom_sink_pipe" % player._name, "")
        if not pipe:
            logger.error("No custom sink pipe set for %s" % player._name)
            return None
        name = _("Custom")
    else:
        d = SINK_PRESETS.get(preset, "")
        if not d:
            logger.error("Could not find sink preset %s for %s." % (preset, player._name))
            return None

        name = d['name']
        pipe = d['pipe']
        if preset != 'auto':
            dname = settings.get_option('%s/audiosink_device' % player._name)
            if dname:
                pipe += ' device=' + dname
        if 'pipeargs' in d:
            pipe += ' ' + d['pipeargs']

    try:
        sink = AudioSink(name, pipe, player)
    except Exception:
        common.log_exception(log=logger,
                message="Could not enable audiosink %s for %s." % (preset, player._name))
        return None
    return sink
开发者ID:thiblahute,项目名称:exaile,代码行数:29,代码来源:pipe.py


示例16: create_device

def create_device(player_name, return_errorsink=True):
    '''
        Creates an audiosink based on the current settings. This will always
        return an audiosink, but sometimes it will return an audiosink that
        only sends error messages to the bus.
        
        ..note:: Only attempts to autoselect if the user has never specified a 
                 setting manually. Otherwise, they may be confused when it
                 switches to a new output. For example, if they specified a USB
                 device, and it is removed -- when restarting the program, they
                 would not expect to automatically start playing on the builtin
                 sound.
    '''
    
    sink_type = settings.get_option('%s/audiosink' % player_name, 'auto')
    name = '%s-audiosink' % player_name
    sink = None
    errmsg = None
    
    if sink_type == 'auto':
        
        specified_device = settings.get_option('%s/audiosink_device' % player_name, 'auto')
        
        for _unused, device_id, create in get_devices():
            if specified_device == device_id:
                sink = create(name)
                break
        
        if sink is None:
            errmsg = _("Could not create audiosink (device: %s, type: %s)")
            errmsg = errmsg % (specified_device, sink_type)
    
    elif sink_type == 'custom':
        
        pipeline = settings.get_option("%s/custom_sink_pipe" % player_name, "")
        if not pipeline:
            errmsg = _("No custom pipeline specified!")
        else:
            try:
                sink = CustomAudioSink(pipeline, name)
            except:
                errmsg = _("Error creating custom audiosink '%s'") % pipeline
                logger.exception(errmsg)
    
    else:
        preset = SINK_PRESETS.get(sink_type, None)
        if preset is None:
            errmsg = _("Invalid sink type '%s' specified") % sink_type
        else:
            sink = Gst.ElementFactory.make(preset['pipe'], name)
            if sink is None:
                errmsg = _("Could not create sink type '%s'") % preset['pipe']
    
    if errmsg is not None:
        logger.error(errmsg)
        if return_errorsink:
            sink = _get_error_audiosink(errmsg)
           
    return sink
开发者ID:BlubberHarpoonist,项目名称:exaile,代码行数:59,代码来源:sink.py


示例17: _setup_position

    def _setup_position(self):
        width = settings.get_option('gui/trackprop_width', 600)
        height = settings.get_option('gui/trackprop_height', 350)
        x = settings.get_option('gui/trackprop_x', 100)
        y = settings.get_option('gui/trackprop_y', 100)

        self.dialog.move(x, y)
        self.dialog.resize(width, height)
开发者ID:exaile,项目名称:exaile,代码行数:8,代码来源:properties.py


示例18: window_state_change_event

    def window_state_change_event(self, window, event):
        """
            Saves the current maximized and fullscreen
            states and minimizes to tray if requested
        """
        if event.changed_mask & gtk.gdk.WINDOW_STATE_MAXIMIZED:
            settings.set_option("gui/mainw_maximized", bool(event.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED))
        if event.changed_mask & gtk.gdk.WINDOW_STATE_FULLSCREEN:
            self._fullscreen = bool(event.new_window_state & gtk.gdk.WINDOW_STATE_FULLSCREEN)

        # detect minimization state changes
        prev_minimized = self.minimized

        if not self.minimized:

            if (
                event.changed_mask & gtk.gdk.WINDOW_STATE_ICONIFIED
                and not event.changed_mask & gtk.gdk.WINDOW_STATE_WITHDRAWN
                and event.new_window_state & gtk.gdk.WINDOW_STATE_ICONIFIED
                and not event.new_window_state & gtk.gdk.WINDOW_STATE_WITHDRAWN
                and not self.window_state & gtk.gdk.WINDOW_STATE_ICONIFIED
            ):

                self.minimized = True
        else:
            if event.changed_mask & gtk.gdk.WINDOW_STATE_WITHDRAWN and not event.new_window_state & (
                gtk.gdk.WINDOW_STATE_WITHDRAWN
            ):  # and \

                self.minimized = False

        # track this
        self.window_state = event.new_window_state

        if settings.get_option("gui/minimize_to_tray", False):

            # old code to detect minimization
            # -> it must have worked at some point, perhaps this is a GTK version
            # specific set of behaviors? Current code works now on 2.24.17

            # if wm_state is not None:
            #    if '_NET_WM_STATE_HIDDEN' in wm_state[2]:
            #        show tray
            #        window.hide
            # else
            #    destroy tray

            if self.minimized != prev_minimized and self.minimized == True:
                if not settings.get_option("gui/use_tray", False) and self.controller.tray_icon is None:
                    self.controller.tray_icon = tray.TrayIcon(self)

                window.hide()
            elif window.window.property_get("_NET_WM_STATE") is None:
                if not settings.get_option("gui/use_tray", False) and self.controller.tray_icon is not None:
                    self.controller.tray_icon.destroy()
                    self.controller.tray_icon = None

        return False
开发者ID:thiblahute,项目名称:exaile,代码行数:58,代码来源:main.py


示例19: migrate

def migrate():
    """
        Enables the OSD plugin if the builtin OSD was originally enabled
    """
    plugins = settings.get_option('plugins/enabled', [])

    if settings.get_option('osd/enabled', False) and 'osd' not in plugins:
        settings.set_option('plugins/enabled', plugins + ['osd'])

    settings.set_option('osd/enabled', False)
开发者ID:exaile,项目名称:exaile,代码行数:10,代码来源:osd.py


示例20: check_default_settings

    def check_default_settings():
        for band in range(10):
            if settings.get_option("plugin/equalizer/band%s" % band) is None:
                settings.set_option("plugin/equalizer/band%s" % band, 0.0)

        if settings.get_option("plugin/equalizer/pre") is None:
            settings.set_option("plugin/equalizer/pre", 0.0)

        if settings.get_option("plugin/equalizer/enabled") is None:
            settings.set_option("plugin/equalizer/enabled", True)
开发者ID:exaile,项目名称:exaile,代码行数:10,代码来源:__init__.py



注:本文中的xl.settings.get_option函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python settings.set_option函数代码示例发布时间:2022-05-26
下一篇:
Python providers.unregister函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap