GNOME Bugzilla – Bug 752650
validate:launcher: catch errors and continue
Last modified: 2015-08-16 13:41:27 UTC
when the file name consists of invalid characters, it exits with exception Instead of exiting, print the error and continue executing the next scenario
Created attachment 307790 [details] [review] catch errors and continue
Review of attachment 307790 [details] [review]: ::: validate/launcher/baseclasses.py @@ +35,3 @@ from loggable import Loggable import xml.etree.cElementTree as ET +import sre_compile That would be from sre_compile import error @@ +1376,3 @@ + if re.findall("%s\..*\.%s$" % (mfile_bname, self.FILE_EXTENSION), f): + scenarios.append(os.path.join(os.path.dirname(mfile), f)) + except error, v: What kind of error do you get?
Created attachment 307819 [details] [review] catch errors and continue There was a file which was named in the format [A-B].mp3, which was throwing an error "bad character range".
Created attachment 307820 [details] [review] catch errors and continue forgot to obsolete the previous patch.. for file name in the format [A-B].mp3, got the exception "bad character range", because of which it just exits without doing anything
(In reply to Vineeth from comment #4) > Created attachment 307820 [details] [review] [review] > catch errors and continue > > forgot to obsolete the previous patch.. > > for file name in the format [A-B].mp3, got the exception "bad character > range", because of which it just exits without doing anything Then it sounds like the wrong solution, we should probably run probably escape those char to run the regex on or something
did some experimentation with different file names. It does not directly throw error for [a-b].mp3 format.. it is weird actually, the first digit should be greater than the second digit. but again it is not straight forward. [2-2].mp3 ok [2-1].mp3 not ok [20-1].mp3 ok [21-1].mp3 ok [22-1].mp3 not ok so this might actually be some problem with how re.findall is implemented. Not sure what character to escape here. And even if we remove some characters and pass, the check in the above patch might be useful, because right now, it just stops executing after an error.
should be something like: re.findall("%s\..*\.%s$" % (re.escape(mfile_bname), self.FILE_EXTENSION), f):
Created attachment 307876 [details] [review] call escape to remove bad character range
Review of attachment 307876 [details] [review]: Yop
Comment on attachment 307876 [details] [review] call escape to remove bad character range commit 94c684d4010032947a29a1d0901f1f5014afe500 Author: Vineeth TM <vineeth.tm@samsung.com> Date: Wed Jul 22 08:45:26 2015 +0900 validate:launcher: escape the characters to remove bad range in regex When media file name consists of some special characters of the format [b-a].mp3, then it fails with 'bad character range' error and exits. call re.escape to escape the characters before using it in findall https://bugzilla.gnome.org/show_bug.cgi?id=752650