本文整理汇总了Python中quodlibet.util.print_d函数的典型用法代码示例。如果您正苦于以下问题:Python print_d函数的具体用法?Python print_d怎么用?Python print_d使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_d函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add
def add(self, func, *args, **kwargs):
"""Register a routine to run in GLib main loop.
func should be a function that returns a Python iterator (e.g.
generator) that provides values until it should stop being called.
Optional Keyword Arguments:
priority -- priority to run at (default GLib.PRIORITY_LOW)
funcid -- mutex/removal identifier for this function
timeout -- use timeout_add (with given timeout) instead of idle_add
(in milliseconds)
Only one function with the same funcid can be running at once.
Starting a new function with the same ID will stop the old one. If
no funcid is given, the function itself is used. The funcid must
be usable as a hash key.
"""
funcid = kwargs.pop("funcid", func)
if funcid in self.__routines:
remove(funcid)
priority = kwargs.pop("priority", GLib.PRIORITY_LOW)
timeout = kwargs.pop("timeout", None)
print_d("Added copool function %r with id %r" % (func, funcid))
routine = _Routine(self, func, funcid, priority, timeout, args, kwargs)
self.__routines[funcid] = routine
routine.resume()
示例2: _create_waveform
def _create_waveform(self, song, points):
# Close any existing pipeline to avoid leaks
self._clean_pipeline()
if not song.is_file:
return
command_template = """
uridecodebin name=uridec
! audioconvert
! level name=audiolevel interval={} post-messages=true
! fakesink sync=false"""
interval = int(song("~#length") * 1E9 / points)
print_d("Computing data for each %.3f seconds" % (interval / 1E9))
command = command_template.format(interval)
pipeline = Gst.parse_launch(command)
pipeline.get_by_name("uridec").set_property("uri", song("~uri"))
bus = pipeline.get_bus()
self._bus_id = bus.connect("message", self._on_bus_message)
bus.add_signal_watch()
pipeline.set_state(Gst.State.PLAYING)
self._pipeline = pipeline
self._new_rms_vals = []
示例3: _wrap_class
def _wrap_class(lib, version, base, ptr, prefix, methods):
for method in methods:
name, ret, args = method[:3]
if len(method) > 3 and method[-1] != version:
continue
try:
func = getattr(lib, prefix + name)
except AttributeError:
# don't fail on missing ones, just in case..
print_d("missing libudev symbol: %r" % (prefix + name))
continue
func.argtypes = args
func.restype = ret
def add_self(f, check_null=False):
def check(*args):
# the first arg is the pointer to the struct, check for
# null pointers before passing it...
args[0].contents
return f(*args)
return check
if args and args[0] == ptr:
setattr(ptr, name, add_self(func))
else:
setattr(base, name, func)
示例4: _add_service
def _add_service(self):
assert not self._group
assert not self._group_id
try:
bus = dbus.SystemBus()
server_obj = bus.get_object(self.DBUS_NAME, self.DBUS_PATH_SERVER)
server = dbus.Interface(server_obj, self.DBUS_INTERFACE_SERVER)
group_path = server.EntryGroupNew()
group_obj = bus.get_object(self.DBUS_NAME, group_path)
group = dbus.Interface(group_obj, self.DBUS_INTERFACE_ENTRY_GROUP)
self._group_id = group.connect_to_signal(
"StateChanged", self._group_state_change)
flags = AvahiPublishFlags.NONE
print_d("name=%s, flags=%x, stype=%s, port=%d" % (
self._real_name, flags, self.stype, self.port))
group.AddService(
AVAHI_IF_UNSPEC, AvahiProtocol.UNSPEC,
dbus.UInt32(flags), self._real_name, self.stype,
dbus.String(), dbus.String(), dbus.UInt16(self.port), [])
group.Commit()
self._group = group
except dbus.DBusException:
self._remove_service()
示例5: _on_bus_message
def _on_bus_message(self, bus, message):
if message.type == Gst.MessageType.ERROR:
error, debug = message.parse_error()
print_d("Error received from element {name}: {error}".format(
name=message.src.get_name(), error=error))
print_d("Debugging information: {}".format(debug))
elif message.type == Gst.MessageType.ELEMENT:
structure = message.get_structure()
if structure.get_name() == "level":
rms_db = structure.get_value("rms")
if rms_db:
# Calculate average of all channels (usually 2)
rms_db_avg = sum(rms_db) / len(rms_db)
# Normalize dB value to value between 0 and 1
rms = pow(10, (rms_db_avg / 20))
self._new_rms_vals.append(rms)
else:
print_w("Got unexpected message of type {}"
.format(message.type))
elif message.type == Gst.MessageType.EOS:
self._clean_pipeline()
# Update the waveform with the new data
self._rms_vals = self._new_rms_vals
self._waveform_scale.reset(self._rms_vals)
self._waveform_scale.set_placeholder(False)
self._update_redraw_interval()
# Clear temporary reference to the waveform data
del self._new_rms_vals
示例6: 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)
示例7: failure
def failure(source, msg):
name = source.__class__.__name__
print_d("Didn't get cover from {0}: {1}".format(name, msg))
source.disconnect_by_func(success)
source.disconnect_by_func(failure)
if not cancellable or not cancellable.is_cancelled():
run()
示例8: success
def success(source, result):
name = source.__class__.__name__
print_d('Successfully got cover from {0}'.format(name))
source.disconnect_by_func(success)
source.disconnect_by_func(failure)
if not cancellable or not cancellable.is_cancelled():
callback(True, result)
示例9: _create_waveform
def _create_waveform(self, song, points):
# Close any existing pipelines to avoid warnings
if hasattr(self, "_pipeline") and self._pipeline:
self._pipeline.set_state(Gst.State.NULL)
command_template = """
filesrc name=fs
! decodebin ! audioconvert
! level name=audiolevel interval={} post-messages=true
! fakesink sync=false"""
interval = int(song("~#length") * 1E9 / points)
print_d("Computing data for each %.3f seconds" % (interval / 1E9))
command = command_template.format(interval)
pipeline = Gst.parse_launch(command)
pipeline.get_by_name("fs").set_property("location", song("~filename"))
bus = pipeline.get_bus()
self._bus_id = bus.connect("message", self._on_bus_message)
bus.add_signal_watch()
pipeline.set_state(Gst.State.PLAYING)
self._pipeline = pipeline
self._rms_vals = []
示例10: plugin_on_song_started
def plugin_on_song_started(self, song):
if (song is None and config.get("memory", "order") != "onesong" and
not app.player.paused):
browser = app.window.browser
if not browser.can_filter('album'):
return
albumlib = app.library.albums
albumlib.load()
if browser.can_filter_albums():
keys = browser.list_albums()
values = [albumlib[k] for k in keys]
else:
keys = set(browser.list("album"))
values = [a for a in albumlib if a("album") in keys]
if self.use_weights:
# Select 3% of albums, or at least 3 albums
nr_albums = int(min(len(values), max(0.03 * len(values), 3)))
chosen_albums = random.sample(values, nr_albums)
album_scores = sorted(self._score(chosen_albums))
for score, album in album_scores:
print_d("%0.2f scored by %s" % (score, album("album")))
album = max(album_scores)[1]
else:
album = random.choice(values)
if album is not None:
self.schedule_change(album)
示例11: 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)
示例12: run
def run(self, app, name, *args):
"""Execute the command `name` passing args
May raise CommandError
"""
if name not in self._commands:
raise CommandError("Unknown command %r" % name)
cmd, argcount, optcount = self._commands[name]
if len(args) < argcount:
raise CommandError("Not enough arguments for %r" % name)
if len(args) > argcount + optcount:
raise CommandError("Too many arguments for %r" % name)
print_d("Running %r with params %s " % (cmd.__name__, args))
try:
result = cmd(app, *args)
except CommandError as e:
raise CommandError("%s: %s" % (name, str(e)))
else:
if result is not None and not isinstance(result, fsnative):
raise CommandError(
"%s: returned %r which is not fsnative" % (name, result))
return result
示例13: handle_line
def handle_line(self, app, line):
"""Parses a command line and executes the command.
Can not fail.
Args:
app (Application)
line (fsnative)
Returns:
fsnative or None
"""
assert isinstance(line, fsnative)
# only one arg supported atm
parts = line.split(" ", 1)
command = parts[0]
args = parts[1:]
print_d("command: %r(*%r)" % (command, args))
try:
return self.run(app, command, *args)
except CommandError as e:
print_e(e)
except:
util.print_exc()
示例14: __about_to_finish_sync
def __about_to_finish_sync(self):
"""Returns the next song uri to play or None"""
print_d("About to finish (sync)")
# Chained oggs falsely trigger a gapless transition.
# At least for radio streams we can safely ignore it because
# transitions don't occur there.
# https://github.com/quodlibet/quodlibet/issues/1454
# https://bugzilla.gnome.org/show_bug.cgi?id=695474
if self.song.multisong:
print_d("multisong: ignore about to finish")
return
# mod + gapless deadlocks
# https://github.com/quodlibet/quodlibet/issues/2780
if isinstance(self.song, ModFile):
return
if config.getboolean("player", "gst_disable_gapless"):
print_d("Gapless disabled")
return
# this can trigger twice, see issue 987
if self._in_gapless_transition:
return
self._in_gapless_transition = True
print_d("Select next song in mainloop..")
self._source.next_ended()
print_d("..done.")
song = self._source.current
if song is not None:
return song("~uri")
示例15: _group_add_service_and_commit
def _group_add_service_and_commit(self, group, flags):
print_d("name=%s, flags=%x, stype=%s, port=%d" % (
self._real_name, flags, self.stype, self.port))
group.AddService('(iiussssqaay)',
AVAHI_IF_UNSPEC, AvahiProtocol.UNSPEC, flags,
self._real_name, self.stype, '', '', self.port, [])
group.Commit()