Example #1
0
 def spatialite_version_tuple(self):
     """
     Return the SpatiaLite version as a tuple (version string, major,
     minor, subminor).
     """
     version = self.spatialite_version()
     return (version,) + get_version_tuple(version)
Example #2
0
 def spatialite_version_tuple(self):
     """
     Return the SpatiaLite version as a tuple (version string, major,
     minor, subminor).
     """
     version = self.spatialite_version()
     return (version, ) + get_version_tuple(version)
Example #3
0
 def postgis_version_tuple(self):
     """
     Return the PostGIS version as a tuple (version string, major,
     minor, subminor).
     """
     version = self.postgis_lib_version()
     return (version, ) + get_version_tuple(version)
Example #4
0
 def postgis_version_tuple(self):
     """
     Return the PostGIS version as a tuple (version string, major,
     minor, subminor).
     """
     version = self.postgis_lib_version()
     return (version,) + get_version_tuple(version)
Example #5
0
def replace_javascript():
    """Check if we need to strip out 'text/javascript' bits"""
    # This is a bit of a hack, but I don't have an elegant way
    # of dealing with the change between Django 3.0 and 3.1 here
    djversion = get_version_tuple(get_version())
    if djversion[0] > 3 or (djversion[0] == 3 and djversion[1] > 0):
        return True
    return False
Example #6
0
def check_django_compatability():
    """
    Verify that this version of django-spanner is compatible with the installed
    version of Django. For example, any django-spanner 2.2.x is compatible
    with Django 2.2.y.
    """
    from . import __version__

    if django.VERSION[:2] != get_version_tuple(__version__)[:2]:
        raise ImproperlyConfigured(
            "You must use the latest version of django-spanner {A}.{B}.x "
            "with Django {A}.{B}.y (found django-spanner {C}).".format(
                A=django.VERSION[0], B=django.VERSION[1], C=__version__))
Example #7
0
 def check_availability(cls):
     if not pywatchman:
         raise WatchmanUnavailable('pywatchman not installed.')
     client = pywatchman.client(timeout=0.1)
     try:
         result = client.capabilityCheck()
     except Exception:
         # The service is down?
         raise WatchmanUnavailable('Cannot connect to the watchman service.')
     version = get_version_tuple(result['version'])
     # Watchman 4.9 includes multiple improvements to watching project
     # directories as well as case insensitive filesystems.
     logger.debug('Watchman version %s', version)
     if version < (4, 9):
         raise WatchmanUnavailable('Watchman 4.9 or later is required.')
 def check_availability(cls):
     if not pywatchman:
         raise WatchmanUnavailable('pywatchman not installed.')
     client = pywatchman.client(timeout=0.1)
     try:
         result = client.capabilityCheck()
     except Exception:
         # The service is down?
         raise WatchmanUnavailable('Cannot connect to the watchman service.')
     version = get_version_tuple(result['version'])
     # Watchman 4.9 includes multiple improvements to watching project
     # directories as well as case insensitive filesystems.
     logger.debug('Watchman version %s', version)
     if version < (4, 9):
         raise WatchmanUnavailable('Watchman 4.9 or later is required.')
Example #9
0
    def init_connection_state(self):
        drv_name = self.connection.getinfo(Database.SQL_DRIVER_NAME).upper()

        if drv_name.startswith('LIBTDSODBC'):
            try:
                drv_ver = self.connection.getinfo(Database.SQL_DRIVER_VER)
                ver = get_version_tuple(drv_ver)[:2]
                if ver < (0, 95):
                    raise ImproperlyConfigured(
                        "FreeTDS 0.95 or newer is required.")
            except:
                # unknown driver version
                pass

        ms_drv_names = re.compile('^(LIB)?(SQLNCLI|MSODBCSQL)')

        if ms_drv_names.match(drv_name):
            self.driver_charset = None
            # http://msdn.microsoft.com/en-us/library/ms131686.aspx
            self.supports_mars = True
            self.features.can_use_chunked_reads = True

        settings_dict = self.settings_dict
        cursor = self.create_cursor()

        options = settings_dict.get('OPTIONS', {})
        isolation_level = options.get('isolation_level', None)
        if isolation_level:
            cursor.execute('SET TRANSACTION ISOLATION LEVEL %s' %
                           isolation_level)

        # Set date format for the connection. Also, make sure Sunday is
        # considered the first day of the week (to be consistent with the
        # Django convention for the 'week_day' Django lookup) if the user
        # hasn't told us otherwise
        datefirst = options.get('datefirst', 7)
        cursor.execute('SET DATEFORMAT ymd; SET DATEFIRST %s' % datefirst)

        # http://blogs.msdn.com/b/sqlnativeclient/archive/2008/02/27/microsoft-sql-server-native-client-and-microsoft-sql-server-2008-native-client.aspx
        val = cursor.execute('SELECT SYSDATETIME()').fetchone()[0]
        if isinstance(val, str):
            raise ImproperlyConfigured(
                "The database driver doesn't support modern datatime types.")
Example #10
0
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435

try:
    import psycopg2 as Database
    import psycopg2.extensions
    import psycopg2.extras
except ImportError as e:
    raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)


def psycopg2_version():
    version = psycopg2.__version__.split(' ', 1)[0]
<<<<<<< HEAD
    return tuple(int(v) for v in version.split('.') if v.isdigit())
=======
    return get_version_tuple(version)
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435


PSYCOPG2_VERSION = psycopg2_version()

if PSYCOPG2_VERSION < (2, 5, 4):
    raise ImproperlyConfigured("psycopg2_version 2.5.4 or newer is required; you have %s" % psycopg2.__version__)


# Some of these import psycopg2, so import them after checking if it's installed.
from .client import DatabaseClient                          # NOQA isort:skip
from .creation import DatabaseCreation                      # NOQA isort:skip
from .features import DatabaseFeatures                      # NOQA isort:skip
from .introspection import DatabaseIntrospection            # NOQA isort:skip
from .operations import DatabaseOperations                  # NOQA isort:skip
Example #11
0
def geos_version_tuple():
    """Return the GEOS version as a tuple (major, minor, subminor)."""
    return get_version_tuple(geos_version_info()['version'])
Example #12
0
def geos_version_tuple():
    """Return the GEOS version as a tuple (major, minor, subminor)."""
    return get_version_tuple(geos_version().decode())
Example #13
0
def geos_version_tuple():
    """Return the GEOS version as a tuple (major, minor, subminor)."""
    return get_version_tuple(geos_version().decode())
Example #14
0
 def test_get_version_tuple(self):
     self.assertEqual(get_version_tuple('1.2.3'), (1, 2, 3))
     self.assertEqual(get_version_tuple('1.2.3b2'), (1, 2, 3))
     self.assertEqual(get_version_tuple('1.2.3b2.dev0'), (1, 2, 3))
Example #15
0
def psycopg2_version():
    version = psycopg2.__version__.split(' ', 1)[0]
    return get_version_tuple(version)
Example #16
0
from channels import __version__ as channels_version
from channels.routing import ProtocolTypeRouter, URLRouter
from channels.sessions import SessionMiddlewareStack
from django.utils.version import get_version_tuple
from django.apps import apps
from django.urls import path
from .consumers import GraphQLSubscriptionConsumer

if apps.is_installed("django.contrib.auth"):
    from channels.auth import AuthMiddlewareStack
else:
    AuthMiddlewareStack = None

channels_version_tuple = get_version_tuple(channels_version)

if channels_version_tuple > (3, 0, 0):
    websocket_urlpatterns = [
        path("subscriptions", GraphQLSubscriptionConsumer.as_asgi())
    ]
else:
    websocket_urlpatterns = [
        path("subscriptions", GraphQLSubscriptionConsumer)
    ]

application = ProtocolTypeRouter(
    {"websocket": URLRouter(websocket_urlpatterns)})

session_application = ProtocolTypeRouter(
    {"websocket": SessionMiddlewareStack(URLRouter(websocket_urlpatterns))})

if AuthMiddlewareStack:
Example #17
0
def psycopg2_version():
    version = psycopg2.__version__.split(' ', 1)[0]
    return get_version_tuple(version)
Example #18
0
def geos_version_tuple():
    """Return the GEOS version as a tuple (major, minor, subminor)."""
    return get_version_tuple(geos_version_info()['version'])
Example #19
0
MS SQL Server database backend for Django.
"""
import os
import re
import time

from django.core.exceptions import ImproperlyConfigured

try:
    import pyodbc as Database
except ImportError as e:
    raise ImproperlyConfigured("Error loading pyodbc module: %s" % e)

from django.utils.version import get_version_tuple # noqa

pyodbc_ver = get_version_tuple(Database.version)
if pyodbc_ver < (3, 0):
    raise ImproperlyConfigured("pyodbc 3.0 or newer is required; you have %s" % Database.version)

from django.conf import settings # noqa
from django.db import NotSupportedError # noqa
from django.db.backends.base.base import BaseDatabaseWrapper # noqa
from django.utils.encoding import smart_str # noqa
from django.utils.functional import cached_property # noqa

if hasattr(settings, 'DATABASE_CONNECTION_POOLING'):
    if not settings.DATABASE_CONNECTION_POOLING:
        Database.pooling = False

from .client import DatabaseClient # noqa
from .creation import DatabaseCreation # noqa
Example #20
0
 def test_get_version_tuple(self):
     self.assertEqual(get_version_tuple("1.2.3"), (1, 2, 3))
     self.assertEqual(get_version_tuple("1.2.3b2"), (1, 2, 3))
     self.assertEqual(get_version_tuple("1.2.3b2.dev0"), (1, 2, 3))