From fdc905b0aa8fabb7f8ed5a349f48ae5ebee57e9b Mon Sep 17 00:00:00 2001 From: Sophist Date: Fri, 27 Jan 2017 20:29:18 +0000 Subject: [PATCH 1/3] PICARD-958: Avoid dir/file name unicode errors Resolves [PICARD-958](https://tickets.metabrainz.org/browse/PICARD-958). When dir or file names contain unicode characters and debug logging is on, then debug.log statements which use %s placeholders cause the following error: ``` Traceback (most recent call last): File ".\picard\tagger.py", line 315, in event event.run() File ".\picard\util\thread.py", line 34, in run self.func(*self.args, **self.kwargs) File ".\picard\log.py", line 116, in _stderr_receiver sys.stderr.write(formatted_log_line(level, time, msg + os.linesep)) File "C:\Program Files (x86)\Python2\lib\encodings\cp850.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode character u'\u2010' in position 77: character maps to ``` --- picard/tagger.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/picard/tagger.py b/picard/tagger.py index eb013eada..3e36ad40f 100644 --- a/picard/tagger.py +++ b/picard/tagger.py @@ -151,7 +151,7 @@ class Tagger(QtGui.QApplication): log.debug("Platform: %s %s %s", platform.platform(), platform.python_implementation(), platform.python_version()) log.debug("Versions: %s", versions.as_string()) - log.debug("Configuration file path: %s", config.config.fileName()) + log.debug("Configuration file path: %r", config.config.fileName()) # TODO remove this before the final release if sys.platform == "win32": @@ -160,12 +160,12 @@ class Tagger(QtGui.QApplication): olduserdir = "~/.picard" olduserdir = os.path.expanduser(olduserdir) if os.path.isdir(olduserdir): - log.info("Moving %s to %s", olduserdir, USER_DIR) + log.info("Moving %r to %r", olduserdir, USER_DIR) try: shutil.move(olduserdir, USER_DIR) except: pass - log.debug("User directory: %s", os.path.abspath(USER_DIR)) + log.debug("User directory: %r", os.path.abspath(USER_DIR)) # for compatibility with pre-1.3 plugins QtCore.QObject.tagger = self @@ -356,10 +356,10 @@ class Tagger(QtGui.QApplication): for filename in filenames: filename = os.path.normpath(os.path.realpath(filename)) if ignore_hidden and is_hidden(filename): - log.debug("File ignored (hidden): %s" % (filename)) + log.debug("File ignored (hidden): %r" % (filename)) continue if ignoreregex is not None and ignoreregex.search(filename): - log.info("File ignored (matching %s): %s" % (pattern, filename)) + log.info("File ignored (matching %r): %r" % (pattern, filename)) continue if filename not in self.files: file = open_file(filename) @@ -399,7 +399,7 @@ class Tagger(QtGui.QApplication): 'count': number_of_files, 'directory': root, } - log.debug("Adding %(count)d files from '%(directory)s'" % + log.debug("Adding %(count)d files from '%(directory)r'" % mparms) self.window.set_statusbar_message( ungettext( @@ -432,7 +432,7 @@ class Tagger(QtGui.QApplication): 'count': number_of_files, 'directory': path, } - log.debug("Adding %(count)d files from '%(directory)s'" % + log.debug("Adding %(count)d files from '%(directory)r'" % mparms) self.window.set_statusbar_message( ungettext( From 0180d0cf4111d03e932d66fef3501e0b62cafe56 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Sat, 28 Jan 2017 11:28:42 +0100 Subject: [PATCH 2/3] Drop os.path.realpath(), partly reverting PR 599 See discussion at https://github.com/metabrainz/picard/pull/599/files/d5f3ca366518dde825f4d8c724f0a5a69ffc25b4#r98327865 --- picard/ui/mainwindow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/picard/ui/mainwindow.py b/picard/ui/mainwindow.py index 133367036..c4d9c1f8a 100644 --- a/picard/ui/mainwindow.py +++ b/picard/ui/mainwindow.py @@ -799,7 +799,7 @@ class MainWindow(QtGui.QMainWindow): def open_folder(self): files = self.tagger.get_files_from_objects(self.selected_objects) - folders = set([os.path.realpath(os.path.dirname(f.filename)) for f in files]) + folders = set([os.path.dirname(f.filename) for f in files]) for folder in folders: QtGui.QDesktopServices.openUrl(self._openUrl(folder)) From ffcbbec156b180055d419bd558edf950e1a6ae7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Lalinsk=C3=BD?= Date: Sun, 29 Jan 2017 13:13:38 +0100 Subject: [PATCH 3/3] Use python-discid 1.1.1 --- .gitlab-ci.yml | 2 +- scripts/package-osx.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b099d624d..49d40eb11 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: variables: CHROMAPRINT_FPCALC_VERSION: "1.4.2" DISCID_VERSION: "0.6.1" - PYTHON_DISCID_VERSION: "1.1.0" + PYTHON_DISCID_VERSION: "1.1.1" MUTAGEN_VERSION: "1.36" package win: diff --git a/scripts/package-osx.sh b/scripts/package-osx.sh index e07fc7690..be230e8e1 100644 --- a/scripts/package-osx.sh +++ b/scripts/package-osx.sh @@ -15,7 +15,7 @@ virtualenv -p python2.7 --system-site-packages e . e/bin/activate pip install mutagen==$MUTAGEN_VERSION -pip install https://github.com/JonnyJD/python-discid/archive/dmg.zip # XXX can't use $PYTHON_DISCID_VERSION +pip install discid==$PYTHON_DISCID_VERSION pip install py2app perl -pi -e 's{plugin_dir = (.*)$}{plugin_dir = "/Developer/Applications/Qt/plugins"}' e/lib/python2.7/site-packages/py2app/recipes/sip.py