2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/e786022dc67e/ Changeset: e786022dc67e User: jmchilton Date: 2013-10-16 20:01:15 Summary: Improved handling of tools producing unicode in standard error/output. Without this change (modification on idea by Bjoern), sqlite reports errors as follows for such tools: ProgrammingError: (ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings. u'UPDATE job SET update_time=?, stdout=?, stderr=? WHERE job.id = ?' ('2013-10-10 05:00:05.789309', '', '/dev/fd/2 unicode \xc3\xaa\xe0\xaf\xb3\xe0\xbe\x85\xe1\x9d\xb1\xe3\x8e\xb0\n', 11). Affected #: 1 file diff -r 1c22e43fc21e049da34af60f603f2e19bde912d2 -r e786022dc67ed918050bd81b9ac679ac958e4f75 lib/galaxy/jobs/__init__.py --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -25,6 +25,7 @@ from galaxy.util.bunch import Bunch from galaxy.util.expressions import ExpressionContext from galaxy.util.json import from_json_string +from galaxy.util import unicodify from .output_checker import check_output log = logging.getLogger( __name__ ) @@ -869,6 +870,9 @@ the output datasets based on stderr and stdout from the command, and the contents of the output files. """ + stdout = unicodify( stdout ) + stderr = unicodify( stderr ) + # default post job setup self.sa_session.expunge_all() job = self.get_job() @@ -1518,6 +1522,9 @@ the output datasets based on stderr and stdout from the command, and the contents of the output files. """ + stdout = unicodify( stdout ) + stderr = unicodify( stderr ) + # This may have ended too soon log.debug( 'task %s for job %d ended; exit code: %d' % (self.task_id, self.job_id, https://bitbucket.org/galaxy/galaxy-central/commits/00764f2c46df/ Changeset: 00764f2c46df User: jmchilton Date: 2013-10-16 20:01:15 Summary: Improved handling of tools producing unicode in stardard error/output. Without this modification paste cannot render the stderr and/or stdout of such tools. This is a modification on an idea from Simon Guest, utilizing some code (now available as galaxy.util.smart_str) from an older version of Django to solve this problem. Affected #: 2 files diff -r e786022dc67ed918050bd81b9ac679ac958e4f75 -r 00764f2c46dff45f208e22203c6498777725bba7 lib/galaxy/util/__init__.py --- a/lib/galaxy/util/__init__.py +++ b/lib/galaxy/util/__init__.py @@ -547,6 +547,30 @@ except: return default + +def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'): + """ + Returns a bytestring version of 's', encoded as specified in 'encoding'. + + If strings_only is True, don't convert (some) non-string-like objects. + + Adapted from an older, simpler version of django.utils.encoding.smart_str. + """ + if strings_only and isinstance(s, (type(None), int)): + return s + if not isinstance(s, basestring): + try: + return str(s) + except UnicodeEncodeError: + return unicode(s).encode(encoding, errors) + elif isinstance(s, unicode): + return s.encode(encoding, errors) + elif s and encoding != 'utf-8': + return s.decode('utf-8', errors).encode(encoding, errors) + else: + return s + + def object_to_string( obj ): return binascii.hexlify( pickle.dumps( obj, 2 ) ) diff -r e786022dc67ed918050bd81b9ac679ac958e4f75 -r 00764f2c46dff45f208e22203c6498777725bba7 lib/galaxy/webapps/galaxy/controllers/dataset.py --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -8,7 +8,7 @@ from galaxy import datatypes, eggs, model, util, web from galaxy.datatypes.display_applications.util import decode_dataset_user, encode_dataset_user from galaxy.model.item_attrs import UsesAnnotations, UsesItemRatings -from galaxy.util import inflector +from galaxy.util import inflector, smart_str from galaxy.util.sanitize_html import sanitize_html from galaxy.web.base.controller import BaseUIController, ERROR, SUCCESS, url_for, UsesHistoryDatasetAssociationMixin, UsesHistoryMixin from galaxy.web.framework.helpers import grids, iff, time_ago @@ -184,7 +184,7 @@ stdout = job.stdout except: stdout = "Invalid dataset ID or you are not allowed to access this dataset" - return stdout + return smart_str( stdout ) @web.expose # TODO: Migrate stderr and stdout to use _get_job_for_dataset; it wasn't tested. @@ -196,7 +196,7 @@ stderr = job.stderr except: stderr = "Invalid dataset ID or you are not allowed to access this dataset" - return stderr + return smart_str( stderr ) @web.expose def exit_code( self, trans, dataset_id=None, **kwargs ): Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.