diff --git a/modelbaker/dbconnector/gpkg_connector.py b/modelbaker/dbconnector/gpkg_connector.py index 95552bb..0cf4155 100644 --- a/modelbaker/dbconnector/gpkg_connector.py +++ b/modelbaker/dbconnector/gpkg_connector.py @@ -875,7 +875,9 @@ def rename_dataset(self, tid, datasetname): return False, self.tr('Could not rename dataset to "{}".').format(datasetname) def get_topics_info(self): - if self._table_exists("T_ILI2DB_CLASSNAME"): + if self._table_exists("T_ILI2DB_CLASSNAME") and self._table_exists( + GPKG_METAATTRS_TABLE + ): cursor = self.conn.cursor() cursor.execute( """ diff --git a/modelbaker/dbconnector/mssql_connector.py b/modelbaker/dbconnector/mssql_connector.py index eb3f435..849a4ef 100644 --- a/modelbaker/dbconnector/mssql_connector.py +++ b/modelbaker/dbconnector/mssql_connector.py @@ -993,7 +993,11 @@ def rename_dataset(self, tid, datasetname): def get_topics_info(self): result = {} - if self.schema and self._table_exists("t_ili2db_classname"): + if ( + self.schema + and self._table_exists("t_ili2db_classname") + and self._table_exists(METAATTRS_TABLE) + ): cur = self.conn.cursor() cur.execute( """ diff --git a/modelbaker/dbconnector/pg_connector.py b/modelbaker/dbconnector/pg_connector.py index e3df395..80f8c37 100644 --- a/modelbaker/dbconnector/pg_connector.py +++ b/modelbaker/dbconnector/pg_connector.py @@ -1076,7 +1076,11 @@ def rename_dataset(self, tid, datasetname): return False, self.tr('Could not rename dataset "{}".').format(datasetname) def get_topics_info(self): - if self.schema and self._table_exists("t_ili2db_classname"): + if ( + self.schema + and self._table_exists("t_ili2db_classname") + and self._table_exists(PG_METAATTRS_TABLE) + ): cur = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor) cur.execute( sql.SQL( diff --git a/modelbaker/ilitoppingmaker/ilitarget.py b/modelbaker/ilitoppingmaker/ilitarget.py index dd038c4..51bac2c 100644 --- a/modelbaker/ilitoppingmaker/ilitarget.py +++ b/modelbaker/ilitoppingmaker/ilitarget.py @@ -19,6 +19,7 @@ import datetime import os +import pathlib from ..libs.toppingmaker import Target from ..libs.toppingmaker.utils import slugify @@ -62,7 +63,9 @@ def ilidata_path_resolver(target, name, type): _, relative_filedir_path = target.filedir_path(type) id = target.unique_id_in_target_scope(target, slugify(f"{type}_{name}_001")) - path = os.path.join(relative_filedir_path, name) + path = pathlib.PureWindowsPath( + os.path.join(relative_filedir_path, name) + ).as_posix() type = type toppingfile = {"id": id, "path": path, "type": type} target.toppingfileinfo_list.append(toppingfile) diff --git a/modelbaker/iliwrapper/ilicache.py b/modelbaker/iliwrapper/ilicache.py index b7d2a47..01c961a 100644 --- a/modelbaker/iliwrapper/ilicache.py +++ b/modelbaker/iliwrapper/ilicache.py @@ -19,6 +19,7 @@ import glob import logging import os +import pathlib import re import shutil import urllib.parse @@ -685,20 +686,21 @@ def download_file(self, netloc, url, file, dataset_id=None): file_url = self.file_url(url, file) if url is None or os.path.isdir(url): - file_path = file_url + file_path = os.path.normpath(file_url) # continue with the local file - if os.path.exists(file_url): - self.file_download_succeeded.emit(dataset_id, file_url) + if os.path.exists(file_path): + self.file_download_succeeded.emit(dataset_id, file_path) else: self.file_download_failed.emit( dataset_id, - self.tr("Could not find local file {}").format(file_url), + self.tr("Could not find local file {}").format(file_path), ) else: - file_path = os.path.join(self.CACHE_PATH, netloc, file) + file_path = os.path.normpath(os.path.join(self.CACHE_PATH, netloc, file)) file_dir = os.path.dirname(file_path) os.makedirs(file_dir, exist_ok=True) - + # in case there are backslashes in the url, remove them + file_url = pathlib.PureWindowsPath(file_url).as_posix() download_file( file_url, file_path,