mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 08:56:17 +00:00
parent
dd33e8da14
commit
a08689e8c0
@ -14,10 +14,9 @@ import getpass
|
||||
import sys
|
||||
import time
|
||||
|
||||
from pony.orm import db_session
|
||||
from pony.orm import ObjectNotFound
|
||||
|
||||
from .db import Folder, User
|
||||
from .db import Folder, User, db_session
|
||||
from .managers.folder import FolderManager
|
||||
from .managers.user import UserManager
|
||||
from .scanner import Scanner
|
||||
|
@ -17,6 +17,7 @@ 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
|
||||
@ -469,6 +470,26 @@ 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,12 +12,11 @@ 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,13 +11,12 @@ 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, Folder
|
||||
from .db import init_database, release_database, db_session, Folder
|
||||
from .py23 import dict
|
||||
from .scanner import Scanner
|
||||
|
||||
|
@ -12,10 +12,9 @@ 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
|
||||
from .db import init_database, db_session
|
||||
|
||||
def create_application(config = None):
|
||||
global app
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track
|
||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
||||
|
||||
from .apitestbase import ApiTestBase
|
||||
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track, User, ClientPrefs
|
||||
from supysonic.db import Folder, Artist, Album, Track, User, ClientPrefs, db_session
|
||||
|
||||
from .apitestbase import ApiTestBase
|
||||
|
||||
|
@ -12,9 +12,8 @@ import time
|
||||
import uuid
|
||||
|
||||
from lxml import etree
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track
|
||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
||||
|
||||
from .apitestbase import ApiTestBase
|
||||
|
||||
|
@ -13,9 +13,8 @@ import uuid
|
||||
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track
|
||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
||||
|
||||
from .apitestbase import ApiTestBase
|
||||
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track, Playlist, User
|
||||
from supysonic.db import Folder, Artist, Album, Track, Playlist, User, db_session
|
||||
|
||||
from .apitestbase import ApiTestBase
|
||||
|
||||
|
@ -11,9 +11,9 @@
|
||||
import time
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session, commit
|
||||
from pony.orm import commit
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track
|
||||
from supysonic.db import Folder, Artist, Album, Track, db_session
|
||||
|
||||
from .apitestbase import ApiTestBase
|
||||
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Track
|
||||
from supysonic.db import Folder, Track, db_session
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
|
||||
|
@ -15,14 +15,13 @@ 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
|
||||
from supysonic.db import Folder, User, init_database, release_database, db_session
|
||||
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,12 +15,14 @@ import tempfile
|
||||
import unittest
|
||||
|
||||
from contextlib import contextmanager
|
||||
from pony.orm import db_session, commit
|
||||
from pony.orm import 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,10 +18,9 @@ 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, Track, Artist
|
||||
from supysonic.db import init_database, release_database, db_session, Track, Artist
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.watcher import SupysonicWatcher
|
||||
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder
|
||||
from supysonic.db import Folder, db_session
|
||||
|
||||
from .frontendtestbase import FrontendTestBase
|
||||
|
||||
|
@ -11,9 +11,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import User
|
||||
from supysonic.db import User, db_session
|
||||
|
||||
from .frontendtestbase import FrontendTestBase
|
||||
|
||||
|
@ -10,9 +10,7 @@
|
||||
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import Folder, Artist, Album, Track, Playlist, User
|
||||
from supysonic.db import Folder, Artist, Album, Track, Playlist, User, db_session
|
||||
|
||||
from .frontendtestbase import FrontendTestBase
|
||||
|
||||
|
@ -11,9 +11,8 @@
|
||||
import uuid
|
||||
|
||||
from flask import escape
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import User, ClientPrefs
|
||||
from supysonic.db import User, ClientPrefs, db_session
|
||||
|
||||
from .frontendtestbase import FrontendTestBase
|
||||
|
||||
|
@ -12,9 +12,7 @@ import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import init_database, release_database
|
||||
from supysonic.db import init_database, release_database, db_session
|
||||
from supysonic.db import Folder
|
||||
from supysonic.managers.folder import FolderManager
|
||||
from supysonic.scanner import Scanner
|
||||
|
@ -18,7 +18,9 @@ import tempfile
|
||||
import unittest
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session, ObjectNotFound
|
||||
from pony.orm import ObjectNotFound
|
||||
|
||||
db_session = db.db_session
|
||||
|
||||
class FolderManagerTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
|
@ -17,9 +17,11 @@ import io
|
||||
import unittest
|
||||
import uuid
|
||||
|
||||
from pony.orm import db_session, commit
|
||||
from pony.orm import 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,9 +14,7 @@ import shutil
|
||||
import unittest
|
||||
import tempfile
|
||||
|
||||
from pony.orm import db_session
|
||||
|
||||
from supysonic.db import init_database, release_database
|
||||
from supysonic.db import init_database, release_database, db_session
|
||||
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