mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Start on Upload page
Remove reduntant Exiting text Rename css folder to theme
This commit is contained in:
parent
d85ac5f103
commit
f730ecd0c9
7 changed files with 63 additions and 61 deletions
|
@ -12,19 +12,16 @@ class DBmanager():
|
|||
except ImportError:
|
||||
print("Error: could not import required packages")
|
||||
sys.exit(1)
|
||||
|
||||
env_path = os.path.join('usr', '.env')
|
||||
if not os.path.exists(env_path):
|
||||
print("Error: could not find .env file")
|
||||
sys.exit(1)
|
||||
|
||||
load_dotenv(env_path)
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Connecting to database...")
|
||||
|
||||
try:
|
||||
env_path = os.path.join('usr', '.env')
|
||||
|
||||
if not os.path.exists(env_path):
|
||||
print("Error: could not find .env file")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
load_dotenv(env_path)
|
||||
print("### OnlyLegs Database Manager ###")
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Connecting to database...")
|
||||
|
||||
database = mysql.connector.connect(host=os.environ.get('DB_HOST'),
|
||||
port=os.environ.get('DB_PORT'),
|
||||
database=os.environ.get('DB_NAME'),
|
||||
|
@ -46,52 +43,42 @@ class DBmanager():
|
|||
|
||||
except Error as e:
|
||||
print("Error while connecting to Database!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
self.database = database
|
||||
|
||||
def initialize(self):
|
||||
dir = os.path.join('packages', 'tables')
|
||||
|
||||
if not os.path.exists(dir+'/generate.sql'):
|
||||
if not os.path.exists(os.path.join('packages', 'tables', 'generate.sql')):
|
||||
print("Error: could not find tables directory")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Initializing tables...")
|
||||
|
||||
with open(dir+'/generate.sql', 'r') as f:
|
||||
sql = f.read()
|
||||
|
||||
with open(os.path.join('packages', 'tables', 'generate.sql'), 'r') as sql:
|
||||
cursor = self.database.cursor()
|
||||
query = cursor.execute(sql, multi=True)
|
||||
query = cursor.execute(sql.read(), multi=True)
|
||||
|
||||
i = 0
|
||||
for res in query:
|
||||
#print("Running query...")
|
||||
print(f"Affected {res.rowcount} rows")
|
||||
|
||||
self.database.commit()
|
||||
print(f"Query {i+1}: Affected {res.rowcount} rows")
|
||||
i += 1
|
||||
|
||||
if not os.path.exists(dir+'/junctions.sql'):
|
||||
if not os.path.exists(os.path.join('packages', 'tables', 'junctions.sql')):
|
||||
print("Error: could not find junctions directory")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Initializing junctions...")
|
||||
|
||||
with open(dir+'/junctions.sql', 'r') as f:
|
||||
sql = f.read()
|
||||
|
||||
with open(os.path.join('packages', 'tables', 'junctions.sql'), 'r') as sql:
|
||||
cursor = self.database.cursor()
|
||||
query = cursor.execute(sql, multi=True)
|
||||
query = cursor.execute(sql.read(), multi=True)
|
||||
|
||||
i = 0
|
||||
for res in query:
|
||||
#print("Running query...")
|
||||
print(f"Affected {res.rowcount} rows")
|
||||
|
||||
self.database.commit()
|
||||
|
||||
print(f"Query {i+1}: Affected {res.rowcount} rows")
|
||||
i += 1
|
||||
|
||||
self.database.commit()
|
||||
print(f"{now.hour}:{now.minute}:{now.second} - Done!\n")
|
||||
|
||||
def getImage(self, id):
|
||||
|
@ -101,4 +88,4 @@ class DBmanager():
|
|||
cursor = self.database.cursor()
|
||||
cursor.execute(sql, img)
|
||||
|
||||
return cursor.fetchone()
|
||||
return cursor.fetchone()
|
||||
|
|
|
@ -13,7 +13,6 @@ class Sassy():
|
|||
import sass
|
||||
except ImportError:
|
||||
print("Could not find libsass!")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
theme_path = os.path.join('usr', 'themes', theme, 'style.scss')
|
||||
|
@ -24,7 +23,6 @@ class Sassy():
|
|||
self.loadTheme(theme_path)
|
||||
else:
|
||||
print("No theme found!")
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
font_path = os.path.join('usr', 'themes', theme, 'fonts')
|
||||
|
@ -38,17 +36,16 @@ class Sassy():
|
|||
print(f"{now.hour}:{now.minute}:{now.second} - Done!\n")
|
||||
|
||||
def loadTheme (self, theme):
|
||||
with open('static/css/style.css', 'w') as f:
|
||||
with open('static/theme/style.css', 'w') as f:
|
||||
try:
|
||||
f.write(self.sass.compile(filename=theme, output_style='compressed'))
|
||||
print("Compiled successfully to:", f.name)
|
||||
except self.sass.CompileError as e:
|
||||
print("Failed to compile!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
def loadFonts (self, font_path):
|
||||
dest = os.path.join('static', 'css', 'fonts')
|
||||
dest = os.path.join('static', 'theme', 'fonts')
|
||||
|
||||
if os.path.exists(dest):
|
||||
print("Removing old fonts...")
|
||||
|
@ -57,7 +54,6 @@ class Sassy():
|
|||
print("Removed old fonts!")
|
||||
except Exception as e:
|
||||
print("Failed to remove old fonts!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
|
@ -65,7 +61,6 @@ class Sassy():
|
|||
print("Copied fonts to:", dest)
|
||||
except Exception as e:
|
||||
print("Failed to copy fonts!\nFull error:", e)
|
||||
print("Exiting...")
|
||||
sys.exit(1)
|
||||
|
||||
#print ("Removing old fonts from:", dest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue