本文整理汇总了Python中picard.log.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: drop_urls
def drop_urls(urls, target):
files = []
new_files = []
for url in urls:
log.debug("Dropped the URL: %r", url.toString(QtCore.QUrl.RemoveUserInfo))
if url.scheme() == "file" or not url.scheme():
filename = os.path.normpath(os.path.realpath(url.toLocalFile().rstrip("\0")))
file = BaseTreeView.tagger.files.get(filename)
if file:
files.append(file)
elif os.path.isdir(encode_filename(filename)):
BaseTreeView.tagger.add_directory(filename)
else:
new_files.append(filename)
elif url.scheme() in ("http", "https"):
path = url.path()
match = re.search(r"/(release|recording)/([0-9a-z\-]{36})", path)
if match:
entity = match.group(1)
mbid = match.group(2)
if entity == "release":
BaseTreeView.tagger.load_album(mbid)
elif entity == "recording":
BaseTreeView.tagger.load_nat(mbid)
if files:
BaseTreeView.tagger.move_files(files, target)
if new_files:
BaseTreeView.tagger.add_files(new_files, target=target)
开发者ID:zas,项目名称:picard,代码行数:28,代码来源:itemviews.py
示例2: restore_header_state
def restore_header_state(self):
if self.ui.release_list:
header = self.ui.release_list.header()
state = config.persist[self.dialog_header_state]
if state:
header.restoreState(state)
log.debug("restore_state: %s" % self.dialog_header_state)
开发者ID:Jormangeud,项目名称:picard,代码行数:7,代码来源:cdlookup.py
示例3: _move
def _move(self, parent):
if parent != self.parent:
log.debug("Moving %r from %r to %r", self, self.parent, parent)
if self.parent:
self.parent.remove_file(self)
self.parent = parent
self.tagger.acoustidmanager.update(self, self.metadata['musicbrainz_recordingid'])
开发者ID:Freso,项目名称:picard,代码行数:7,代码来源:file.py
示例4: coverart
def coverart(album, metadata, release):
"""Gets all cover art URLs from the metadata and then attempts to
download the album art. """
coverart = CoverArt(album, metadata, release)
log.debug("New %r", coverart)
coverart.retrieve()
开发者ID:Freso,项目名称:picard,代码行数:7,代码来源:__init__.py
示例5: add_files
def add_files(self, filenames, target=None):
"""Add files to the tagger."""
ignoreregex = None
pattern = config.setting['ignore_regex']
if pattern:
ignoreregex = re.compile(pattern)
ignore_hidden = not config.persist["show_hidden_files"]
new_files = []
for filename in filenames:
filename = os.path.normpath(os.path.realpath(filename))
if ignore_hidden and is_hidden_path(filename):
log.debug("File ignored (hidden): %s" % (filename))
continue
if ignoreregex is not None and ignoreregex.search(filename):
log.info("File ignored (matching %s): %s" % (pattern, filename))
continue
if filename not in self.files:
file = open_file(filename)
if file:
self.files[filename] = file
new_files.append(file)
if new_files:
log.debug("Adding files %r", new_files)
new_files.sort(key=lambda x: x.filename)
if target is None or target is self.unmatched_files:
self.unmatched_files.add_files(new_files)
target = None
for file in new_files:
file.load(partial(self._file_loaded, target=target))
开发者ID:SRITANU,项目名称:picard,代码行数:29,代码来源:tagger.py
示例6: _finished
def _finished(self, kind, ids, callback, document, reply, error):
self.pending -= ids
statusbar = self.tagger.window.set_statusbar_message
if not error:
count = len(ids)
if kind == self.COLLECTION_ADD:
self.releases |= ids
self.size += count
status_msg = ngettext(
'Added %(count)i release to collection "%(name)s"',
'Added %(count)i releases to collection "%(name)s"',
count)
debug_msg = 'Added %(count)i releases to collection "%(name)s"'
else:
self.releases -= ids
self.size -= count
status_msg = ngettext(
'Removed %(count)i release from collection "%(name)s"',
'Removed %(count)i releases from collection "%(name)s"',
count)
debug_msg = 'Removed %(count)i releases from collection "%(name)s"'
callback()
mparms = {'count': count, 'name': self.name}
log.debug(debug_msg % mparms)
statusbar(status_msg, mparms, translate=None, echo=None)
else:
statusbar(
N_("Error while modifying collections: %(error)s"),
{'error': reply.errorString()},
echo=log.error
)
开发者ID:zas,项目名称:picard,代码行数:31,代码来源:collection.py
示例7: dropMimeData
def dropMimeData(self, parent, index, data, action):
target = None
if parent:
if index == parent.childCount():
item = parent
else:
item = parent.child(index)
if item is not None:
target = item.obj
log.debug("Drop target = %r", target)
handled = False
# text/uri-list
urls = data.urls()
if urls:
if target is None:
target = self.tagger.unmatched_files
self.drop_urls(urls, target)
handled = True
# application/picard.album-list
albums = data.data("application/picard.album-list")
if albums:
if isinstance(self, FileTreeView) and target is None:
target = self.tagger.unmatched_files
albums = [self.tagger.load_album(id) for id in str(albums).split("\n")]
self.tagger.move_files(self.tagger.get_files_from_objects(albums), target)
handled = True
return handled
开发者ID:Versatilus,项目名称:picard,代码行数:27,代码来源:itemviews.py
示例8: _save
def _save(self, filename, metadata):
log.debug("Saving file %r", filename)
file = ASF(encode_filename(filename))
if config.setting['clear_existing_tags']:
file.tags.clear()
cover = []
for image in metadata.images_to_be_saved_to_tags:
tag_data = pack_image(image.mimetype, image.data,
image_type_as_id3_num(image.maintype),
image.comment)
cover.append(ASFByteArrayAttribute(tag_data))
if cover:
file.tags['WM/Picture'] = cover
for name, values in metadata.rawitems():
if name.startswith('lyrics:'):
name = 'lyrics'
elif name == '~rating':
values[0] = int(values[0]) * 99 / (config.setting['rating_steps'] - 1)
elif name == 'discnumber' and 'totaldiscs' in metadata:
values[0] = '%s/%s' % (metadata['discnumber'], metadata['totaldiscs'])
if name not in self.__TRANS:
continue
name = self.__TRANS[name]
file.tags[name] = map(unicode, values)
file.save()
开发者ID:LordSputnik,项目名称:picard,代码行数:27,代码来源:asf.py
示例9: _save
def _save(self, filename, metadata):
log.debug("Saving file %r", filename)
file = ASF(encode_filename(filename))
if config.setting['clear_existing_tags']:
file.tags.clear()
if config.setting['save_images_to_tags']:
cover = []
for image in metadata.images:
if not save_this_image_to_tags(image):
continue
tag_data = pack_image(image.mimetype, image.data,
image_type_as_id3_num(image.maintype()),
image.description)
cover.append(ASFByteArrayAttribute(tag_data))
if cover:
file.tags['WM/Picture'] = cover
for name, values in metadata.rawitems():
if name.startswith('lyrics:'):
name = 'lyrics'
elif name == '~rating':
values[0] = int(values[0]) * 99 / (config.setting['rating_steps'] - 1)
if name not in self.__TRANS:
continue
name = self.__TRANS[name]
file.tags[name] = map(unicode, values)
file.save()
开发者ID:m42i,项目名称:picard,代码行数:28,代码来源:asf.py
示例10: load_plugindir
def load_plugindir(self, plugindir):
plugindir = os.path.normpath(plugindir)
if not os.path.isdir(plugindir):
log.info("Plugin directory %r doesn't exist", plugindir)
return
# first, handle eventual plugin updates
for updatepath in [os.path.join(plugindir, file) for file in
os.listdir(plugindir) if file.endswith('.update')]:
path = os.path.splitext(updatepath)[0]
name = is_zip(path)
if not name:
name = _plugin_name_from_path(path)
if name:
self._remove_plugin(name)
os.rename(updatepath, path)
log.debug('Updating plugin %r (%r))', name, path)
else:
log.error('Cannot get plugin name from %r', updatepath)
# now load found plugins
names = set()
for path in [os.path.join(plugindir, file) for file in os.listdir(plugindir)]:
name = is_zip(path)
if not name:
name = _plugin_name_from_path(path)
if name:
names.add(name)
log.debug("Looking for plugins in directory %r, %d names found",
plugindir,
len(names))
for name in sorted(names):
try:
self.load_plugin(name, plugindir)
except Exception as e:
log.error('Unable to load plugin: %s.\nError occured: %s', name, e)
开发者ID:zas,项目名称:picard,代码行数:34,代码来源:plugin.py
示例11: _save
def _save(self, filename, metadata):
log.debug("Saving file %r", filename)
file = ASF(encode_filename(filename))
if config.setting["clear_existing_tags"]:
file.tags.clear()
if config.setting["save_images_to_tags"]:
cover = []
for image in metadata.images:
if not save_this_image_to_tags(image):
continue
tag_data = pack_image(image["mime"], image["data"], image_type_as_id3_num(image["type"]), image["desc"])
cover.append(ASFByteArrayAttribute(tag_data))
if cover:
file.tags["WM/Picture"] = cover
for name, values in metadata.rawitems():
if name.startswith("lyrics:"):
name = "lyrics"
elif name == "~rating":
values[0] = int(values[0]) * 99 / (config.setting["rating_steps"] - 1)
if name not in self.__TRANS:
continue
name = self.__TRANS[name]
file.tags[name] = map(unicode, values)
file.save()
开发者ID:TushRaj,项目名称:picard,代码行数:26,代码来源:asf.py
示例12: _load
def _load(self, filename):
log.debug("Loading file %r", filename)
file = ASF(encode_filename(filename))
metadata = Metadata()
for name, values in file.tags.items():
if name == 'WM/Picture':
for image in values:
(mime, data, type, description) = unpack_image(image.value)
try:
coverartimage = TagCoverArtImage(
file=filename,
tag=name,
types=types_from_id3(type),
comment=description,
support_types=True,
data=data,
)
except CoverArtImageError as e:
log.error('Cannot load image from %r: %s' %
(filename, e))
else:
metadata.append_image(coverartimage)
continue
elif name not in self.__RTRANS:
continue
elif name == 'WM/SharedUserRating':
# Rating in WMA ranges from 0 to 99, normalize this to the range 0 to 5
values[0] = int(round(int(unicode(values[0])) / 99.0 * (config.setting['rating_steps'] - 1)))
name = self.__RTRANS[name]
values = filter(bool, map(unicode, values))
if values:
metadata[name] = values
self._info(metadata, file)
return metadata
开发者ID:Murat-Tulek,项目名称:picard,代码行数:35,代码来源:asf.py
示例13: restore_table_header_state
def restore_table_header_state(self):
header = self.table.horizontalHeader()
state = config.persist[self.dialog_header_state]
if state:
header.restoreState(state)
header.setSectionResizeMode(QtWidgets.QHeaderView.Interactive)
log.debug("restore_state: %s" % self.dialog_header_state)
开发者ID:Jormangeud,项目名称:picard,代码行数:7,代码来源:__init__.py
示例14: fetch_username
def fetch_username(self, callback):
log.debug("OAuth: fetching username")
host, port = config.setting['server_host'], config.setting['server_port']
path = "/oauth2/userinfo"
self.webservice.get(host, port, path,
partial(self.on_fetch_username_finished, callback),
parse_response_type=None, mblogin=True, priority=True, important=True)
开发者ID:Sophist-UK,项目名称:Sophist_picard,代码行数:7,代码来源:oauth.py
示例15: _caa_json_downloaded
def _caa_json_downloaded(album, metadata, release, try_list, data, http, error):
album._requests -= 1
caa_front_found = False
if error:
log.error(str(http.errorString()))
else:
try:
caa_data = json.loads(data)
except ValueError:
log.debug("Invalid JSON: %s", http.url().toString())
else:
caa_types = config.setting["caa_image_types"].split()
caa_types = map(unicode.lower, caa_types)
for image in caa_data["images"]:
if config.setting["caa_approved_only"] and not image["approved"]:
continue
if not image["types"] and "unknown" in caa_types:
image["types"] = [u"Unknown"]
imagetypes = map(unicode.lower, image["types"])
for imagetype in imagetypes:
if imagetype == "front":
caa_front_found = True
if imagetype in caa_types:
_caa_append_image_to_trylist(try_list, image)
break
if error or not caa_front_found:
_fill_try_list(album, release, try_list)
_walk_try_list(album, metadata, release, try_list)
开发者ID:hartzell,项目名称:picard,代码行数:29,代码来源:coverart.py
示例16: _out_of_backoff
def _out_of_backoff(hostkey):
REQUEST_DELAY_EXPONENT[hostkey] = 0 # Coming out of backoff, so reset.
# Shrink the delay between requests with each successive reply to
# converge on maximum throughput.
delay = max(int(REQUEST_DELAY[hostkey] / 2),
REQUEST_DELAY_MINIMUM[hostkey])
cws = CONGESTION_WINDOW_SIZE[hostkey]
sst = CONGESTION_SSTHRESH[hostkey]
if sst and cws >= sst:
# Analogous to TCP's congestion avoidance phase. Window growth is linear.
phase = 'congestion avoidance'
cws = cws + (1.0 / cws)
else:
# Analogous to TCP's slow start phase. Window growth is exponential.
phase = 'slow start'
cws += 1
if (REQUEST_DELAY[hostkey] != delay
or CONGESTION_WINDOW_SIZE[hostkey] != cws):
log.debug(
'%s: oobackoff; delay: %dms -> %dms; %s; window size %.3f -> %.3f',
hostkey,
REQUEST_DELAY[hostkey],
delay,
phase,
CONGESTION_WINDOW_SIZE[hostkey],
cws
)
CONGESTION_WINDOW_SIZE[hostkey] = cws
REQUEST_DELAY[hostkey] = delay
开发者ID:Jormangeud,项目名称:picard,代码行数:34,代码来源:ratecontrol.py
示例17: request_finished
def request_finished(document, reply, error):
if error:
tagger.window.set_statusbar_message(
N_("Error loading collections: %(error)s"),
{'error': reply.errorString()},
echo=log.error
)
return
if document and "collections" in document:
collection_list = document['collections']
new_collections = set()
for node in collection_list:
if node["entity-type"] != "release":
continue
col_id = node['id']
col_name = node['name']
col_size = node['release-count']
new_collections.add(col_id)
collection = get_user_collection(col_id, col_name, col_size, refresh=True)
# remove collections which aren't returned by the web service anymore
old_collections = set(user_collections) - new_collections
for collection_id in old_collections:
del user_collections[collection_id]
log.debug("User collections: %r", [(k, v.name) for k, v in user_collections.items()])
if callback:
callback()
开发者ID:zas,项目名称:picard,代码行数:29,代码来源:collection.py
示例18: fetch_username
def fetch_username(self, callback):
log.debug("OAuth: fetching username")
host, port = config.setting['server_host'], config.setting['server_port']
path = "/oauth2/userinfo"
self.xmlws.get(host, port, path,
partial(self.on_fetch_username_finished, callback),
xml=False, mblogin=True, priority=True, important=True)
开发者ID:jinjian1991,项目名称:picard,代码行数:7,代码来源:oauth.py
示例19: _handle_redirect
def _handle_redirect(self, reply, request, redirect):
url = request.url()
error = int(reply.error())
# merge with base url (to cover the possibility of the URL being relative)
redirect = url.resolved(redirect)
if not WebService.urls_equivalent(redirect, reply.request().url()):
log.debug("Redirect to %s requested", redirect.toString(QUrl.RemoveUserInfo))
redirect_host = string_(redirect.host())
redirect_port = self.url_port(redirect)
redirect_query = dict(QUrlQuery(redirect).queryItems(QUrl.FullyEncoded))
redirect_path = redirect.path()
original_host = string_(url.host())
original_port = self.url_port(url)
original_host_key = (original_host, original_port)
redirect_host_key = (redirect_host, redirect_port)
if (original_host_key in REQUEST_DELAY_MINIMUM
and redirect_host_key not in REQUEST_DELAY_MINIMUM):
log.debug("Setting the minimum rate limit for %s to %i" %
(redirect_host_key, REQUEST_DELAY_MINIMUM[original_host_key]))
REQUEST_DELAY_MINIMUM[redirect_host_key] = REQUEST_DELAY_MINIMUM[original_host_key]
self.get(redirect_host,
redirect_port,
redirect_path,
request.handler, request.parse_response_type, priority=True, important=True,
refresh=request.refresh, queryargs=redirect_query,
cacheloadcontrol=request.attribute(QtNetwork.QNetworkRequest.CacheLoadControlAttribute))
else:
log.error("Redirect loop: %s",
reply.request().url().toString(QUrl.RemoveUserInfo)
)
request.handler(reply.readAll(), reply, error)
开发者ID:Sophist-UK,项目名称:Sophist_picard,代码行数:33,代码来源:__init__.py
示例20: _start_request
def _start_request(self, method, host, port, path, data, handler, xml,
mblogin=False, cacheloadcontrol=None, refresh=None):
if mblogin and host in MUSICBRAINZ_SERVERS and port == 80:
urlstring = "https://%s%s" % (host, path)
else:
urlstring = "http://%s:%d%s" % (host, port, path)
log.debug("%s %s", method, urlstring)
url = QUrl.fromEncoded(urlstring)
if mblogin:
url.setUserName(config.setting["username"])
url.setPassword(config.setting["password"])
request = QtNetwork.QNetworkRequest(url)
if mblogin or (method == "GET" and refresh):
request.setPriority(QtNetwork.QNetworkRequest.HighPriority)
request.setAttribute(QtNetwork.QNetworkRequest.CacheLoadControlAttribute,
QtNetwork.QNetworkRequest.AlwaysNetwork)
elif method == "PUT" or method == "DELETE":
request.setPriority(QtNetwork.QNetworkRequest.HighPriority)
elif cacheloadcontrol is not None:
request.setAttribute(QtNetwork.QNetworkRequest.CacheLoadControlAttribute,
cacheloadcontrol)
request.setRawHeader("User-Agent", USER_AGENT_STRING)
if xml:
request.setRawHeader("Accept", "application/xml")
if data is not None:
if method == "POST" and host == config.setting["server_host"]:
request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/xml; charset=utf-8")
else:
request.setHeader(QtNetwork.QNetworkRequest.ContentTypeHeader, "application/x-www-form-urlencoded")
send = self._request_methods[method]
reply = send(request, data) if data is not None else send(request)
key = (host, port)
self._last_request_times[key] = time.time()
self._active_requests[reply] = (request, handler, xml, refresh)
return True
开发者ID:endthestart,项目名称:picard,代码行数:35,代码来源:webservice.py
注:本文中的picard.log.debug函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论