本文整理汇总了Python中quodlibet.util.print_exc函数的典型用法代码示例。如果您正苦于以下问题:Python print_exc函数的具体用法?Python print_exc怎么用?Python print_exc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了print_exc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __update_icon
def __update_icon(self):
if self.__size <= 0:
return
if not self.__pixbuf:
flags = 0
if sys.platform == "win32":
flags = Gtk.IconLookupFlags.FORCE_SIZE
try:
self.__pixbuf = self.__icon_theme.load_icon(
Icons.QUODLIBET, self.__size, flags)
except GLib.GError:
util.print_exc()
return
# We need to fill the whole height that is given to us, or
# the KDE panel will emit size-changed until we reach 0
w, h = self.__pixbuf.get_width(), self.__pixbuf.get_height()
if h < self.__size:
bg = GdkPixbuf.Pixbuf.new(
GdkPixbuf.Colorspace.RGB, True, 8, w, self.__size)
bg.fill(0)
self.__pixbuf.copy_area(0, 0, w, h, bg, 0, (self.__size - h) / 2)
self.__pixbuf = bg
if app.player.paused and not self.__pixbuf_paused:
self.__pixbuf_paused = new_with_paused_emblem(self.__pixbuf)[1]
if app.player.paused:
new_pixbuf = self.__pixbuf_paused
else:
new_pixbuf = self.__pixbuf
self._icon.set_from_pixbuf(new_pixbuf)
开发者ID:vrasidas,项目名称:quodlibet,代码行数:34,代码来源:trayicon.py
示例2: __about_to_finish
def __about_to_finish(self, playbin):
print_d("About to finish (async)")
try:
uri = self._runner.call(self.__about_to_finish_sync,
priority=GLib.PRIORITY_HIGH,
timeout=0.5)
except MainRunnerTimeoutError as e:
# Due to some locks being held during this signal we can get
# into a deadlock when a seek or state change event happens
# in the mainloop before our function gets scheduled.
# In this case abort and do nothing, which results
# in a non-gapless transition.
print_d("About to finish (async): %s" % e)
return
except MainRunnerAbortedError as e:
print_d("About to finish (async): %s" % e)
return
except MainRunnerError:
util.print_exc()
return
if uri is not None:
print_d("About to finish (async): setting uri")
playbin.set_property('uri', uri)
print_d("About to finish (async): done")
开发者ID:zsau,项目名称:quodlibet,代码行数:26,代码来源:player.py
示例3: __invoke
def __invoke(self, librarian, event, *args):
args = list(args)
if args and args[0]:
if isinstance(args[0], dict):
args[0] = SongWrapper(args[0])
elif isinstance(args[0], (set, list)):
args[0] = ListWrapper(args[0])
for plugin in itervalues(self.__plugins):
method_name = 'plugin_on_' + event.replace('-', '_')
handler = getattr(plugin, method_name, None)
def overridden(obj, name):
return name in type(obj).__dict__
if overridden(plugin, method_name):
try:
handler(*args)
except Exception:
print_e("Error during %s on %s" %
(method_name, type(plugin)))
util.print_exc()
if event not in ["removed", "changed"] and args:
from quodlibet import app
songs = args[0]
if not isinstance(songs, (set, list)):
songs = [songs]
songs = filter(None, songs)
check_wrapper_changed(librarian, app.window, songs)
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:29,代码来源:events.py
示例4: plugin_songs
def plugin_songs(self, songs):
for song in songs:
song = song._song
if not isinstance(song, ID3File):
continue
filename = song["~filename"]
try:
tag = ID3hack(filename)
except Exception:
util.print_exc()
continue
if not tag.getall("TLEN"):
continue
tag.delall("TLEN")
try:
tag.save()
except Exception:
util.print_exc()
continue
app.librarian.reload(song)
开发者ID:bossjones,项目名称:quodlibet,代码行数:26,代码来源:id3tlen.py
示例5: 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
示例6: enable
def enable(self, plugin, status, force=False):
"""Enable or disable a plugin. Also takes an instance."""
if type(plugin) in self.__handlers:
plugin = type(plugin)
if not force and self.enabled(plugin) == bool(status):
return
if not status:
print_d("Disable %r" % plugin.PLUGIN_ID)
for handler in self.__handlers[plugin]:
handler.plugin_disable(plugin)
self.__enabled.discard(plugin.PLUGIN_ID)
instance = self.__instance.get(plugin)
if instance and hasattr(instance, "disabled"):
try:
instance.disabled()
except Exception:
util.print_exc()
else:
print_d("Enable %r" % plugin.PLUGIN_ID)
obj = self.get_instance(plugin)
if obj and hasattr(obj, "enabled"):
try:
obj.enabled()
except Exception:
util.print_exc()
for handler in self.__handlers[plugin]:
handler.plugin_enable(plugin, obj)
self.__enabled.add(plugin.PLUGIN_ID)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:31,代码来源:__init__.py
示例7: 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()
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:27,代码来源:commands.py
示例8: __save_files
def __save_files(self, parent, model, library):
win = WritingWindow(parent, len(model))
was_changed = set()
all_done = False
for entry in model.itervalues():
song, track = entry.song, entry.tracknumber
if song.get("tracknumber") == track:
win.step()
continue
if not song.valid():
win.hide()
dialog = OverwriteWarning(self, song)
resp = dialog.run()
win.show()
if resp != OverwriteWarning.RESPONSE_SAVE:
break
song["tracknumber"] = track
try:
song.write()
except AudioFileError:
util.print_exc()
WriteFailedError(self, song).run()
library.reload(song, changed=was_changed)
break
was_changed.add(song)
if win.step():
break
else:
all_done = True
library.changed(was_changed)
win.destroy()
self.save.set_sensitive(not all_done)
self.revert.set_sensitive(not all_done)
开发者ID:bernd-wechner,项目名称:quodlibet,代码行数:34,代码来源:tracknumbers.py
示例9: _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
示例10: __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
示例11: enable
def enable(self, plugin, status, force=False):
"""Enable or disable a plugin."""
if not force and self.enabled(plugin) == bool(status):
return
if not status:
print_d("Disable %r" % plugin.id)
for handler in plugin.handlers:
handler.plugin_disable(plugin)
self.__enabled.discard(plugin.id)
instance = plugin.instance
if instance and hasattr(instance, "disabled"):
try:
instance.disabled()
except Exception:
util.print_exc()
else:
print_d("Enable %r" % plugin.id)
obj = plugin.get_instance()
if obj and hasattr(obj, "enabled"):
try:
obj.enabled()
except Exception:
util.print_exc()
for handler in plugin.handlers:
handler.plugin_enable(plugin)
self.__enabled.add(plugin.id)
开发者ID:mistotebe,项目名称:quodlibet,代码行数:30,代码来源:__init__.py
示例12: load
def load(self, filename, skip=False):
"""Load a library from a file, containing a picked list.
Loading does not cause added, changed, or removed signals.
"""
self.filename = filename
print_d("Loading contents of %r." % filename, self)
try:
if os.path.exists(filename):
# pickle makes 1000 read syscalls for 6000 songs
# read the file into memory so that there are less
# context switches. saves 40% here..
fileobj = file(filename, "rb")
try: items = pickle.loads(fileobj.read())
except (pickle.PickleError, EnvironmentError,
ImportError, EOFError):
util.print_exc()
try: shutil.copy(filename, filename + ".not-valid")
except EnvironmentError:
util.print_exc()
items = []
fileobj.close()
else: return
except EnvironmentError:
return
if skip:
for item in filter(skip, items):
self._contents[item.key] = item
else:
map(self._load, items)
print_d("Done loading contents of %r." % filename, self)
开发者ID:silkecho,项目名称:glowing-silk,代码行数:32,代码来源:_library.py
示例13: __save_files
def __save_files(self, parent, model, library):
win = WritingWindow(parent, len(model))
was_changed = []
for row in model:
song = row[0]
track = row[2]
if song.get("tracknumber") == track:
win.step()
continue
if not song.valid() and not qltk.ConfirmAction(
win, _("Tag may not be accurate"),
_("<b>%s</b> changed while the program was running. "
"Saving without refreshing your library may "
"overwrite other changes to the song.\n\n"
"Save this song anyway?") %(
util.escape(util.fsdecode(song("~basename"))))
).run():
break
song["tracknumber"] = track
try: song.write()
except:
util.print_exc()
qltk.ErrorMessage(
win, _("Unable to save song"),
_("Saving <b>%s</b> failed. The file may be "
"read-only, corrupted, or you do not have "
"permission to edit it.")%(
util.escape(util.fsdecode(song('~basename'))))).run()
library.reload(song, changed=was_changed)
break
was_changed.append(song)
if win.step(): break
library.changed(was_changed)
win.destroy()
开发者ID:silkecho,项目名称:glowing-silk,代码行数:34,代码来源:tracknumbers.py
示例14: load_dir_modules
def load_dir_modules(path, package, load_compiled=False):
"""Load all modules in path (non-recursive).
Load pyc files if load_compiled is True.
In case the module is already loaded, doesn't reload it.
"""
try:
entries = os.listdir(path)
except OSError:
print_w("%r not found" % path)
return []
modules = set()
for entry in entries:
if entry[:1] == "_":
continue
if entry.endswith(".py"):
modules.add(entry[:-3])
elif load_compiled and entry.endswith(".pyc"):
modules.add(entry[:-4])
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:silkecho,项目名称:glowing-silk,代码行数:32,代码来源:modulescanner.py
示例15: __popup_menu
def __popup_menu(self, view, parent):
menu = gtk.Menu()
view.ensure_popup_selection()
model, rows = view.get_selection().get_selected_rows()
can_change = min([model[path][CANEDIT] for path in rows])
items = [
SplitDisc,
SplitTitle,
SplitPerformer,
SplitArranger,
SplitValues,
SplitPerformerFromTitle,
SplitOriginalArtistFromTitle,
]
items.extend(self.handler.plugins)
items.sort(key=lambda item: (item._order, item.__name__))
if len(rows) == 1:
row = model[rows[0]]
value = row[VALUE].decode("utf-8")
text = util.unescape(value)
multi = value.split("<")[0] != value
for Item in items:
if Item.tags and row[TAG] not in Item.tags:
continue
try:
b = Item(row[TAG], text)
except:
util.print_exc()
else:
b.connect("activate", self.__menu_activate, view)
if not min(map(self.__songinfo.can_change, b.needs) + [1]) or multi:
b.set_sensitive(False)
menu.append(b)
if menu.get_children():
menu.append(gtk.SeparatorMenuItem())
b = gtk.ImageMenuItem(gtk.STOCK_REMOVE, gtk.ICON_SIZE_MENU)
b.connect("activate", self.__remove_tag, view)
keyval, mod = gtk.accelerator_parse("Delete")
menu.__accels = gtk.AccelGroup()
b.add_accelerator("activate", menu.__accels, keyval, mod, gtk.ACCEL_VISIBLE)
menu.append(b)
menu.show_all()
# Setting the menu itself to be insensitive causes it to not
# be dismissed; see #473.
for c in menu.get_children():
c.set_sensitive(can_change and c.get_property("sensitive"))
menu.connect("selection-done", lambda m: m.destroy())
return view.popup_menu(menu, 3, gtk.get_current_event_time())
开发者ID:silkecho,项目名称:glowing-silk,代码行数:59,代码来源:edittags.py
示例16: __popup_menu
def __popup_menu(self, view, parent):
menu = Gtk.Menu()
view.ensure_popup_selection()
model, rows = view.get_selection().get_selected_rows()
can_change = min([model[path][0].canedit for path in rows])
items = [SplitDisc, SplitTitle, SplitPerformer, SplitArranger,
SplitValues, SplitPerformerFromTitle,
SplitOriginalArtistFromTitle]
items.extend(self.handler.plugins)
items.sort(key=lambda item: (item._order, item.__name__))
if len(rows) == 1:
row = model[rows[0]]
entry = row[0]
comment = entry.value
text = comment.text
for Item in items:
if Item.tags and entry.tag not in Item.tags:
continue
try:
b = Item(entry.tag, text)
except:
util.print_exc()
else:
b.connect('activate', self.__menu_activate, view)
if (not min(listmap(self.__songinfo.can_change, b.needs) +
[1])
or comment.is_special()):
b.set_sensitive(False)
menu.append(b)
if menu.get_children():
menu.append(SeparatorMenuItem())
b = MenuItem(_("_Remove"), Icons.LIST_REMOVE)
b.connect('activate', self.__remove_tag, view)
qltk.add_fake_accel(b, "Delete")
menu.append(b)
menu.show_all()
# Setting the menu itself to be insensitive causes it to not
# be dismissed; see #473.
for c in menu.get_children():
c.set_sensitive(can_change and c.get_property('sensitive'))
b.set_sensitive(True)
menu.connect('selection-done', lambda m: m.destroy())
# XXX: Keep reference
self.__menu = menu
return view.popup_menu(menu, 3, Gtk.get_current_event_time())
开发者ID:piotrdrag,项目名称:quodlibet,代码行数:57,代码来源:edittags.py
示例17: plugin_handle
def plugin_handle(self, plugin):
try:
ok = issubclass(plugin, GStreamerPlugin) and plugin.setup_element()
except Exception:
util.print_exc()
ok = False
if ok:
plugin._handler = self
return ok
开发者ID:silkecho,项目名称:glowing-silk,代码行数:10,代码来源:_gstutils.py
示例18: wrap
def wrap():
# check once we are scheduled
if not cancellable.is_cancelled():
try:
return function(*args, **kwargs)
except:
# ThreadPool catches the exception for the async result
# which we don't use. Print instead as if it was not catched.
util.print_exc()
raise
开发者ID:ZDBioHazard,项目名称:quodlibet,代码行数:10,代码来源:thread.py
示例19: _set_status
def _set_status(self, text):
print_d("Setting status to \"%s\"..." % text)
self.status = text
try:
accounts = get_active_account_paths()
# TODO: account filtering
set_accounts_requested_presence(accounts, text)
except dbus.DBusException:
print_d("...but setting failed")
util.print_exc()
开发者ID:Muges,项目名称:quodlibet,代码行数:10,代码来源:telepathy_status.py
示例20: 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
注:本文中的quodlibet.util.print_exc函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论