mirror of
https://github.com/spl0k/supysonic.git
synced 2024-11-09 11:42:16 +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 = [
|
||||
'flask>=0.11',
|
||||
'pony>=0.7.2',
|
||||
'pony>=0.7.6',
|
||||
'Pillow',
|
||||
'requests>=1.0.0',
|
||||
'mutagen>=1.33'
|
||||
|
@ -14,9 +14,10 @@ import getpass
|
||||
import sys
|
||||
import time
|
||||
|
||||
from pony.orm import db_session
|
||||
from pony.orm import ObjectNotFound
|
||||
|
||||
from .db import Folder, User, db_session
|
||||
from .db import Folder, User
|
||||
from .managers.folder import FolderManager
|
||||
from .managers.user import UserManager
|
||||
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 buffer
|
||||
from pony.orm import min, max, avg, sum, exists
|
||||
from pony.orm import db_session as pony_session
|
||||
from uuid import UUID, uuid4
|
||||
|
||||
from .py23 import dict, strtype
|
||||
@ -32,6 +31,11 @@ def now():
|
||||
|
||||
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):
|
||||
@classmethod
|
||||
def get(cls, *args, **kwargs):
|
||||
@ -470,26 +474,6 @@ class Playlist(db.Entity):
|
||||
|
||||
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):
|
||||
if not isinstance(database_uri, strtype):
|
||||
raise TypeError('Expecting a string')
|
||||
|
@ -12,11 +12,12 @@ import mimetypes
|
||||
import mutagen
|
||||
import time
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from .covers import find_cover_in_folder
|
||||
from .db import Folder, Artist, Album, Track, User
|
||||
from .db import StarredFolder, StarredArtist, StarredAlbum, StarredTrack
|
||||
from .db import RatingFolder, RatingTrack
|
||||
from .db import db_session
|
||||
from .py23 import strtype
|
||||
|
||||
class StatsDetails(object):
|
||||
|
@ -11,12 +11,13 @@ import logging
|
||||
import time
|
||||
|
||||
from logging.handlers import TimedRotatingFileHandler
|
||||
from pony.orm import db_session
|
||||
from signal import signal, SIGTERM, SIGINT
|
||||
from threading import Thread, Condition, Timer
|
||||
from watchdog.observers import Observer
|
||||
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 .scanner import Scanner
|
||||
|
||||
|
@ -12,9 +12,10 @@ import mimetypes
|
||||
|
||||
from flask import Flask
|
||||
from os import makedirs, path
|
||||
from pony.orm import db_session
|
||||
|
||||
from .config import IniConfig
|
||||
from .db import init_database, db_session
|
||||
from .db import init_database
|
||||
|
||||
def create_application(config = None):
|
||||
global app
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
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
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
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
|
||||
|
||||
|
@ -12,8 +12,9 @@ import time
|
||||
import uuid
|
||||
|
||||
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
|
||||
|
||||
|
@ -13,8 +13,9 @@ import uuid
|
||||
|
||||
from io import BytesIO
|
||||
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
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
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
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
import time
|
||||
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
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
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.scanner import Scanner
|
||||
|
||||
|
@ -15,13 +15,14 @@ import tempfile
|
||||
import unittest
|
||||
|
||||
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
|
||||
from StringIO import StringIO
|
||||
except ImportError:
|
||||
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 ..testbase import TestConfig
|
||||
|
@ -13,10 +13,10 @@ import unittest
|
||||
import uuid
|
||||
|
||||
from collections import namedtuple
|
||||
from pony.orm import db_session
|
||||
|
||||
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}$')
|
||||
|
||||
class DbTestCase(unittest.TestCase):
|
||||
|
@ -15,14 +15,12 @@ import tempfile
|
||||
import unittest
|
||||
|
||||
from contextlib import contextmanager
|
||||
from pony.orm import commit
|
||||
from pony.orm import db_session, commit
|
||||
|
||||
from supysonic import db
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
|
||||
db_session = db.db_session
|
||||
|
||||
class ScannerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
db.init_database('sqlite:', True)
|
||||
|
@ -18,9 +18,10 @@ import unittest
|
||||
|
||||
from contextlib import contextmanager
|
||||
from hashlib import sha1
|
||||
from pony.orm import db_session
|
||||
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.watcher import SupysonicWatcher
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from supysonic.db import Folder, db_session
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder
|
||||
|
||||
from .frontendtestbase import FrontendTestBase
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from supysonic.db import User, db_session
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import User
|
||||
|
||||
from .frontendtestbase import FrontendTestBase
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
|
||||
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
|
||||
|
||||
|
@ -11,8 +11,9 @@
|
||||
import uuid
|
||||
|
||||
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
|
||||
|
||||
|
@ -12,7 +12,9 @@ import shutil
|
||||
import tempfile
|
||||
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.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
|
@ -18,9 +18,7 @@ import tempfile
|
||||
import unittest
|
||||
import uuid
|
||||
|
||||
from pony.orm import ObjectNotFound
|
||||
|
||||
db_session = db.db_session
|
||||
from pony.orm import db_session, ObjectNotFound
|
||||
|
||||
class FolderManagerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -17,11 +17,9 @@ import io
|
||||
import unittest
|
||||
import uuid
|
||||
|
||||
from pony.orm import commit
|
||||
from pony.orm import db_session, commit
|
||||
from pony.orm import ObjectNotFound
|
||||
|
||||
db_session = db.db_session
|
||||
|
||||
class UserManagerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
# Create an empty sqlite database in memory
|
||||
|
@ -14,7 +14,9 @@ import shutil
|
||||
import unittest
|
||||
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.managers.user import UserManager
|
||||
from supysonic.web import create_application
|
||||
|
Loading…
Reference in New Issue
Block a user