mirror of
https://github.com/fergalmoran/picard.git
synced 2025-12-22 17:28:58 +00:00
Nuke QVariant, QString in favor of Python types
This commit is contained in:
@@ -22,7 +22,7 @@ import re
|
||||
|
||||
PICARD_APP_NAME = "Picard"
|
||||
PICARD_ORG_NAME = "MusicBrainz"
|
||||
PICARD_VERSION = (1, 3, 0, 'dev', 2)
|
||||
PICARD_VERSION = (1, 3, 0, 'dev', 3)
|
||||
|
||||
|
||||
class VersionError(Exception):
|
||||
|
||||
@@ -139,10 +139,10 @@ class AcoustIDClient(QtCore.QObject):
|
||||
|
||||
def _on_fpcalc_finished(self, next, file, exit_code, exit_status):
|
||||
process = self.sender()
|
||||
finished = process.property('picard_finished').toBool()
|
||||
finished = process.property('picard_finished')
|
||||
if finished:
|
||||
return
|
||||
process.setProperty('picard_finished', QtCore.QVariant(True))
|
||||
process.setProperty('picard_finished', True)
|
||||
result = None
|
||||
try:
|
||||
self._running -= 1
|
||||
@@ -172,7 +172,7 @@ class AcoustIDClient(QtCore.QObject):
|
||||
finished = process.property('picard_finished').toBool()
|
||||
if finished:
|
||||
return
|
||||
process.setProperty('picard_finished', QtCore.QVariant(True))
|
||||
process.setProperty('picard_finished', True)
|
||||
try:
|
||||
self._running -= 1
|
||||
self._run_next_task()
|
||||
@@ -188,7 +188,7 @@ class AcoustIDClient(QtCore.QObject):
|
||||
fpcalc = config.setting["acoustid_fpcalc"] or "fpcalc"
|
||||
self._running += 1
|
||||
process = QtCore.QProcess(self)
|
||||
process.setProperty('picard_finished', QtCore.QVariant(False))
|
||||
process.setProperty('picard_finished', False)
|
||||
process.finished.connect(partial(self._on_fpcalc_finished, next, file))
|
||||
process.error.connect(partial(self._on_fpcalc_error, next, file))
|
||||
process.start(fpcalc, ["-length", "120", file.filename])
|
||||
|
||||
@@ -55,8 +55,7 @@ class ConfigSection(LockableObject):
|
||||
def __setitem__(self, name, value):
|
||||
self.lock_for_write()
|
||||
try:
|
||||
self.__config.setValue("%s/%s" % (self.__name, name),
|
||||
QtCore.QVariant(value))
|
||||
self.__config.setValue("%s/%s" % (self.__name, name), value)
|
||||
finally:
|
||||
self.unlock()
|
||||
|
||||
@@ -178,9 +177,7 @@ class TextOption(Option):
|
||||
"""Option with a text value."""
|
||||
|
||||
def __init__(self, section, name, default):
|
||||
def convert(value):
|
||||
return unicode(value.toString())
|
||||
Option.__init__(self, section, name, default, convert)
|
||||
Option.__init__(self, section, name, default, unicode)
|
||||
|
||||
|
||||
class BoolOption(Option):
|
||||
@@ -188,7 +185,7 @@ class BoolOption(Option):
|
||||
"""Option with a boolean value."""
|
||||
|
||||
def __init__(self, section, name, default):
|
||||
Option.__init__(self, section, name, default, QtCore.QVariant.toBool)
|
||||
Option.__init__(self, section, name, default, bool)
|
||||
|
||||
|
||||
class IntOption(Option):
|
||||
@@ -196,9 +193,7 @@ class IntOption(Option):
|
||||
"""Option with an integer value."""
|
||||
|
||||
def __init__(self, section, name, default):
|
||||
def convert(value):
|
||||
return value.toInt()[0]
|
||||
Option.__init__(self, section, name, default, convert)
|
||||
Option.__init__(self, section, name, default, int)
|
||||
|
||||
|
||||
class FloatOption(Option):
|
||||
@@ -206,9 +201,7 @@ class FloatOption(Option):
|
||||
"""Option with a float value."""
|
||||
|
||||
def __init__(self, section, name, default):
|
||||
def convert(value):
|
||||
return value.toDouble()[0]
|
||||
Option.__init__(self, section, name, default, convert)
|
||||
Option.__init__(self, section, name, default, float)
|
||||
|
||||
|
||||
class PasswordOption(Option):
|
||||
@@ -216,9 +209,15 @@ class PasswordOption(Option):
|
||||
"""Super l33t h3ckery!"""
|
||||
|
||||
def __init__(self, section, name, default):
|
||||
def convert(value):
|
||||
return rot13(unicode(value.toString()))
|
||||
Option.__init__(self, section, name, default, convert)
|
||||
Option.__init__(self, section, name, default, rot13)
|
||||
|
||||
|
||||
class ListOption(Option):
|
||||
|
||||
"""Option with a list of values."""
|
||||
|
||||
def __init__(self, section, name, default):
|
||||
Option.__init__(self, section, name, default, list)
|
||||
|
||||
|
||||
_config = Config()
|
||||
|
||||
@@ -43,16 +43,15 @@ def upgrade_to_v1_0_0_final_0():
|
||||
_s["file_naming_format"] = (
|
||||
"$if($eq(%%compilation%%,1),\n$noop(Various Artist "
|
||||
"albums)\n%s,\n$noop(Single Artist Albums)\n%s)" % (
|
||||
_s["va_file_naming_format"].toString(),
|
||||
_s["va_file_naming_format"],
|
||||
_s["file_naming_format"]
|
||||
))
|
||||
_s.remove("va_file_naming_format")
|
||||
_s.remove("use_va_format")
|
||||
|
||||
if ("va_file_naming_format" in _s and
|
||||
"use_va_format" in _s):
|
||||
|
||||
if ("va_file_naming_format" in _s and "use_va_format" in _s):
|
||||
msgbox = QtGui.QMessageBox()
|
||||
|
||||
if _s["use_va_format"].toBool():
|
||||
remove_va_file_naming_format()
|
||||
msgbox.information(msgbox,
|
||||
@@ -63,7 +62,7 @@ def upgrade_to_v1_0_0_final_0():
|
||||
"merged with that of single artist albums."),
|
||||
QtGui.QMessageBox.Ok)
|
||||
|
||||
elif (_s["va_file_naming_format"].toString() !=
|
||||
elif (_s["va_file_naming_format"] !=
|
||||
r"$if2(%albumartist%,%artist%)/%album%/$if($gt(%totaldis"
|
||||
"cs%,1),%discnumber%-,)$num(%tracknumber%,2) %artist% - "
|
||||
"%title%"):
|
||||
@@ -102,9 +101,20 @@ def upgrade_to_v1_3_0_dev_2():
|
||||
'comma instead of spaces as tag separator (PICARD-536).'))
|
||||
|
||||
|
||||
def upgrade_to_v1_3_0_dev_3():
|
||||
_s["preferred_release_countries"] = \
|
||||
_s["preferred_release_countries"].split(" ")
|
||||
|
||||
_s["preferred_release_formats"] = \
|
||||
_s["preferred_release_formats"].split(" ")
|
||||
|
||||
_s["enabled_plugins"] = _s["enabled_plugins"].split()
|
||||
|
||||
|
||||
def upgrade_config():
|
||||
cfg = config._config
|
||||
cfg.register_upgrade_hook(upgrade_to_v1_0_0_final_0)
|
||||
cfg.register_upgrade_hook(upgrade_to_v1_3_0_dev_1)
|
||||
cfg.register_upgrade_hook(upgrade_to_v1_3_0_dev_2)
|
||||
cfg.register_upgrade_hook(upgrade_to_v1_3_0_dev_3)
|
||||
cfg.run_upgrade_hooks()
|
||||
|
||||
@@ -141,8 +141,8 @@ class Metadata(dict):
|
||||
parts.append((score, weights["totaltracks"]))
|
||||
total += weights["totaltracks"]
|
||||
|
||||
preferred_countries = config.setting["preferred_release_countries"].split(" ")
|
||||
preferred_formats = config.setting["preferred_release_formats"].split(" ")
|
||||
preferred_countries = config.setting["preferred_release_countries"]
|
||||
preferred_formats = config.setting["preferred_release_formats"]
|
||||
|
||||
total_countries = len(preferred_countries)
|
||||
if total_countries:
|
||||
|
||||
@@ -71,7 +71,7 @@ class ExtensionPoint(object):
|
||||
self.__items = filter(lambda i: i[0] != name, self.__items)
|
||||
|
||||
def __iter__(self):
|
||||
enabled_plugins = config.setting["enabled_plugins"].split()
|
||||
enabled_plugins = config.setting["enabled_plugins"]
|
||||
for module, item in self.__items:
|
||||
if module is None or module in enabled_plugins:
|
||||
yield item
|
||||
|
||||
@@ -47,7 +47,7 @@ class CDLookupDialog(QtGui.QDialog):
|
||||
item.setText(4, ", ".join(labels))
|
||||
item.setText(5, ", ".join(catalog_numbers))
|
||||
item.setText(6, barcode)
|
||||
item.setData(0, QtCore.Qt.UserRole, QtCore.QVariant(release.id))
|
||||
item.setData(0, QtCore.Qt.UserRole, release.id)
|
||||
self.ui.release_list.setCurrentItem(self.ui.release_list.topLevelItem(0))
|
||||
self.ui.ok_button.setEnabled(True)
|
||||
for i in range(self.ui.release_list.columnCount() - 1):
|
||||
@@ -58,7 +58,7 @@ class CDLookupDialog(QtGui.QDialog):
|
||||
self.ui.lookup_button.clicked.connect(self.lookup)
|
||||
|
||||
def accept(self):
|
||||
release_id = str(self.ui.release_list.currentItem().data(0, QtCore.Qt.UserRole).toString())
|
||||
release_id = self.ui.release_list.currentItem().data(0, QtCore.Qt.UserRole)
|
||||
self.tagger.load_album(release_id, discid=self.disc.id)
|
||||
QtGui.QDialog.accept(self)
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class CoverArtBox(QtGui.QGroupBox):
|
||||
self.load_remote_image(mime, data)
|
||||
|
||||
def on_remote_image_fetched(self, data, reply, error):
|
||||
mime = str(reply.header(QtNetwork.QNetworkRequest.ContentTypeHeader).toString())
|
||||
mime = reply.header(QtNetwork.QNetworkRequest.ContentTypeHeader)
|
||||
if mime not in ('image/jpeg', 'image/png'):
|
||||
log.warning("Can't load image with MIME-Type %s", mime)
|
||||
return
|
||||
|
||||
@@ -87,7 +87,7 @@ def get_match_color(similarity, basecolor):
|
||||
class MainPanel(QtGui.QSplitter):
|
||||
|
||||
options = [
|
||||
config.Option("persist", "splitter_state", QtCore.QByteArray(), QtCore.QVariant.toByteArray),
|
||||
config.Option("persist", "splitter_state", QtCore.QByteArray()),
|
||||
]
|
||||
|
||||
columns = [
|
||||
@@ -202,10 +202,10 @@ class MainPanel(QtGui.QSplitter):
|
||||
class BaseTreeView(QtGui.QTreeWidget):
|
||||
|
||||
options = [
|
||||
config.Option("setting", "color_modified", QtGui.QColor(QtGui.QPalette.WindowText), QtGui.QColor),
|
||||
config.Option("setting", "color_saved", QtGui.QColor(0, 128, 0), QtGui.QColor),
|
||||
config.Option("setting", "color_error", QtGui.QColor(200, 0, 0), QtGui.QColor),
|
||||
config.Option("setting", "color_pending", QtGui.QColor(128, 128, 128), QtGui.QColor),
|
||||
config.Option("setting", "color_modified", QtGui.QColor(QtGui.QPalette.WindowText)),
|
||||
config.Option("setting", "color_saved", QtGui.QColor(0, 128, 0)),
|
||||
config.Option("setting", "color_error", QtGui.QColor(200, 0, 0)),
|
||||
config.Option("setting", "color_pending", QtGui.QColor(128, 128, 128)),
|
||||
]
|
||||
|
||||
def __init__(self, window, parent=None):
|
||||
@@ -576,7 +576,7 @@ class TreeItem(QtGui.QTreeWidgetItem):
|
||||
column = self.treeWidget().sortColumn()
|
||||
if column == 1:
|
||||
return (self.obj.metadata.length or 0) < (other.obj.metadata.length or 0)
|
||||
return self.text(column).toLower() < other.text(column).toLower()
|
||||
return self.text(column).lower() < other.text(column).lower()
|
||||
|
||||
|
||||
class ClusterItem(TreeItem):
|
||||
|
||||
@@ -54,14 +54,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||
selection_updated = QtCore.pyqtSignal(object)
|
||||
|
||||
options = [
|
||||
config.Option("persist", "window_state", QtCore.QByteArray(),
|
||||
QtCore.QVariant.toByteArray),
|
||||
config.Option("persist", "window_position", QtCore.QPoint(),
|
||||
QtCore.QVariant.toPoint),
|
||||
config.Option("persist", "window_size", QtCore.QSize(780, 560),
|
||||
QtCore.QVariant.toSize),
|
||||
config.Option("persist", "bottom_splitter_state", QtCore.QByteArray(),
|
||||
QtCore.QVariant.toByteArray),
|
||||
config.Option("persist", "window_state", QtCore.QByteArray()),
|
||||
config.Option("persist", "window_position", QtCore.QPoint()),
|
||||
config.Option("persist", "window_size", QtCore.QSize(780, 560)),
|
||||
config.Option("persist", "bottom_splitter_state", QtCore.QByteArray()),
|
||||
config.BoolOption("persist", "window_maximized", False),
|
||||
config.BoolOption("persist", "view_cover_art", False),
|
||||
config.BoolOption("persist", "view_file_browser", False),
|
||||
@@ -545,9 +541,9 @@ class MainWindow(QtGui.QMainWindow):
|
||||
search_panel = QtGui.QWidget(toolbar)
|
||||
hbox = QtGui.QHBoxLayout(search_panel)
|
||||
self.search_combo = QtGui.QComboBox(search_panel)
|
||||
self.search_combo.addItem(_(u"Album"), QtCore.QVariant("album"))
|
||||
self.search_combo.addItem(_(u"Artist"), QtCore.QVariant("artist"))
|
||||
self.search_combo.addItem(_(u"Track"), QtCore.QVariant("track"))
|
||||
self.search_combo.addItem(_(u"Album"), "album")
|
||||
self.search_combo.addItem(_(u"Artist"), "artist")
|
||||
self.search_combo.addItem(_(u"Track"), "track")
|
||||
hbox.addWidget(self.search_combo, 0)
|
||||
self.search_edit = QtGui.QLineEdit(search_panel)
|
||||
self.search_edit.returnPressed.connect(self.search)
|
||||
@@ -594,9 +590,8 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
def search(self):
|
||||
"""Search for album, artist or track on the MusicBrainz website."""
|
||||
text = unicode(self.search_edit.text())
|
||||
type = unicode(self.search_combo.itemData(
|
||||
self.search_combo.currentIndex()).toString())
|
||||
text = self.search_edit.text()
|
||||
type = self.search_combo.itemData(self.search_combo.currentIndex())
|
||||
self.tagger.search(text, type, config.setting["use_adv_search_syntax"])
|
||||
|
||||
def add_files(self):
|
||||
|
||||
@@ -47,9 +47,9 @@ from picard.ui.options import (
|
||||
class OptionsDialog(QtGui.QDialog):
|
||||
|
||||
options = [
|
||||
config.Option("persist", "options_position", QtCore.QPoint(), QtCore.QVariant.toPoint),
|
||||
config.Option("persist", "options_size", QtCore.QSize(560, 400), QtCore.QVariant.toSize),
|
||||
config.Option("persist", "options_splitter", QtCore.QByteArray(), QtCore.QVariant.toByteArray),
|
||||
config.Option("persist", "options_position", QtCore.QPoint()),
|
||||
config.Option("persist", "options_size", QtCore.QSize(560, 400)),
|
||||
config.Option("persist", "options_splitter", QtCore.QByteArray()),
|
||||
]
|
||||
|
||||
def add_pages(self, parent, default_page, parent_item):
|
||||
|
||||
@@ -70,7 +70,7 @@ class FingerprintingOptionsPage(OptionsPage):
|
||||
def update_groupboxes(self):
|
||||
if self.ui.use_acoustid.isChecked():
|
||||
self.ui.acoustid_settings.setEnabled(True)
|
||||
if self.ui.acoustid_fpcalc.text().isEmpty():
|
||||
if not self.ui.acoustid_fpcalc.text():
|
||||
fpcalc_path = find_executable(*FPCALC_NAMES)
|
||||
if fpcalc_path:
|
||||
self.ui.acoustid_fpcalc.setText(fpcalc_path)
|
||||
|
||||
@@ -51,7 +51,7 @@ class InterfaceOptionsPage(OptionsPage):
|
||||
super(InterfaceOptionsPage, self).__init__(parent)
|
||||
self.ui = Ui_InterfaceOptionsPage()
|
||||
self.ui.setupUi(self)
|
||||
self.ui.ui_language.addItem(_('System default'), QtCore.QVariant(''))
|
||||
self.ui.ui_language.addItem(_('System default'), '')
|
||||
language_list = [(l[0], l[1], _(l[2])) for l in UI_LANGUAGES]
|
||||
for lang_code, native, translation in sorted(language_list, key=operator.itemgetter(2),
|
||||
cmp=locale.strcoll):
|
||||
@@ -59,7 +59,7 @@ class InterfaceOptionsPage(OptionsPage):
|
||||
name = u'%s (%s)' % (translation, native)
|
||||
else:
|
||||
name = translation
|
||||
self.ui.ui_language.addItem(name, QtCore.QVariant(lang_code))
|
||||
self.ui.ui_language.addItem(name, lang_code)
|
||||
self.ui.starting_directory.stateChanged.connect(
|
||||
partial(
|
||||
enabledSlot,
|
||||
@@ -79,7 +79,7 @@ class InterfaceOptionsPage(OptionsPage):
|
||||
self.ui.toolbar_multiselect.setChecked(config.setting["toolbar_multiselect"])
|
||||
self.ui.use_adv_search_syntax.setChecked(config.setting["use_adv_search_syntax"])
|
||||
self.ui.quit_confirmation.setChecked(config.setting["quit_confirmation"])
|
||||
current_ui_language = QtCore.QVariant(config.setting["ui_language"])
|
||||
current_ui_language = config.setting["ui_language"]
|
||||
self.ui.ui_language.setCurrentIndex(self.ui.ui_language.findData(current_ui_language))
|
||||
self.ui.starting_directory.setChecked(config.setting["starting_directory"])
|
||||
self.ui.starting_directory_path.setText(config.setting["starting_directory_path"])
|
||||
@@ -90,9 +90,9 @@ class InterfaceOptionsPage(OptionsPage):
|
||||
config.setting["use_adv_search_syntax"] = self.ui.use_adv_search_syntax.isChecked()
|
||||
config.setting["quit_confirmation"] = self.ui.quit_confirmation.isChecked()
|
||||
self.tagger.window.update_toolbar_style()
|
||||
new_language = self.ui.ui_language.itemData(self.ui.ui_language.currentIndex()).toString()
|
||||
new_language = self.ui.ui_language.itemData(self.ui.ui_language.currentIndex())
|
||||
if new_language != config.setting["ui_language"]:
|
||||
config.setting["ui_language"] = self.ui.ui_language.itemData(self.ui.ui_language.currentIndex()).toString()
|
||||
config.setting["ui_language"] = self.ui.ui_language.itemData(self.ui.ui_language.currentIndex())
|
||||
dialog = QtGui.QMessageBox(QtGui.QMessageBox.Information, _('Language changed'), _('You have changed the interface language. You have to restart Picard in order for the change to take effect.'), QtGui.QMessageBox.Ok, self)
|
||||
dialog.exec_()
|
||||
config.setting["starting_directory"] = self.ui.starting_directory.isChecked()
|
||||
|
||||
@@ -41,7 +41,7 @@ class PluginsOptionsPage(OptionsPage):
|
||||
ACTIVE = True
|
||||
|
||||
options = [
|
||||
config.TextOption("setting", "enabled_plugins", ""),
|
||||
config.ListOption("setting", "enabled_plugins", []),
|
||||
]
|
||||
|
||||
def __init__(self, parent=None):
|
||||
@@ -64,7 +64,7 @@ class PluginsOptionsPage(OptionsPage):
|
||||
|
||||
def load(self):
|
||||
plugins = sorted(self.tagger.pluginmanager.plugins, cmp=cmp_plugins)
|
||||
enabled_plugins = config.setting["enabled_plugins"].split()
|
||||
enabled_plugins = config.setting["enabled_plugins"]
|
||||
firstitem = None
|
||||
for plugin in plugins:
|
||||
enabled = plugin.module_name in enabled_plugins
|
||||
@@ -108,7 +108,7 @@ class PluginsOptionsPage(OptionsPage):
|
||||
for item, plugin in self.items.iteritems():
|
||||
if item.checkState(0) == QtCore.Qt.Checked:
|
||||
enabled_plugins.append(plugin.module_name)
|
||||
config.setting["enabled_plugins"] = " ".join(enabled_plugins)
|
||||
config.setting["enabled_plugins"] = enabled_plugins
|
||||
|
||||
def change_details(self):
|
||||
plugin = self.items[self.ui.plugins.selectedItems()[0]]
|
||||
|
||||
@@ -37,8 +37,8 @@ class ReleasesOptionsPage(OptionsPage):
|
||||
|
||||
options = [
|
||||
config.TextOption("setting", "release_type_scores", "Album 0.5 Single 0.5 EP 0.5 Compilation 0.5 Soundtrack 0.5 Spokenword 0.5 Interview 0.5 Audiobook 0.5 Live 0.5 Remix 0.5 Other 0.5"),
|
||||
config.TextOption("setting", "preferred_release_countries", u""),
|
||||
config.TextOption("setting", "preferred_release_formats", u""),
|
||||
config.ListOption("setting", "preferred_release_countries", []),
|
||||
config.ListOption("setting", "preferred_release_formats", []),
|
||||
]
|
||||
|
||||
_release_type_sliders = {}
|
||||
@@ -115,11 +115,11 @@ class ReleasesOptionsPage(OptionsPage):
|
||||
def _load_list_items(self, setting, source, list1, list2):
|
||||
source_list = [(c[0], _(c[1])) for c in source.items()]
|
||||
source_list.sort(key=itemgetter(1), cmp=strcoll)
|
||||
saved_data = config.setting[setting].split(" ")
|
||||
saved_data = config.setting[setting]
|
||||
move = []
|
||||
for data, name in source_list:
|
||||
item = QtGui.QListWidgetItem(name)
|
||||
item.setData(QtCore.Qt.UserRole, QtCore.QVariant(data))
|
||||
item.setData(QtCore.Qt.UserRole, data)
|
||||
try:
|
||||
i = saved_data.index(data)
|
||||
move.append((i, item))
|
||||
@@ -133,8 +133,8 @@ class ReleasesOptionsPage(OptionsPage):
|
||||
data = []
|
||||
for i in range(list1.count()):
|
||||
item = list1.item(i)
|
||||
data.append(unicode(item.data(QtCore.Qt.UserRole).toString()))
|
||||
config.setting[setting] = " ".join(data)
|
||||
data.append(unicode(item.data(QtCore.Qt.UserRole)))
|
||||
config.setting[setting] = data
|
||||
|
||||
|
||||
register_options_page(ReleasesOptionsPage)
|
||||
|
||||
@@ -30,8 +30,8 @@ class TagsFromFileNamesDialog(QtGui.QDialog):
|
||||
|
||||
options = [
|
||||
config.TextOption("persist", "tags_from_filenames_format", ""),
|
||||
config.Option("persist", "tags_from_filenames_position", QtCore.QPoint(), QtCore.QVariant.toPoint),
|
||||
config.Option("persist", "tags_from_filenames_size", QtCore.QSize(560, 400), QtCore.QVariant.toSize),
|
||||
config.Option("persist", "tags_from_filenames_position", QtCore.QPoint()),
|
||||
config.Option("persist", "tags_from_filenames_size", QtCore.QSize(560, 400)),
|
||||
]
|
||||
|
||||
def __init__(self, files, parent=None):
|
||||
|
||||
@@ -19,9 +19,10 @@
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
import sys
|
||||
from PyQt4.QtCore import QFile, QRegExp
|
||||
from PyQt4.QtCore import QFile
|
||||
from picard.util import uniqify
|
||||
|
||||
|
||||
DEFAULT_DRIVES = []
|
||||
try:
|
||||
try:
|
||||
@@ -61,7 +62,7 @@ if sys.platform == 'win32':
|
||||
|
||||
elif sys.platform == 'linux2' and QFile.exists(LINUX_CDROM_INFO):
|
||||
AUTO_DETECT_DRIVES = True
|
||||
from PyQt4.QtCore import QIODevice, QString
|
||||
from PyQt4.QtCore import QIODevice
|
||||
|
||||
# Read info from /proc/sys/dev/cdrom/info
|
||||
def get_cdrom_drives():
|
||||
@@ -71,14 +72,14 @@ elif sys.platform == 'linux2' and QFile.exists(LINUX_CDROM_INFO):
|
||||
drive_names = []
|
||||
drive_audio_caps = []
|
||||
line = cdinfo.readLine()
|
||||
while not line.isEmpty():
|
||||
while line:
|
||||
if line.indexOf(':') != -1:
|
||||
key, values = line.split(':')
|
||||
if key == 'drive name':
|
||||
drive_names = QString(values).trimmed().split(QRegExp("\\s+"), QString.SkipEmptyParts)
|
||||
drive_names = values.strip().split()
|
||||
elif key == 'Can play audio':
|
||||
drive_audio_caps = [v == '1' for v in
|
||||
QString(values).trimmed().split(QRegExp("\\s+"), QString.SkipEmptyParts)]
|
||||
values.strip().split()]
|
||||
break # no need to continue passed this line
|
||||
line = cdinfo.readLine()
|
||||
# Show only drives that are capable of playing audio
|
||||
|
||||
@@ -230,13 +230,13 @@ class XmlWebService(QtCore.QObject):
|
||||
log.error("Error: Request not found for %s" % str(reply.request().url().toString()))
|
||||
return
|
||||
error = int(reply.error())
|
||||
redirect = reply.attribute(QtNetwork.QNetworkRequest.RedirectionTargetAttribute).toUrl()
|
||||
fromCache = reply.attribute(QtNetwork.QNetworkRequest.SourceIsFromCacheAttribute).toBool()
|
||||
redirect = reply.attribute(QtNetwork.QNetworkRequest.RedirectionTargetAttribute)
|
||||
fromCache = reply.attribute(QtNetwork.QNetworkRequest.SourceIsFromCacheAttribute)
|
||||
cached = ' (CACHED)' if fromCache else ''
|
||||
log.debug("Received reply for %s: HTTP %d (%s) %s",
|
||||
reply.request().url().toString(),
|
||||
reply.attribute(QtNetwork.QNetworkRequest.HttpStatusCodeAttribute).toInt()[0],
|
||||
reply.attribute(QtNetwork.QNetworkRequest.HttpReasonPhraseAttribute).toString(),
|
||||
reply.attribute(QtNetwork.QNetworkRequest.HttpStatusCodeAttribute),
|
||||
reply.attribute(QtNetwork.QNetworkRequest.HttpReasonPhraseAttribute),
|
||||
cached
|
||||
)
|
||||
if handler is not None:
|
||||
@@ -245,10 +245,10 @@ class XmlWebService(QtCore.QObject):
|
||||
reply.request().url().toString(),
|
||||
reply.errorString(),
|
||||
error,
|
||||
reply.attribute(QtNetwork.QNetworkRequest.HttpStatusCodeAttribute).toInt()[0])
|
||||
reply.attribute(QtNetwork.QNetworkRequest.HttpStatusCodeAttribute))
|
||||
|
||||
# Redirect if found and not infinite
|
||||
if not redirect.isEmpty() and not XmlWebService.urls_equivalent(redirect, reply.request().url()):
|
||||
if redirect and not XmlWebService.urls_equivalent(redirect, reply.request().url()):
|
||||
log.debug("Redirect to %s requested", redirect.toString())
|
||||
redirect_host = str(redirect.host())
|
||||
redirect_port = redirect.port(80)
|
||||
@@ -401,7 +401,7 @@ class XmlWebService(QtCore.QObject):
|
||||
filters.append(('query', ' '.join(query)))
|
||||
params = []
|
||||
for name, value in filters:
|
||||
value = str(QUrl.toPercentEncoding(QtCore.QString(value)))
|
||||
value = QUrl.toPercentEncoding(unicode(value))
|
||||
params.append('%s=%s' % (str(name), value))
|
||||
path = "/ws/2/%s/?%s" % (entitytype, "&".join(params))
|
||||
return self.get(host, port, path, handler)
|
||||
|
||||
Reference in New Issue
Block a user