36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
import os
|
|
try:
|
|
import config
|
|
except:
|
|
print("You have no configuration file, please move example.config.py to config.py and modify the options to your usage")
|
|
exit()
|
|
|
|
def initialise():
|
|
# Create the posts db
|
|
try:
|
|
import posts
|
|
except:
|
|
with open("posts.py","w") as posts_db:
|
|
posts_db.write("posts = []")
|
|
# Create the users db
|
|
try:
|
|
import users
|
|
except:
|
|
users = []
|
|
print("What users do you want to have? You can always change this later by editing users.py (0 to finish)")
|
|
while True:
|
|
user_input = input()
|
|
if user_input == "0":
|
|
break
|
|
else:
|
|
users.append(user_input)
|
|
with open("users.py", "w") as users_db:
|
|
users_db.write(f"users = {users}")
|
|
# Create folders in the web directory
|
|
if not os.path.exists(f"{config.webroot}/post"):
|
|
os.makedirs(f"{config.webroot}/post")
|
|
if not os.path.exists(f"{config.webroot}/user"):
|
|
os.makedirs(f"{config.webroot}/user")
|
|
|
|
print("Successfully initialised Glogger")
|