mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Using new pony on_connect
decorator
Revert "Restore SQLite case insensitive LIKE"
This reverts commit a08689e8c0
.
This commit is contained in:
parent
4df8e975ec
commit
38f718b4df
2
setup.py
2
setup.py
@ -18,7 +18,7 @@ from setuptools import find_packages
|
|||||||
|
|
||||||
reqs = [
|
reqs = [
|
||||||
'flask>=0.11',
|
'flask>=0.11',
|
||||||
'pony>=0.7.2',
|
'pony>=0.7.6',
|
||||||
'Pillow',
|
'Pillow',
|
||||||
'requests>=1.0.0',
|
'requests>=1.0.0',
|
||||||
'mutagen>=1.33'
|
'mutagen>=1.33'
|
||||||
|
@ -14,9 +14,10 @@ import getpass
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from pony.orm import db_session
|
||||||
from pony.orm import ObjectNotFound
|
from pony.orm import ObjectNotFound
|
||||||
|
|
||||||
from .db import Folder, User, db_session
|
from .db import Folder, User
|
||||||
from .managers.folder import FolderManager
|
from .managers.folder import FolderManager
|
||||||
from .managers.user import UserManager
|
from .managers.user import UserManager
|
||||||
from .scanner import Scanner
|
from .scanner import Scanner
|
||||||
|
@ -17,7 +17,6 @@ from pony.orm import Database, Required, Optional, Set, PrimaryKey, LongStr
|
|||||||
from pony.orm import ObjectNotFound
|
from pony.orm import ObjectNotFound
|
||||||
from pony.orm import buffer
|
from pony.orm import buffer
|
||||||
from pony.orm import min, max, avg, sum, exists
|
from pony.orm import min, max, avg, sum, exists
|
||||||
from pony.orm import db_session as pony_session
|
|
||||||
from uuid import UUID, uuid4
|
from uuid import UUID, uuid4
|
||||||
|
|
||||||
from .py23 import dict, strtype
|
from .py23 import dict, strtype
|
||||||
@ -32,6 +31,11 @@ def now():
|
|||||||
|
|
||||||
db = Database()
|
db = Database()
|
||||||
|
|
||||||
|
@db.on_connect(provider = 'sqlite')
|
||||||
|
def sqlite_case_insensitive_like(db, connection):
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute('PRAGMA case_sensitive_like = OFF')
|
||||||
|
|
||||||
class PathMixin(object):
|
class PathMixin(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def get(cls, *args, **kwargs):
|
def get(cls, *args, **kwargs):
|
||||||
@ -470,26 +474,6 @@ class Playlist(db.Entity):
|
|||||||
|
|
||||||
self.tracks = ','.join(t for t in tracks if t)
|
self.tracks = ','.join(t for t in tracks if t)
|
||||||
|
|
||||||
class DBSessionContextWrapper(object):
|
|
||||||
def __ensure_sqlite_case_insensitive_like(self):
|
|
||||||
if db.provider.dialect == 'SQLite':
|
|
||||||
db.execute('PRAGMA case_sensitive_like = OFF')
|
|
||||||
|
|
||||||
def __call__(self, func, *args, **kwargs):
|
|
||||||
def new_func(*args, **kwargs):
|
|
||||||
self.__ensure_sqlite_case_insensitive_like()
|
|
||||||
return func(*args, **kwargs)
|
|
||||||
return pony_session(new_func, *args, **kwargs)
|
|
||||||
|
|
||||||
def __enter__(self):
|
|
||||||
pony_session.__enter__()
|
|
||||||
self.__ensure_sqlite_case_insensitive_like()
|
|
||||||
|
|
||||||
def __exit__(self, *args, **kwargs):
|
|
||||||
pony_session.__exit__(*args, **kwargs)
|
|
||||||
|
|
||||||
db_session = DBSessionContextWrapper()
|
|
||||||
|
|
||||||
def parse_uri(database_uri):
|
def parse_uri(database_uri):
|
||||||
if not isinstance(database_uri, strtype):
|
if not isinstance(database_uri, strtype):
|
||||||
raise TypeError('Expecting a string')
|
raise TypeError('Expecting a string')
|
||||||
|
@ -12,11 +12,12 @@ import mimetypes
|
|||||||
import mutagen
|
import mutagen
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from pony.orm import db_session
|
||||||
|
|
||||||
from .covers import find_cover_in_folder
|
from .covers import find_cover_in_folder
|
||||||
from .db import Folder, Artist, Album, Track, User
|
from .db import Folder, Artist, Album, Track, User
|
||||||
from .db import StarredFolder, StarredArtist, StarredAlbum, StarredTrack
|
from .db import StarredFolder, StarredArtist, StarredAlbum, StarredTrack
|
||||||
from .db import RatingFolder, RatingTrack
|
from .db import RatingFolder, RatingTrack
|
||||||
from .db import db_session
|
|
||||||
from .py23 import strtype
|
from .py23 import strtype
|
||||||
|
|
||||||
class StatsDetails(object):
|
class StatsDetails(object):
|
||||||
|
@ -11,12 +11,13 @@ import logging
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from logging.handlers import TimedRotatingFileHandler
|
from logging.handlers import TimedRotatingFileHandler
|
||||||
|
from pony.orm import db_session
|
||||||
from signal import signal, SIGTERM, SIGINT
|
from signal import signal, SIGTERM, SIGINT
|
||||||
from threading import Thread, Condition, Timer
|
from threading import Thread, Condition, Timer
|
||||||
from watchdog.observers import Observer
|
from watchdog.observers import Observer
|
||||||
from watchdog.events import PatternMatchingEventHandler
|
from watchdog.events import PatternMatchingEventHandler
|
||||||
|
|
||||||
from .db import init_database, release_database, db_session, Folder
|
from .db import init_database, release_database, Folder
|
||||||
from .py23 import dict
|
from .py23 import dict
|
||||||
from .scanner import Scanner
|
from .scanner import Scanner
|
||||||
|
|
||||||
|
@ -12,9 +12,10 @@ import mimetypes
|
|||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from os import makedirs, path
|
from os import makedirs, path
|
||||||
|
from pony.orm import db_session
|
||||||
|
|
||||||
from .config import IniConfig
|
from .config import IniConfig
|
||||||
from .db import init_database, db_session
|
from .db import init_database
|
||||||
|
|
||||||
def create_application(config = None):
|
def create_application(config = None):
|
||||||
global app
|
global app
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import Folder, Artist, Album, Track
|
||||||
|
|
||||||
from .apitestbase import ApiTestBase
|
from .apitestbase import ApiTestBase
|
||||||
|
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track, User, ClientPrefs, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import Folder, Artist, Album, Track, User, ClientPrefs
|
||||||
|
|
||||||
from .apitestbase import ApiTestBase
|
from .apitestbase import ApiTestBase
|
||||||
|
|
||||||
|
@ -12,8 +12,9 @@ import time
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
|
from pony.orm import db_session
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
from supysonic.db import Folder, Artist, Album, Track
|
||||||
|
|
||||||
from .apitestbase import ApiTestBase
|
from .apitestbase import ApiTestBase
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ import uuid
|
|||||||
|
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
from pony.orm import db_session
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
from supysonic.db import Folder, Artist, Album, Track
|
||||||
|
|
||||||
from .apitestbase import ApiTestBase
|
from .apitestbase import ApiTestBase
|
||||||
|
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track, Playlist, User, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import Folder, Artist, Album, Track, Playlist, User
|
||||||
|
|
||||||
from .apitestbase import ApiTestBase
|
from .apitestbase import ApiTestBase
|
||||||
|
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from pony.orm import commit
|
from pony.orm import db_session, commit
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
from supysonic.db import Folder, Artist, Album, Track
|
||||||
|
|
||||||
from .apitestbase import ApiTestBase
|
from .apitestbase import ApiTestBase
|
||||||
|
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from supysonic.db import Folder, Track, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import Folder, Track
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
|
|
||||||
|
@ -15,13 +15,14 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from pony.orm import db_session
|
||||||
|
|
||||||
try: # Don't use io.StringIO on py2, it only accepts unicode and the CLI spits strs
|
try: # Don't use io.StringIO on py2, it only accepts unicode and the CLI spits strs
|
||||||
from StringIO import StringIO
|
from StringIO import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
from supysonic.db import Folder, User, init_database, release_database, db_session
|
from supysonic.db import Folder, User, init_database, release_database
|
||||||
from supysonic.cli import SupysonicCLI
|
from supysonic.cli import SupysonicCLI
|
||||||
|
|
||||||
from ..testbase import TestConfig
|
from ..testbase import TestConfig
|
||||||
|
@ -13,10 +13,10 @@ import unittest
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from pony.orm import db_session
|
||||||
|
|
||||||
from supysonic import db
|
from supysonic import db
|
||||||
|
|
||||||
db_session = db.db_session
|
|
||||||
date_regex = re.compile(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$')
|
date_regex = re.compile(r'^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}$')
|
||||||
|
|
||||||
class DbTestCase(unittest.TestCase):
|
class DbTestCase(unittest.TestCase):
|
||||||
|
@ -15,14 +15,12 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from pony.orm import commit
|
from pony.orm import db_session, commit
|
||||||
|
|
||||||
from supysonic import db
|
from supysonic import db
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
|
|
||||||
db_session = db.db_session
|
|
||||||
|
|
||||||
class ScannerTestCase(unittest.TestCase):
|
class ScannerTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
db.init_database('sqlite:', True)
|
db.init_database('sqlite:', True)
|
||||||
|
@ -18,9 +18,10 @@ import unittest
|
|||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
|
from pony.orm import db_session
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database, db_session, Track, Artist
|
from supysonic.db import init_database, release_database, Track, Artist
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.watcher import SupysonicWatcher
|
from supysonic.watcher import SupysonicWatcher
|
||||||
|
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from supysonic.db import Folder, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import Folder
|
||||||
|
|
||||||
from .frontendtestbase import FrontendTestBase
|
from .frontendtestbase import FrontendTestBase
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from supysonic.db import User, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import User
|
||||||
|
|
||||||
from .frontendtestbase import FrontendTestBase
|
from .frontendtestbase import FrontendTestBase
|
||||||
|
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from supysonic.db import Folder, Artist, Album, Track, Playlist, User, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import Folder, Artist, Album, Track, Playlist, User
|
||||||
|
|
||||||
from .frontendtestbase import FrontendTestBase
|
from .frontendtestbase import FrontendTestBase
|
||||||
|
|
||||||
|
@ -11,8 +11,9 @@
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from flask import escape
|
from flask import escape
|
||||||
|
from pony.orm import db_session
|
||||||
|
|
||||||
from supysonic.db import User, ClientPrefs, db_session
|
from supysonic.db import User, ClientPrefs
|
||||||
|
|
||||||
from .frontendtestbase import FrontendTestBase
|
from .frontendtestbase import FrontendTestBase
|
||||||
|
|
||||||
|
@ -12,7 +12,9 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import init_database, release_database
|
||||||
from supysonic.db import Folder
|
from supysonic.db import Folder
|
||||||
from supysonic.managers.folder import FolderManager
|
from supysonic.managers.folder import FolderManager
|
||||||
from supysonic.scanner import Scanner
|
from supysonic.scanner import Scanner
|
||||||
|
@ -18,9 +18,7 @@ import tempfile
|
|||||||
import unittest
|
import unittest
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from pony.orm import ObjectNotFound
|
from pony.orm import db_session, ObjectNotFound
|
||||||
|
|
||||||
db_session = db.db_session
|
|
||||||
|
|
||||||
class FolderManagerTestCase(unittest.TestCase):
|
class FolderManagerTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
|
@ -17,11 +17,9 @@ import io
|
|||||||
import unittest
|
import unittest
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from pony.orm import commit
|
from pony.orm import db_session, commit
|
||||||
from pony.orm import ObjectNotFound
|
from pony.orm import ObjectNotFound
|
||||||
|
|
||||||
db_session = db.db_session
|
|
||||||
|
|
||||||
class UserManagerTestCase(unittest.TestCase):
|
class UserManagerTestCase(unittest.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
# Create an empty sqlite database in memory
|
# Create an empty sqlite database in memory
|
||||||
|
@ -14,7 +14,9 @@ import shutil
|
|||||||
import unittest
|
import unittest
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from supysonic.db import init_database, release_database, db_session
|
from pony.orm import db_session
|
||||||
|
|
||||||
|
from supysonic.db import init_database, release_database
|
||||||
from supysonic.config import DefaultConfig
|
from supysonic.config import DefaultConfig
|
||||||
from supysonic.managers.user import UserManager
|
from supysonic.managers.user import UserManager
|
||||||
from supysonic.web import create_application
|
from supysonic.web import create_application
|
||||||
|
Loading…
Reference in New Issue
Block a user