1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/e844d6edf929/ changeset: r5198:e844d6edf929 user: rc date: 2011-03-08 20:08:07 summary: Added the postgres9 json sniffnfix method to the migration script instead of importing it from custom_types.py affected #: 1 file (319 bytes) --- a/lib/galaxy/model/migrate/versions/0076_fix_form_values_data_corruption.py Tue Mar 08 12:42:26 2011 -0500 +++ b/lib/galaxy/model/migrate/versions/0076_fix_form_values_data_corruption.py Tue Mar 08 14:08:07 2011 -0500 @@ -9,7 +9,6 @@ from sqlalchemy.exc import * from galaxy.util.json import from_json_string, to_json_string -from galaxy.model.custom_types import _sniffnfix_pg9_hex import logging log = logging.getLogger( __name__ ) @@ -17,6 +16,18 @@ metadata = MetaData( migrate_engine ) db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) +def _sniffnfix_pg9_hex(value): + """ + Sniff for and fix postgres 9 hex decoding issue + + """ + try: + if value[0] == 'x': + return binascii.unhexlify(value[1:]) + else: + return value + except Exception, ex: + return value def upgrade(): print __doc__ @@ -32,7 +43,7 @@ # first check if loading the dict from the json succeeds # if that fails, it means that the content field is corrupted. try: - field_values_dict = from_json_string( str( row['field_values'] ) ) + field_values_dict = from_json_string( _sniffnfix_pg9_hex( str( row['field_values'] ) ) ) except Exception, e: corrupted_rows = corrupted_rows + 1 # content field is corrupted @@ -72,7 +83,10 @@ json_values = to_json_string(field_values_dict) cmd = "UPDATE form_values SET content='%s' WHERE id=%i" %( json_values, int( row['id'] ) ) db_session.execute( cmd ) - print 'Fixed %i corrupted rows.' % corrupted_rows + if corrupted_rows: + print 'Fixed %i corrupted rows.' % corrupted_rows + else: + print 'No corrupted rows found.' def downgrade(): pass \ No newline at end of file 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.