Skip to content
Snippets Groups Projects
Commit 0e3a8cab authored by Thilo Kogge's avatar Thilo Kogge
Browse files

fixed linter errors

parent 805a0ae5
No related branches found
No related tags found
2 merge requests!70fixed 304 logic,!69db model updates
......@@ -62,7 +62,7 @@ def run_migrations(strict=True):
for podcast_url in podcasts:
podcast_dict = Factory().get_store().get(podcast_url).__dict__
if podcast_dict != None:
podcast, entry_hashs = migrate_podcast_v0_v1(podcast_dict,strict)
podcast, entry_hashs = migrate_podcast_v0_v1(podcast_dict, strict)
for entry_id, podpost in entry_hashs.items():
if not podpost.id:
raise ValueError("Podpost has no id")
......@@ -81,7 +81,7 @@ def run_migrations(strict=True):
migrate_external_v0_v1(post_hash_to_id)
set_versionnumber(1)
if current_version < 2:
if current_version < 2 and start_version == 1:
from playhouse.migrate import SqliteMigrator
migrator = SqliteMigrator(db)
logger.info("migration2: Starting migration of the datamodel...")
......@@ -94,8 +94,8 @@ def run_migrations(strict=True):
migrator.add_index("podcast", Podcast.url.column_name)
)
db.pragma("foreign_keys", "on")
set_versionnumber(2)
pyotherside.send("migrationDone")
set_versionnumber(2)
pyotherside.send("migrationDone")
def recreate_table(table: Type[Model], tablename: str):
......@@ -105,7 +105,7 @@ def recreate_table(table: Type[Model], tablename: str):
db.execute_sql("ALTER TABLE %s RENAME TO %s;" % (tablename, table_copy_name))
db.create_tables([table])
sql = "INSERT INTO %s (%s) SELECT %s FROM %s;" % (tablename, col_names, col_names, table_copy_name)
#todo: check for returned sql errors
# todo: check for returned sql errors
db.execute_sql(sql)
logger.info("deleting copy of table %s", tablename)
db.execute_sql("DROP TABLE %s_x;" % tablename)
......@@ -181,7 +181,7 @@ def migrate_podpost_v0_v1(post_dict: dict, podpost: Podpost):
PodpostFactory().persist(podpost)
def migrate_podcast_v0_v1(podcast_dict: dict, strict = True) -> Tuple[Podcast, Dict[str, Podpost]]:
def migrate_podcast_v0_v1(podcast_dict: dict, strict=True) -> Tuple[Podcast, Dict[str, Podpost]]:
logger.info("migrating podcast '%s' to new format version 1 strictmode: %s", podcast_dict['title'], strict)
try:
if podcast_dict['logo_path']:
......@@ -239,7 +239,8 @@ def migrate_podcast_v0_v1(podcast_dict: dict, strict = True) -> Tuple[Podcast, D
raise ValueError("Migration failed. Expected %d entries, but only migrated %d", old_entry_count,
len(podcast.entry_ids_old_to_new))
except Exception as e:
logger.exception("error while migrating podcast %s to new format. strictmode: %s", podcast_dict['title'], strict)
logger.exception("error while migrating podcast %s to new format. strictmode: %s", podcast_dict['title'],
strict)
raise e
......
......@@ -10,6 +10,10 @@ from peewee import CharField, TextField, BooleanField, IntegerField, ModelSelect
sys.path.append("/usr/share/podqast/python")
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from podpost import Podpost
from podcast.constants import Constants, BaseModel
from podcast.factory import BaseFactory
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment