Prompt for book directory when not set.

This commit is contained in:
th3r00t
2020-09-11 17:35:46 -04:00
parent 31aeb82c3d
commit 58c0f21784
2 changed files with 9 additions and 1 deletions

View File

@@ -1,7 +1,7 @@
{
"TITLE": "pyShelf E-Book Server",
"VERSION": "0.6.0",
"BOOKPATH": "~/Books",
"BOOKPATH": "",
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DATABASE": "pyshelf",

8
configure vendored
View File

@@ -6,6 +6,7 @@ from pathlib import Path
from django.core.management.utils import get_random_secret_key
from src.backend.lib.pyShelf import Admin
def load_config():
with open('config.json',"r") as file:
config = json.load(file)
@@ -27,6 +28,12 @@ def set_secret(config=load_config()):
else:
print("Secret already set, skipping.")
def set_book_directory(config=load_config(), *args):
if config["BOOKPATH"] == "":
try: config["BOOKPATH"] = args[0]
except IndexError: config["BOOKPATH"] = input("Input Book Directory ")
write_config(config)
def init_django_database():
cmds = [
'python3 manage.py makemigrations',
@@ -40,5 +47,6 @@ def init_django_database():
os.chdir("../")
set_secret()
set_book_directory()
init_django_database()
Admin(Path.cwd()).createsuperuser()