本文整理汇总了Python中quodlibet.util.dprint.print_w函数的典型用法代码示例。如果您正苦于以下问题:Python print_w函数的具体用法?Python print_w怎么用?Python print_w使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_w函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __remove
def __remove(self, iters, smodel):
def song_at(itr):
return smodel[smodel.get_path(itr)][0]
def remove_from_model(iters, smodel):
for it in iters:
smodel.remove(it)
model, iter = self.__selected_playlists()
if iter:
playlist = model[iter][0]
# A {iter: song} dict, exhausting `iters` once.
removals = {iter_remove: song_at(iter_remove)
for iter_remove in iters}
if not removals:
print_w("No songs selected to remove")
return
if self._query is None or not self.get_filter_text():
# Calling playlist.remove_songs(songs) won't remove the
# right ones if there are duplicates
remove_from_model(removals.keys(), smodel)
self.__rebuild_playlist_from_songs_model(playlist, smodel)
# Emit manually
self.library.emit('changed', removals.values())
else:
playlist.remove_songs(removals.values(), True)
remove_from_model(iters, smodel)
print_d("Removed %d song(s) from %s" % (len(removals), playlist))
self.changed(playlist)
self.activate()
开发者ID:zsau,项目名称:quodlibet,代码行数:30,代码来源:main.py
示例2: _set_status
def _set_status(self, text):
print_d("Setting status to \"%s\"..." % text)
result, mid = self.client.publish(self.topic, text)
if result != mqtt.MQTT_ERR_SUCCESS:
print_w("Couldn't publish to %s at %s:%d (%s)"
% (self.topic, self.host, self.port, result))
self.status = text
开发者ID:Muges,项目名称:quodlibet,代码行数:7,代码来源:mqtt.py
示例3: init
def init():
global device_manager
if not dbus: return
device_manager = None
print_d(_("Initializing device backend."))
try_text = _("Trying '%s'")
#DKD maintainers will change the naming of dbus, app stuff
#in january 2010 or so (already changed in trunk), so try both
if device_manager is None:
print_d(try_text % "DeviceKit Disks")
try: device_manager = DKD(("DeviceKit", "Disks"))
except (LookupError, dbus.DBusException): pass
if device_manager is None:
print_d(try_text % "UDisks")
try: device_manager = DKD(("UDisks",))
except (LookupError, dbus.DBusException): pass
if device_manager is None:
print_d(try_text % "HAL")
try: device_manager = HAL()
except (LookupError, dbus.DBusException): pass
if device_manager is None:
print_w(_("Couldn't connect to a device backend."))
else:
print_d(_("Device backend initialized."))
return device_manager
开发者ID:silkecho,项目名称:glowing-silk,代码行数:31,代码来源:__init__.py
示例4: run
def run(self, songs):
"""
Runs this command on `songs`,
splitting into multiple calls if necessary
"""
args = []
if self.parameter:
value = GetStringDialog(None, _("Input value"),
_("Value for %s?") % self.parameter).run()
self.command = self.command.format(**{self.parameter: value})
print_d("Actual command=%s" % self.command)
for song in songs:
arg = str(self.__pat.format(song))
if not arg:
print_w("Couldn't build shell command using \"%s\"."
"Check your pattern?" % self.pattern)
break
if not self.unique:
args.append(arg)
elif arg not in args:
args.append(arg)
max = int((self.max_args or 10000))
com_words = self.command.split(" ")
while args:
print_d("Running %s with %d substituted arg(s) (of %d%s total)..."
% (self.command, min(max, len(args)), len(args),
" unique" if self.unique else ""))
util.spawn(com_words + args[:max])
args = args[max:]
开发者ID:Konzertheld,项目名称:quodlibet,代码行数:29,代码来源:custom_commands.py
示例5: __request
def __request(self, line, raw=False, want_reply=True):
"""
Send a request to the server, if connected, and return its response
"""
line = line.strip()
if not (self.is_connected or line.split()[0] == 'login'):
print_d("Can't do '%s' - not connected" % line.split()[0], self)
return None
if self._debug:
print_(">>>> \"%s\"" % line)
try:
self.telnet.write(line + "\n")
if not want_reply:
return None
raw_response = self.telnet.read_until("\n").strip()
except socket.error as e:
print_w("Couldn't communicate with squeezebox (%s)" % e)
self.failures += 1
if self.failures >= self._MAX_FAILURES:
print_w("Too many Squeezebox failures. Disconnecting")
self.is_connected = False
return None
response = raw_response if raw else urllib.unquote(raw_response)
if self._debug:
print_("<<<< \"%s\"" % (response,))
return response[len(line) - 1:] if line.endswith("?")\
else response[len(line) + 1:]
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:29,代码来源:server.py
示例6: _load_items
def _load_items(filename):
"""Load items from disk.
In case of an error returns default or an empty list.
"""
try:
with open(filename, "rb") as fp:
data = fp.read()
except EnvironmentError:
print_w("Couldn't load library file from: %r" % filename)
return []
try:
items = load_audio_files(data)
except SerializationError:
# there are too many ways this could fail
util.print_exc()
# move the broken file out of the way
try:
shutil.copy(filename, filename + ".not-valid")
except EnvironmentError:
util.print_exc()
return []
return items
开发者ID:LudoBike,项目名称:quodlibet,代码行数:28,代码来源:libraries.py
示例7: __init__
def __init__(self, dkd_name):
self.__bus = ".".join(dkd_name)
self.__path = "/".join(dkd_name)
super(DKD, self).__init__("org.freedesktop.%s" % self.__bus)
error = False
try:
udev.init()
except OSError:
print_w(_("%s: Could not find %s.") % (self.__bus, libudev))
error = True
else:
self.__udev = udev.Udev.new()
if self.__get_mpi_dir() is None:
print_w(_("%s: Could not find %s.")
% (self.__bus, "media-player-info"))
error = True
if error:
raise LookupError
interface = "org.freedesktop.%s" % self.__bus
path = "/org/freedesktop/%s" % self.__path
obj = self._system_bus.get_object(interface, path)
self.__interface = dbus.Interface(obj, interface)
self.__interface.connect_to_signal('DeviceAdded', self.__device_added)
self.__interface.connect_to_signal('DeviceRemoved',
self.__device_removed)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:31,代码来源:__init__.py
示例8: init
def init():
global device_manager
if not dbus:
return
device_manager = None
print_d(_("Initializing device backend."))
try_text = _("Trying '%s'")
if device_manager is None:
print_d(try_text % "UDisks2")
try:
device_manager = UDisks2Manager()
except (LookupError, dbus.DBusException):
pass
if device_manager is None:
print_d(try_text % "UDisks1")
try:
device_manager = UDisks1Manager()
except (LookupError, dbus.DBusException):
pass
if device_manager is None:
print_w(_("Couldn't connect to a device backend."))
else:
print_d(_("Device backend initialized."))
return device_manager
开发者ID:virtuald,项目名称:quodlibet,代码行数:29,代码来源:__init__.py
示例9: __init__
def __init__(self):
bus_name = "org.freedesktop.UDisks"
interface = "org.freedesktop.UDisks"
path = "/org/freedesktop/UDisks"
super(UDisks1Manager, self).__init__(bus_name)
error = False
try:
udev.init()
except OSError:
print_w("UDisks: " + _("Could not find '%s'.") % "libudev")
error = True
else:
self.__udev = udev.Udev.new()
if get_mpi_dir() is None:
print_w("UDisks: " + _("Could not find '%s'.")
% "media-player-info")
error = True
if error:
raise LookupError
obj = self._system_bus.get_object(bus_name, path)
self.__interface = dbus.Interface(obj, interface)
self.__devices = {}
self.__interface.connect_to_signal('DeviceAdded', self.__device_added)
self.__interface.connect_to_signal('DeviceRemoved',
self.__device_removed)
开发者ID:virtuald,项目名称:quodlibet,代码行数:32,代码来源:__init__.py
示例10: __init__
def __init__(self, orders, base_cls):
assert issubclass(base_cls, Order)
super(PluggableOrders, self).__init__(orders)
self.base_cls = base_cls
if PluginManager.instance:
PluginManager.instance.register_handler(self)
else:
print_w("No plugin manager found")
开发者ID:urielz,项目名称:quodlibet,代码行数:8,代码来源:playorder.py
示例11: process_IN_CREATE
def process_IN_CREATE(self, event):
if not event.dir:
self._log(event)
# Just remember that they've been created, will process later
path = os.path.join(event.path, event.name)
if os.path.exists(path):
self._being_created.add(path)
else:
print_w("Couldn't find %s" % path)
开发者ID:Muges,项目名称:quodlibet,代码行数:9,代码来源:auto_library_update.py
示例12: query_with_refresh
def query_with_refresh(self, text, sort=None, star=STAR):
"""Queries Soundcloud for some (more) relevant results, then filters"""
current = self._contents.values()
try:
query = SoundcloudQuery(text, star=star)
self.client.get_tracks(query.terms)
except SoundcloudQuery.error as e:
print_w("Couldn't filter for query '%s' (%s)" % (text, e))
return current
filtered = query.filter(current)
print_d("Filtered %d results to %d" % (len(current), len(filtered)))
return filtered
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:12,代码来源:library.py
示例13: try_connecting
def try_connecting(self):
try:
self.enabled()
msg = (_("Connected to broker at %(host)s:%(port)d")
% {'host': self.host, 'port': self.port})
Message(Gtk.MessageType.INFO, app.window, "Success", msg).run()
except IOError as e:
template = _("Couldn't connect to %(host)s:%(port)d (%(msg)s)")
msg = template % {'host': self.host, 'port': self.port, 'msg': e}
print_w(msg)
ErrorMessage(app.window, _("Connection error"), msg).run()
yield
开发者ID:Muges,项目名称:quodlibet,代码行数:12,代码来源:mqtt.py
示例14: __get_media_player_id
def __get_media_player_id(self, devpath):
"""DKD is for high-level device stuff. The info if the device is
a media player and what protocol/formats it supports can only
be retrieved through libudev"""
try:
dev = get_device_from_path(self.__udev, devpath)
except Exception:
print_w("Failed to retrieve udev properties for %r" % devpath)
util.print_exc()
return
try: return dev["ID_MEDIA_PLAYER"]
except KeyError: return None
开发者ID:silkecho,项目名称:glowing-silk,代码行数:13,代码来源:__init__.py
示例15: init_devices
def init_devices():
global devices
load_pyc = os.name == 'nt'
modules = load_dir_modules(dirname(__file__),
package=__package__,
load_compiled=load_pyc)
for mod in modules:
try: devices.extend(mod.devices)
except AttributeError:
print_w("%r doesn't contain any devices." % mod.__name__)
devices.sort()
开发者ID:silkecho,项目名称:glowing-silk,代码行数:14,代码来源:__init__.py
示例16: save
def save(self, filename=None):
"""Save the library to the given filename, or the default if `None`"""
if filename is None:
filename = self.filename
print_d("Saving contents to %r." % filename, self)
try:
dump_items(filename, self.get_content())
except EnvironmentError:
print_w("Couldn't save library to path: %r" % filename)
else:
self.dirty = False
开发者ID:urielz,项目名称:quodlibet,代码行数:14,代码来源:libraries.py
示例17: init_devices
def init_devices():
global devices
load_pyc = util.is_windows() or util.is_osx()
modules = load_dir_modules(dirname(__file__),
package=__package__,
load_compiled=load_pyc)
for mod in modules:
try:
devices.extend(mod.devices)
except AttributeError:
print_w("%r doesn't contain any devices." % mod.__name__)
devices.sort(key=lambda d: repr(d))
开发者ID:bossjones,项目名称:quodlibet,代码行数:15,代码来源:__init__.py
示例18: __search_thread
def __search_thread(self, engine, query, replace):
"""Creates searching threads which call the callback function after
they are finished"""
clean_query = self.__cleanup_query(query, replace)
result = []
try:
result = engine().start(clean_query, self.overall_limit)
except Exception:
print_w("[AlbumArt] %s: %r" % (engine.__name__, query))
print_exc()
self.finished += 1
#progress is between 0..1
progress = float(self.finished) / len(self.engine_list)
GLib.idle_add(self.callback, result, progress)
开发者ID:urielz,项目名称:quodlibet,代码行数:16,代码来源:albumart.py
示例19: _get_saved_commands
def _get_saved_commands(cls):
filename = cls.COMS_FILE
print_d("Loading saved commands from '%s'..." % filename)
coms = None
try:
with open(filename, "r", encoding="utf-8") as f:
coms = JSONObjectDict.from_json(Command, f.read())
except (IOError, ValueError) as e:
print_w("Couldn't parse saved commands (%s)" % e)
# Failing all else...
if not coms:
print_d("No commands found in %s. Using defaults." % filename)
coms = {c.name: c for c in cls.DEFAULT_COMS}
print_d("Loaded commands: %s" % coms.keys())
return coms
开发者ID:LudoBike,项目名称:quodlibet,代码行数:16,代码来源:custom_commands.py
示例20: MusicFile
def MusicFile(filename):
"""Returns a AudioFile instance or None"""
lower = filename.lower()
for ext in _extensions:
if lower.endswith(ext):
try:
return _infos[ext](filename)
except:
print_w("Error loading %r" % filename)
if const.DEBUG:
util.print_exc()
return
else:
print_w("Unknown file extension %r" % filename)
return
开发者ID:SimonLarsen,项目名称:quodlibet,代码行数:16,代码来源:__init__.py
注:本文中的quodlibet.util.dprint.print_w函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论