mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Prompt for book directory when not set.
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"TITLE": "pyShelf E-Book Server",
|
"TITLE": "pyShelf E-Book Server",
|
||||||
"VERSION": "0.6.0",
|
"VERSION": "0.6.0",
|
||||||
"BOOKPATH": "~/Books",
|
"BOOKPATH": "",
|
||||||
"DB_HOST": "localhost",
|
"DB_HOST": "localhost",
|
||||||
"DB_PORT": "5432",
|
"DB_PORT": "5432",
|
||||||
"DATABASE": "pyshelf",
|
"DATABASE": "pyshelf",
|
||||||
|
|||||||
8
configure
vendored
8
configure
vendored
@@ -6,6 +6,7 @@ from pathlib import Path
|
|||||||
from django.core.management.utils import get_random_secret_key
|
from django.core.management.utils import get_random_secret_key
|
||||||
from src.backend.lib.pyShelf import Admin
|
from src.backend.lib.pyShelf import Admin
|
||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
with open('config.json',"r") as file:
|
with open('config.json',"r") as file:
|
||||||
config = json.load(file)
|
config = json.load(file)
|
||||||
@@ -27,6 +28,12 @@ def set_secret(config=load_config()):
|
|||||||
else:
|
else:
|
||||||
print("Secret already set, skipping.")
|
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():
|
def init_django_database():
|
||||||
cmds = [
|
cmds = [
|
||||||
'python3 manage.py makemigrations',
|
'python3 manage.py makemigrations',
|
||||||
@@ -40,5 +47,6 @@ def init_django_database():
|
|||||||
os.chdir("../")
|
os.chdir("../")
|
||||||
|
|
||||||
set_secret()
|
set_secret()
|
||||||
|
set_book_directory()
|
||||||
init_django_database()
|
init_django_database()
|
||||||
Admin(Path.cwd()).createsuperuser()
|
Admin(Path.cwd()).createsuperuser()
|
||||||
|
|||||||
Reference in New Issue
Block a user