-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
table status of tul before and after vanilla import
table status of tul before and after vanilla import - script
- Loading branch information
1 parent
9e337b8
commit 96a2fbd
Showing
3 changed files
with
84 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import logging | ||
|
||
import settings | ||
import tul_settings | ||
from utils import init_logging, update_settings | ||
|
||
_logger = logging.getLogger() | ||
|
||
env = update_settings(settings.env, tul_settings.settings) | ||
init_logging(_logger, env["log_file"]) | ||
|
||
import dspace # noqa | ||
import pump | ||
|
||
|
||
def difference_dtb(old_dtb: dict, new_dtb: dict): | ||
msg = "" | ||
no_exist7 = "" | ||
no_exist5 = "" | ||
for name in sorted(old_dtb.keys()): | ||
if name not in new_dtb: | ||
no_exist7 += f"{name}," | ||
else: | ||
difference = int(new_dtb[name]) - int(old_dtb[name]) | ||
result = "surplus " if difference > 0 else ( | ||
"deficit " if difference < 0 else "") | ||
msg += f"{name: >40}: {int(difference): >8d} {result}\n" | ||
del new_dtb[name] | ||
for name in sorted(new_dtb.keys()): | ||
no_exist5 += f"{name}," | ||
_logger.info( | ||
f"\n{msg}Nonexistent tables in DSpace 7:\n\t{no_exist7}\nNonexistent tables in DSpace 5:\n\t{no_exist5}") | ||
_logger.info(40 * "=") | ||
|
||
|
||
if __name__ == "__main__": | ||
_logger.info("Loading repo objects") | ||
|
||
_logger.info("Database difference:") | ||
raw_db_7 = pump.db(env["db_dspace_7"]) | ||
raw_db_tul = pump.db(env["db_tul"]) | ||
difference_dtb(raw_db_tul.table_count(), raw_db_7.table_count()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
from datetime import datetime | ||
_this_dir = os.path.dirname(os.path.abspath(__file__)) | ||
ts = datetime.now().strftime("%Y_%m_%d__%H.%M.%S") | ||
|
||
settings = { | ||
"log_file": os.path.join(_this_dir, "../__logs", f"{ts}.txt"), | ||
|
||
"resume_dir": "__temp/resume/", | ||
|
||
"backend": { | ||
"endpoint": "http://dev-5.pc:85/server/api/", | ||
"user": "[email protected]", | ||
"password": "admin", | ||
"authentication": True, | ||
}, | ||
|
||
"db_dspace_7": { | ||
# CLARIN-DSpace 7 database | ||
"name": "dspace", | ||
"host": "localhost", | ||
# careful - NON standard port | ||
"port": 5435, | ||
"user": "dspace", | ||
"password": "dspace", | ||
}, | ||
|
||
"db_tul": { | ||
"name": "tul", | ||
"host": "localhost", | ||
"user": "postgres", | ||
"password": "dspace", | ||
"port": 5432, | ||
} | ||
} |