-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathrename_all_deprecated_modules.py
executable file
·48 lines (36 loc) · 1.57 KB
/
rename_all_deprecated_modules.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env python3
# Copyright 2021 Coop IT Easy SCRL fs
# Carmen Bianca Bakker <[email protected]>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html).
"""CIE-specific script to run migration on all test databases. This script may
not work for you if your server is different.
"""
import logging
import os
import pathlib
import subprocess
_logger = logging.getLogger(__name__)
def all_databases():
result = subprocess.run(["ociedoo", "list-db"], check=True, stdout=subprocess.PIPE)
output = result.stdout.decode("utf-8")
return [line for line in output.splitlines() if line]
def filter_databases(databases):
return [database for database in databases if database.endswith("-test")]
def main():
os.chdir(pathlib.Path(__file__).parent)
logging.basicConfig(level=logging.INFO)
# don't filter databases
# databases = filter_databases(all_databases())
databases = filter_databases(all_databases())
for database in databases:
# don't create new DB
new_database = database
# _logger.info(f"Removing {new_database} if it exists")
# subprocess.run(["ociedoo", "drop-db", new_database])
# _logger.info(f"Creating {new_database} from {database}")
# subprocess.run(["ociedoo", "copy-db", database, new_database], check=True)
_logger.info(f"Running renaming migration on {new_database}")
subprocess.run(["./rename_deprecated_modules.sh", new_database], check=True)
_logger.info(f"Done with renaming migration of {new_database}")
if __name__ == "__main__":
main()