commit/galaxy-central: nsoranzo: Fix SQlite datatype sniffing for old sqlite3. Remove unused imports.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/03e9b373ec42/ Changeset: 03e9b373ec42 User: nsoranzo Date: 2014-08-28 15:09:10 Summary: Fix SQlite datatype sniffing for old sqlite3. Remove unused imports. Bug fixed: when uploading a gzipped FASTQ file through upload1 tool on a machine with SQLite 3.3.6, it was detected as 'sqlite' datatype and not decompressed. In fact, the sqlite3 command 'pragma schema_version' on any file returns without error on this SQLite version. Affected #: 1 file diff -r 59b6f95bfdd51bcf6c7da17fb9ad2fd4ad7f3133 -r 03e9b373ec42cf727a5d735876f55ab442f73310 lib/galaxy/datatypes/binary.py --- a/lib/galaxy/datatypes/binary.py +++ b/lib/galaxy/datatypes/binary.py @@ -11,10 +11,7 @@ import struct import subprocess import tempfile -import zipfile -import sqlite3 -from urllib import urlencode, quote_plus from galaxy import eggs eggs.require( "bx-python" ) @@ -22,7 +19,6 @@ from galaxy.datatypes.metadata import MetadataElement,ListParameter,DictParameter from galaxy.datatypes import metadata -from galaxy.datatypes.sniff import * import dataproviders log = logging.getLogger(__name__) @@ -580,14 +576,12 @@ except Exception, exc: pass - # Connects and runs a query that should work on any real database - # If the file is not sqlite, an exception will be thrown and the sniffer will return false def sniff( self, filename ): + # The first 16 bytes of any SQLite3 database file is 'SQLite format 3\0', and the file is binary. For details + # about the format, see http://www.sqlite.org/fileformat.html try: - conn = sqlite3.connect(filename) - schema_version=conn.cursor().execute("pragma schema_version").fetchone() - conn.close() - if schema_version is not None: + header = open(filename).read(16) + if binascii.b2a_hex(header) == binascii.hexlify('SQLite format 3\0'): return True return False except: @@ -622,5 +616,5 @@ return dataproviders.dataset.SQliteDataProvider( dataset_source, **settings ) -Binary.register_sniffable_binary_format("sqlite","sqlite",SQlite) +Binary.register_sniffable_binary_format("sqlite", "sqlite", SQlite) 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.
participants (1)
-
commits-noreply@bitbucket.org