Skip to content
Snippets Groups Projects
Commit a4b4bcde authored by Bert Palm's avatar Bert Palm :bug:
Browse files

Merge branch 'minor_cleanups' into 'main'

reodered sync code, added typehints

See merge request !170
parents 85e025d8 54c54c15
No related branches found
No related tags found
1 merge request!170reodered sync code, added typehints
Pipeline #400686 passed
#!/usr/bin/env python
#!/usr/bin/env python3
from __future__ import annotations
import abc
......@@ -72,7 +72,7 @@ class MinioFS(RemoteFS):
secret_key: str,
bucket_name: str | None = None,
secure: bool = True,
):
) -> MinioFS:
logger.warning(str(locals()))
cl = minio.Minio(
endpoint=endpoint,
......@@ -153,7 +153,7 @@ class FtpFS(RemoteFS):
path,
keyfile_path=None,
missing_host_key_policy: MissingHostKeyPolicy | None = None,
):
) -> FtpFS:
# with urlparse(uri, scheme="sftp") the uri
# is interpreted as relative path
uri_parts = urlparse(uri if "://" in uri else f"sftp://{uri}")
......
......@@ -8,43 +8,22 @@ import psycopg
import sys
def has_column(cur, table, column):
records = cur.execute(
"SELECT column_name FROM information_schema.columns "
"WHERE table_name = %s "
"and column_name = %s",
(table, column),
).fetchall()
return len(records) > 0
ALTER_TABLE_SQL = (
"ALTER TABLE s3map.mapping "
"ADD COLUMN filename_pattern varchar(256), "
"ADD COLUMN parser varchar(256)"
)
FETCH_THING_IDS = "SELECT distinct thing_uuid FROM s3map.mapping"
FETCH_THING_IDS2 = "SELECT distinct thing_uuid FROM mapping"
GET_PATTERN_PARSER_BY_THING_ID = ()
usage = f"""{os.path.basename(__file__)} S3_DSN FE_DSN
Adds columns 'filename_pattern' and 'parser' to s3map.mapping
and fills them with data from the frontend.
S3_DSN is the full fledged database connection string to
the s3map_db with ** admin privileges ** (alter tables).
FE_DB is the full fledged database connection string to
the frontenddb (read)
Example:
S3DB=postgresql://postgres:postgres@localhost/postgres
FEDB=postgresql://frontenddb:frontenddb@localhost/postgres
python {os.path.basename(__file__)} $S3DB $FEDB
"""
def has_column(cur, table, column):
records = cur.execute(
"SELECT column_name FROM information_schema.columns "
"WHERE table_name = %s "
"and column_name = %s",
(table, column),
).fetchall()
return len(records) > 0
def get_parser_and_pattern(cur, thing_id):
......@@ -68,6 +47,24 @@ def update_parser_and_pattern(cur, thing_id, parser, pattern):
)
usage = f"""{os.path.basename(__file__)} S3_DSN FE_DSN
Adds columns 'filename_pattern' and 'parser' to s3map.mapping
and fills them with data from the frontend.
S3_DSN is the full fledged database connection string to
the s3map_db with ** admin privileges ** (alter tables).
FE_DB is the full fledged database connection string to
the frontenddb (read)
Example:
S3DB=postgresql://postgres:postgres@localhost/postgres
FEDB=postgresql://frontenddb:frontenddb@localhost/postgres
python {os.path.basename(__file__)} $S3DB $FEDB
"""
if __name__ == "__main__":
if len(sys.argv) != 3:
print(usage)
......
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