#380 Datenbank-Version
This commit is contained in:
@@ -31,10 +31,9 @@ from ffx.filter.preset_filter import PresetFilter
|
|||||||
|
|
||||||
from ffx.filter.nlmeans_filter import NlmeansFilter
|
from ffx.filter.nlmeans_filter import NlmeansFilter
|
||||||
|
|
||||||
|
from ffx.constants import VERSION
|
||||||
|
|
||||||
|
|
||||||
VERSION='0.2.2'
|
|
||||||
|
|
||||||
# 0.1.1
|
# 0.1.1
|
||||||
# Bugfixes, TMBD identify shows
|
# Bugfixes, TMBD identify shows
|
||||||
# 0.1.2
|
# 0.1.2
|
||||||
|
|||||||
@@ -49,4 +49,92 @@ class ConfigurationController():
|
|||||||
|
|
||||||
|
|
||||||
def getData(self):
|
def getData(self):
|
||||||
return self.__configurationData
|
return self.__configurationData
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def addPattern(self, patternDescriptor):
|
||||||
|
#
|
||||||
|
# try:
|
||||||
|
#
|
||||||
|
# s = self.Session()
|
||||||
|
# q = s.query(Pattern).filter(Pattern.show_id == int(patternDescriptor['show_id']),
|
||||||
|
# Pattern.pattern == str(patternDescriptor['pattern']))
|
||||||
|
#
|
||||||
|
# if not q.count():
|
||||||
|
# pattern = Pattern(show_id = int(patternDescriptor['show_id']),
|
||||||
|
# pattern = str(patternDescriptor['pattern']))
|
||||||
|
# s.add(pattern)
|
||||||
|
# s.commit()
|
||||||
|
# return pattern.getId()
|
||||||
|
# else:
|
||||||
|
# return 0
|
||||||
|
#
|
||||||
|
# except Exception as ex:
|
||||||
|
# raise click.ClickException(f"PatternController.addPattern(): {repr(ex)}")
|
||||||
|
# finally:
|
||||||
|
# s.close()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def updatePattern(self, patternId, patternDescriptor):
|
||||||
|
#
|
||||||
|
# try:
|
||||||
|
# s = self.Session()
|
||||||
|
# q = s.query(Pattern).filter(Pattern.id == int(patternId))
|
||||||
|
#
|
||||||
|
# if q.count():
|
||||||
|
#
|
||||||
|
# pattern = q.first()
|
||||||
|
#
|
||||||
|
# pattern.show_id = int(patternDescriptor['show_id'])
|
||||||
|
# pattern.pattern = str(patternDescriptor['pattern'])
|
||||||
|
#
|
||||||
|
# s.commit()
|
||||||
|
# return True
|
||||||
|
#
|
||||||
|
# else:
|
||||||
|
# return False
|
||||||
|
#
|
||||||
|
# except Exception as ex:
|
||||||
|
# raise click.ClickException(f"PatternController.updatePattern(): {repr(ex)}")
|
||||||
|
# finally:
|
||||||
|
# s.close()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def findPattern(self, patternDescriptor):
|
||||||
|
#
|
||||||
|
# try:
|
||||||
|
# s = self.Session()
|
||||||
|
# q = s.query(Pattern).filter(Pattern.show_id == int(patternDescriptor['show_id']), Pattern.pattern == str(patternDescriptor['pattern']))
|
||||||
|
#
|
||||||
|
# if q.count():
|
||||||
|
# pattern = q.first()
|
||||||
|
# return int(pattern.id)
|
||||||
|
# else:
|
||||||
|
# return None
|
||||||
|
#
|
||||||
|
# except Exception as ex:
|
||||||
|
# raise click.ClickException(f"PatternController.findPattern(): {repr(ex)}")
|
||||||
|
# finally:
|
||||||
|
# s.close()
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# def getPattern(self, patternId : int):
|
||||||
|
#
|
||||||
|
# if type(patternId) is not int:
|
||||||
|
# raise ValueError(f"PatternController.getPattern(): Argument patternId is required to be of type int")
|
||||||
|
#
|
||||||
|
# try:
|
||||||
|
# s = self.Session()
|
||||||
|
# q = s.query(Pattern).filter(Pattern.id == int(patternId))
|
||||||
|
#
|
||||||
|
# return q.first() if q.count() else None
|
||||||
|
#
|
||||||
|
# except Exception as ex:
|
||||||
|
# raise click.ClickException(f"PatternController.getPattern(): {repr(ex)}")
|
||||||
|
# finally:
|
||||||
|
# s.close()
|
||||||
|
#
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
|
VERSION='0.2.2'
|
||||||
|
DATABASE_VERSION = 2
|
||||||
|
|
||||||
DEFAULT_QUALITY = 32
|
DEFAULT_QUALITY = 32
|
||||||
DEFAULT_AV1_PRESET = 5
|
DEFAULT_AV1_PRESET = 5
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import os
|
import os, click
|
||||||
|
|
||||||
from sqlalchemy import create_engine
|
from sqlalchemy import create_engine
|
||||||
from sqlalchemy.orm import sessionmaker
|
from sqlalchemy.orm import sessionmaker
|
||||||
@@ -7,9 +7,16 @@ from ffx.model.show import Base, Show
|
|||||||
from ffx.model.pattern import Pattern
|
from ffx.model.pattern import Pattern
|
||||||
from ffx.model.track import Track
|
from ffx.model.track import Track
|
||||||
|
|
||||||
from ffx.model.media_tag import MediaTag
|
from ffx.model.property import Property
|
||||||
from ffx.model.track_tag import TrackTag
|
|
||||||
|
|
||||||
|
from ffx.constants import DATABASE_VERSION
|
||||||
|
|
||||||
|
|
||||||
|
DATABASE_VERSION_KEY = 'database_version'
|
||||||
|
|
||||||
|
class DatabaseVersionException(Exception):
|
||||||
|
def __init__(self, errorMessage):
|
||||||
|
super().__init__(errorMessage)
|
||||||
|
|
||||||
def databaseContext(databasePath: str = ''):
|
def databaseContext(databasePath: str = ''):
|
||||||
|
|
||||||
@@ -42,4 +49,57 @@ def databaseContext(databasePath: str = ''):
|
|||||||
# except sqlite3.OperationalError:
|
# except sqlite3.OperationalError:
|
||||||
# time.sleep(0.1)
|
# time.sleep(0.1)
|
||||||
|
|
||||||
return databaseContext
|
ensureDatabaseVersion(databaseContext)
|
||||||
|
|
||||||
|
return databaseContext
|
||||||
|
|
||||||
|
def ensureDatabaseVersion(databaseContext):
|
||||||
|
|
||||||
|
currentDatabaseVersion = getDatabaseVersion(databaseContext)
|
||||||
|
click.echo(f"current database version: {currentDatabaseVersion}")
|
||||||
|
if currentDatabaseVersion:
|
||||||
|
if currentDatabaseVersion != DATABASE_VERSION:
|
||||||
|
raise DatabaseVersionException(f"Current database version ({currentDatabaseVersion}) does not match required ({DATABASE_VERSION})")
|
||||||
|
else:
|
||||||
|
setDatabaseVersion(databaseContext, DATABASE_VERSION)
|
||||||
|
|
||||||
|
|
||||||
|
def getDatabaseVersion(databaseContext):
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
Session = databaseContext['session']
|
||||||
|
s = Session()
|
||||||
|
q = s.query(Property).filter(Property.key == DATABASE_VERSION_KEY)
|
||||||
|
|
||||||
|
return int(q.first().value) if q.count() else 0
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
raise click.ClickException(f"getDatabaseVersion(): {repr(ex)}")
|
||||||
|
finally:
|
||||||
|
s.close()
|
||||||
|
|
||||||
|
|
||||||
|
def setDatabaseVersion(databaseContext, databaseVersion: int):
|
||||||
|
|
||||||
|
try:
|
||||||
|
Session = databaseContext['session']
|
||||||
|
s = Session()
|
||||||
|
|
||||||
|
q = s.query(Property).filter(Property.key == DATABASE_VERSION_KEY)
|
||||||
|
|
||||||
|
dbVersion = int(databaseVersion)
|
||||||
|
|
||||||
|
versionProperty = q.first()
|
||||||
|
if versionProperty:
|
||||||
|
versionProperty.value = str(dbVersion)
|
||||||
|
else:
|
||||||
|
versionProperty = Property(key = DATABASE_VERSION_KEY,
|
||||||
|
value = str(dbVersion))
|
||||||
|
s.add(versionProperty)
|
||||||
|
s.commit()
|
||||||
|
|
||||||
|
except Exception as ex:
|
||||||
|
raise click.ClickException(f"setDatabaseVersion(): {repr(ex)}")
|
||||||
|
finally:
|
||||||
|
s.close()
|
||||||
16
bin/ffx/model/property.py
Normal file
16
bin/ffx/model/property.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
# from typing import List
|
||||||
|
from sqlalchemy import create_engine, Column, Integer, String, ForeignKey, Enum
|
||||||
|
from sqlalchemy.orm import relationship, declarative_base, sessionmaker
|
||||||
|
|
||||||
|
from .show import Base
|
||||||
|
|
||||||
|
|
||||||
|
class Property(Base):
|
||||||
|
|
||||||
|
__tablename__ = 'properties'
|
||||||
|
|
||||||
|
# v1.x
|
||||||
|
id = Column(Integer, primary_key=True)
|
||||||
|
|
||||||
|
key = Column(String)
|
||||||
|
value = Column(String)
|
||||||
Reference in New Issue
Block a user