-
Notifications
You must be signed in to change notification settings - Fork 635
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8468 from rtibbles/preseed_all_the_dbs
Preseed all the databases
- Loading branch information
Showing
4 changed files
with
90 additions
and
40 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
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,32 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
|
||
temphome = tempfile.mkdtemp() | ||
os.environ["KOLIBRI_HOME"] = temphome | ||
|
||
from kolibri.main import initialize # noqa E402 | ||
from kolibri.deployment.default.sqlite_db_names import ( # noqa E402 | ||
ADDITIONAL_SQLITE_DATABASES, | ||
) | ||
from django.core.management import call_command # noqa E402 | ||
|
||
move_to = os.path.join(os.path.dirname(__file__), "..", "kolibri", "dist", "home") | ||
shutil.rmtree(move_to, ignore_errors=True) | ||
os.mkdir(move_to) | ||
|
||
print("Generating preseeded home data in {}".format(temphome)) | ||
|
||
initialize() | ||
call_command( | ||
"deprovision", "--destroy-all-user-data", "--permanent-irrevocable-data-loss" | ||
) | ||
|
||
shutil.move(os.path.join(temphome, "db.sqlite3"), move_to) | ||
|
||
for db_name in ADDITIONAL_SQLITE_DATABASES: | ||
shutil.move(os.path.join(temphome, "{}.sqlite3".format(db_name)), move_to) | ||
|
||
print("Moved all preseeded home data to {}".format(move_to)) | ||
|
||
shutil.rmtree(temphome) |
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