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

Python util.print_w函数代码示例

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

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



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

示例1: load_dir_modules

def load_dir_modules(path, package, load_compiled=False):
    """Load all modules and packages in path (recursive).
    Load pyc files if load_compiled is True.
    In case the module is already loaded, doesn't reload it.
    """

    # needed for pickle etc.
    assert package in sys.modules

    try:
        modules = [e[0] for e in get_importables(path, load_compiled)]
    except OSError:
        util.print_w("%r not found" % path)
        return []

    # get_importables can yield py and pyc for the same module
    # and we want to load it only once
    modules = set(modules)

    loaded = []
    for name in modules:
        try:
            mod = load_module(name, package, path)
        except Exception:
            util.print_exc()
            continue
        if mod:
            loaded.append(mod)

    return loaded
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:30,代码来源:importhelper.py


示例2: _check

    def _check(self, song):
        old_threshold = Gst.debug_get_default_threshold()
        Gst.debug_set_default_threshold(Gst.DebugLevel.NONE)

        pipeline = Gst.parse_launch(
            "uridecodebin uri=%s ! fakesink" % song("~uri"))
        bus = pipeline.get_bus()
        pipeline.set_state(Gst.State.PLAYING)
        try:
            while 1:
                message = bus.timed_pop(Gst.SECOND * 10)
                if not message or message.type == Gst.MessageType.ERROR:
                    if message:
                        debug = message.parse_error()[0].message
                    else:
                        debug = "timed out"
                    # only print a warning for platforms where we control
                    # the shipped dependencies.
                    if sys.platform == "darwin" or os.name == "nt":
                        print_w("GStreamer: Decoding %r failed (%s)" %
                                (song("~format"), debug))
                    break
                if message.type == Gst.MessageType.EOS:
                    break
        finally:
            pipeline.set_state(Gst.State.NULL)

        Gst.debug_set_default_threshold(old_threshold)
开发者ID:urielz,项目名称:quodlibet,代码行数:28,代码来源:test_player_gst.py


示例3: _exec_command

    def _exec_command(self, command, args, no_ack=False):
        self._command = command

        if command not in self._commands:
            print_w("Unhandled command %r, sending OK." % command)
            command = "ping"

            # Unhandled command, default to OK for now..
            if not self._use_command_list:
                self.ok()
            elif self._command_list_ok:
                self.write_line(u"list_OK")
            return

        cmd, do_ack, permission = self._commands[command]
        if permission != (self.permission & permission):
            raise MPDRequestError("Insufficient permission",
                    AckError.PERMISSION)

        cmd(self, self.service, args)

        if self._use_command_list:
            if self._command_list_ok:
                self.write_line(u"list_OK")
        elif do_ack:
            self.ok()
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:26,代码来源:main.py


示例4: __lookup_cb

    def __lookup_cb(self, lresult):
        with self.__update_row(lresult.song) as entry:
            entry.status = Status.DONE
            entry.result = lresult

            # count how many times each release ID is present and weight by the
            # score
            for release in lresult.releases:
                id_ = release.id
                # to prevent favoring releases which are a superset of
                # the release we actually want (say 8 CD box containing
                # every song of an artist), try to reduce the medium count.
                score = score_release(release) / release.medium_count
                self._release_scores.setdefault(id_, 0)
                self._release_scores[id_] += score

                # do the same again but group by directory
                dir_ = lresult.song("~dirname")
                release_scores = self._directory_scores.setdefault(dir_, {})
                release_scores.setdefault(id_, 0)
                release_scores[id_] += score

            # update display
            if lresult.releases:
                self.__update_active_releases()
            elif lresult.error:
                entry.status = Status.ERROR
                # we don't expose in the UI, so at least print it
                print_w(lresult.error)
            else:
                entry.status = Status.UNKNOWN

        self.__inc_done()
开发者ID:faubiguy,项目名称:quodlibet,代码行数:33,代码来源:search.py


示例5: _check_feed

    def _check_feed(self):
        """Validate stream a bit - failing fast where possible.

           Constructs an equivalent(ish) HEAD request,
           without re-writing feedparser completely.
           (it never times out if reading from a stream - see #2257)"""
        req = feedparser._build_urllib2_request(
            self.uri, feedparser.USER_AGENT, None, None, None, None, {})
        req.method = "HEAD"
        opener = build_opener(feedparser._FeedURLHandler())
        try:
            result = opener.open(req)
            ct_hdr = result.headers.get('Content-Type', "Unknown type")
            content_type = ct_hdr.split(';')[0]
            try:
                status = result.status
            except AttributeError:
                print_w("Missing status code for feed %s" % self.uri)
            else:
                print_d("Pre-check: %s returned %s with content type '%s'" %
                        (self.uri, status, content_type))
                if content_type not in feedparser.ACCEPT_HEADER:
                    print_w("Unusable content: %s. Perhaps %s is not a feed?" %
                            (content_type, self.uri))
                    return False
                # No real need to check HTTP Status - errors are very unlikely
                # to be a usable content type, and we should try to parse
        finally:
            opener.close()
        return True
开发者ID:zsau,项目名称:quodlibet,代码行数:30,代码来源:audiofeeds.py


示例6: is_accel

def is_accel(event, *accels):
    """Checks if the given keypress Gdk.Event matches
    any of accelerator strings.

    example: is_accel(event, "<shift><ctrl>z")
    """

    assert accels

    if event.type != Gdk.EventType.KEY_PRESS:
        return False

    # ctrl+shift+x gives us ctrl+shift+X and accelerator_parse returns
    # lowercase values for matching, so lowercase it if possible
    keyval = event.keyval
    if not keyval & ~0xFF:
        keyval = ord(chr(keyval).lower())

    default_mod = Gtk.accelerator_get_default_mod_mask()

    for accel in accels:
        accel_keyval, accel_mod = Gtk.accelerator_parse(accel)

        # If the accel contains non default modifiers matching will
        # never work and since no one should use them, complain
        non_default = accel_mod & ~default_mod
        if non_default:
            print_w("Accelerator '%s' contains a non default modifier '%s'." %
                (accel, Gtk.accelerator_name(0, non_default) or ""))

        # Remove everything except default modifiers and compare
        if (accel_keyval, accel_mod) == (keyval, event.state & default_mod):
            return True

    return False
开发者ID:faubiguy,项目名称:quodlibet,代码行数:35,代码来源:__init__.py


示例7: __save

    def __save(self, save, song, buffer, delete):
        start, end = buffer.get_bounds()
        text = buffer.get_text(start, end, True)

        # First, write back to the tags.
        song["lyrics"] = text.decode("utf-8")
        try:
            song.write()
        except AudioFileError:
            util.print_exc()

        # Then, write to file.
        # TODO: write to file only if could not write to tags, otherwise delete
        # the file.
        lyricname = song.lyric_filename
        try:
            os.makedirs(os.path.dirname(lyricname))
        except EnvironmentError as err:
            pass

        try:
            with open(lyricname, "w") as f:
                f.write(text)
        except EnvironmentError as err:
            encoding = util.get_locale_encoding()
            print_w(err.strerror.decode(encoding, "replace"))
        delete.set_sensitive(True)
        save.set_sensitive(False)
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:28,代码来源:lyrics.py


示例8: init

def init(app_id):
    if not dbus:
        return

    try:
        bus = dbus.Bus(dbus.Bus.TYPE_SESSION)
        manager = bus.get_object("org.gnome.SessionManager",
                                 "/org/gnome/SessionManager")
        iface = dbus.Interface(manager, "org.gnome.SessionManager")
        client_path = iface.RegisterClient(app_id, "")
        if client_path is None:
            # https://github.com/quodlibet/quodlibet/issues/2435
            print_w("Broken session manager implementation, likely LXDE")
            return

        client = bus.get_object("org.gnome.SessionManager", client_path)
        client_priv = dbus.Interface(client,
                                     "org.gnome.SessionManager.ClientPrivate")

        def end_session_cb(*args):
            print_d("GSM sent EndSession: going down")
            client_priv.EndSessionResponse(True, "")
            app.quit()

        def query_end_session_cb(*args):
            print_d("GSM sent QueryEndSession")
            client_priv.EndSessionResponse(True, "")

        client_priv.connect_to_signal("QueryEndSession", query_end_session_cb)
        client_priv.connect_to_signal("EndSession", end_session_cb)
    except dbus.DBusException:
        print_d("Connecting with the gnome session manager failed")
    else:
        print_d("Connected with gnome session manager: %s" % client_path)
开发者ID:elfalem,项目名称:quodlibet,代码行数:34,代码来源:session.py


示例9: plugin_songs

 def plugin_songs(self, songs):
     # Check this is a launch, not a configure
     if self.chosen_site:
         url_pat = self.get_url_pattern(self.chosen_site)
         pat = Pattern(url_pat)
         urls = set()
         for song in songs:
             # Generate a sanitised AudioFile; allow through most tags
             subs = AudioFile()
             for k in (USER_TAGS + MACHINE_TAGS):
                 vals = song.comma(k)
                 if vals:
                     try:
                         encoded = unicode(vals).encode('utf-8')
                         subs[k] = (encoded if k == 'website'
                                    else quote_plus(encoded))
                     # Dodgy unicode problems
                     except KeyError:
                         print_d("Problem with %s tag values: %r"
                                 % (k, vals))
             url = str(pat.format(subs))
             if not url:
                 print_w("Couldn't build URL using \"%s\"."
                         "Check your pattern?" % url_pat)
                 return
             # Grr, set.add() should return boolean...
             if url not in urls:
                 urls.add(url)
                 website(url)
开发者ID:urielz,项目名称:quodlibet,代码行数:29,代码来源:website_search.py


示例10: show_uri

def show_uri(label, uri):
    """Shows a uri. The uri can be anything handled by GIO or a quodlibet
    specific one.

    Currently handled quodlibet uris:
        - quodlibet:///prefs/plugins/<plugin id>

    Args:
        label (str)
        uri (str) the uri to show
    Returns:
        True on success, False on error
    """

    parsed = urlparse(uri)
    if parsed.scheme == "quodlibet":
        if parsed.netloc != "":
            print_w("Unknown QuodLibet URL format (%s)" % uri)
            return False
        else:
            return __show_quodlibet_uri(parsed)
    else:
        # Gtk.show_uri_on_window exists since 3.22
        if hasattr(Gtk, "show_uri_on_window"):
            from quodlibet.qltk import get_top_parent
            return Gtk.show_uri_on_window(get_top_parent(label), uri, 0)
        else:
            return Gtk.show_uri(None, uri, 0)
开发者ID:elfalem,项目名称:quodlibet,代码行数:28,代码来源:__init__.py


示例11: _update_avahi

    def _update_avahi(self):
        assert self._avahi

        port_num = get_port_num()
        try:
            self._avahi.register(app.name, port_num, "_mpd._tcp")
        except AvahiError as e:
            print_w(str(e))
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:8,代码来源:__init__.py


示例12: _enable_server

 def _enable_server(self):
     port_num = get_port_num()
     print_d("Starting MPD server on port %d" % port_num)
     self._server = MPDServer(app, self, port_num)
     try:
         self._server.start()
     except ServerError as e:
         print_w(str(e))
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:8,代码来源:__init__.py


示例13: _sent

 def _sent(self, session, task, data):
     try:
         self.istream = session.send_finish(task)
         print_d('Sent {1} request to {0}'.format(self._uri,
                                                  self.message.method))
         self.emit('sent', self.message)
     except GLib.GError as e:
         print_w('Failed sending request to {0}'.format(self._uri))
         self.emit('send-failure', e)
开发者ID:gbtami,项目名称:quodlibet,代码行数:9,代码来源:http.py


示例14: port_activate

 def port_activate(entry, *args):
     try:
         port_num = int(entry.get_text())
     except ValueError as e:
         print_w(str(e))
     else:
         if get_port_num() != port_num:
             set_port_num(port_num)
             self._refresh()
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:9,代码来源:__init__.py


示例15: MusicFile

def MusicFile(filename):
    """Returns a AudioFile instance or None"""

    loader = get_loader(filename)
    if loader is not None:
        try:
            return loader(filename)
        except AudioFileError:
            print_w("Error loading %r" % filename)
            util.print_exc()
开发者ID:faubiguy,项目名称:quodlibet,代码行数:10,代码来源:_misc.py


示例16: _callback

 def _callback(self, data):
     try:
         messages = list(fifo.split_message(data))
     except ValueError:
         print_w("invalid message: %r" % data)
         return
     for command, path in messages:
         response = self._cmd_registry.handle_line(self._app, command)
         if path is not None:
             with open(path, "wb") as h:
                 if response is not None:
                     h.write(response)
开发者ID:urielz,项目名称:quodlibet,代码行数:12,代码来源:remote.py


示例17: conclude

    def conclude(self, fails, reason):
        if fails:

            def format_occurrences(e):
                occurences = [(self.lang + ".po", e.linenum)]
                occurences += e.occurrences
                return ", ".join("%s:%s" % o for o in occurences)

            messages = ['"%s" - "%s" (%s)' % (e.msgid, e.msgstr, format_occurrences(e)) for e in fails]
            for message in messages:
                print_w(message)
            self.fail("One or more messages did not pass (%s).\n" "Please check the warning messages above." % reason)
开发者ID:urielz,项目名称:quodlibet,代码行数:12,代码来源:test_po.py


示例18: cover

    def cover(self):
        """
        Method to get cover file from cover provider for a specific song.

        Should always return a file-like object opened as read-only if any
        and None otherwise.
        """
        cp = self.cover_path
        try:
            return open(cp, 'rb') if cp and path.isfile(cp) else None
        except IOError:
            print_w('Failed reading album art "%s"'.format(path))
开发者ID:LudoBike,项目名称:quodlibet,代码行数:12,代码来源:cover.py


示例19: should_process

 def should_process(self):
     """Returns true if the album needs analysis, according to prefs"""
     mode = self.__process_mode
     if mode == UpdateMode.ALWAYS:
         return True
     elif mode == UpdateMode.ANY_MISSING:
         return not all([s.has_all_rg_tags for s in self.songs])
     elif mode == UpdateMode.ALBUM_MISSING:
         return not all([s.album_gain for s in self.songs])
     else:
         print_w("Invalid setting for update mode: " + mode)
         # Safest to re-process probably.
         return True
开发者ID:Muges,项目名称:quodlibet,代码行数:13,代码来源:replaygain.py


示例20: is_accel

def is_accel(event, *accels):
    """Checks if the given keypress Gdk.Event matches
    any of accelerator strings.

    example: is_accel(event, "<shift><ctrl>z")

    Args:
        *accels: one ore more `str`
    Returns:
        bool
    Raises:
        ValueError: in case any of the accels could not be parsed
    """

    assert accels

    if event.type != Gdk.EventType.KEY_PRESS:
        return False

    # ctrl+shift+x gives us ctrl+shift+X and accelerator_parse returns
    # lowercase values for matching, so lowercase it if possible
    keyval = event.keyval
    if not keyval & ~0xFF:
        keyval = ord(chr(keyval).lower())

    default_mod = Gtk.accelerator_get_default_mod_mask()
    keymap = Gdk.Keymap.get_default()

    for accel in accels:
        accel_keyval, accel_mod = Gtk.accelerator_parse(accel)
        if accel_keyval == 0 and accel_mod == 0:
            raise ValueError("Invalid accel: %s" % accel)

        # If the accel contains non default modifiers matching will
        # never work and since no one should use them, complain
        non_default = accel_mod & ~default_mod
        if non_default:
            print_w("Accelerator '%s' contains a non default modifier '%s'." %
                (accel, Gtk.accelerator_name(0, non_default) or ""))

        # event.state contains the real mod mask + the virtual one, while
        # we usually pass only virtual one as text. This adds the real one
        # so they match in the end.
        accel_mod = keymap.map_virtual_modifiers(accel_mod)[1]

        # Remove everything except default modifiers and compare
        if (accel_keyval, accel_mod) == (keyval, event.state & default_mod):
            return True

    return False
开发者ID:elfalem,项目名称:quodlibet,代码行数:50,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python util.re_escape函数代码示例发布时间:2022-05-26
下一篇:
Python util.print_exc函数代码示例发布时间: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