mirror of
https://github.com/Derpy-Leggies/OnlyLegs.git
synced 2025-06-29 11:36:16 +00:00
Sass compiling
Database manager
This commit is contained in:
parent
594431b420
commit
ce6e839281
10 changed files with 160 additions and 397 deletions
50
packages/onlylegsDB.py
Normal file
50
packages/onlylegsDB.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
class DBmanager():
|
||||
def __init__(self):
|
||||
try:
|
||||
import mysql.connector
|
||||
from mysql.connector import Error
|
||||
from dotenv import load_dotenv
|
||||
except ImportError:
|
||||
print("Error: could not import required modules")
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
load_dotenv(os.path.join('usr', '.env'))
|
||||
|
||||
database = mysql.connector.connect(host=os.environ.get('HOST'),
|
||||
port=os.environ.get('PORT'),
|
||||
database=os.environ.get('DATABASE'),
|
||||
user=os.environ.get('USERNAME'),
|
||||
password=os.environ.get('PASSWORD')
|
||||
)
|
||||
|
||||
if database.is_connected():
|
||||
db_Info = database.get_server_info()
|
||||
print("Connected to MySQL Server version: ", db_Info)
|
||||
|
||||
cursor = database.cursor()
|
||||
cursor.execute("select database();")
|
||||
|
||||
record = cursor.fetchone()
|
||||
print("You're connected to database: ", record)
|
||||
|
||||
except Error as e:
|
||||
print("Error while connecting to MySQL\n", e)
|
||||
sys.exit(1)
|
||||
|
||||
self.database = database
|
||||
|
||||
def cursor(self):
|
||||
return self.database.cursor()
|
||||
|
||||
def getImage(self, id):
|
||||
sql = "SELECT * FROM images WHERE id = %s"
|
||||
img = (id,)
|
||||
|
||||
cursor = self.cursor()
|
||||
cursor.execute(sql, img)
|
||||
|
||||
return cursor.fetchone()
|
28
packages/onlylegsSass.py
Normal file
28
packages/onlylegsSass.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import sys
|
||||
import os
|
||||
|
||||
class Sassy():
|
||||
def __init__(self, theme):
|
||||
try:
|
||||
import sass
|
||||
except ImportError:
|
||||
print("Error: sass not found")
|
||||
sys.exit(1)
|
||||
|
||||
path_to_sass = os.path.join('./usr', 'themes', theme, 'style.scss')
|
||||
|
||||
if os.path.exists(path_to_sass):
|
||||
print("Sass found at: " + path_to_sass)
|
||||
self.sass = sass
|
||||
self.loadTheme(path_to_sass)
|
||||
else:
|
||||
print("Error: theme not found")
|
||||
sys.exit(1)
|
||||
|
||||
def loadTheme (self, theme):
|
||||
with open('static/css/style.css', 'w') as f:
|
||||
try:
|
||||
f.write(self.sass.compile(filename=theme, output_style='compressed'))
|
||||
print("Sass compiled successfully to: " + f.name)
|
||||
except self.sass.CompileError as e:
|
||||
print("Error: sass compilation failed:\n", e)
|
Loading…
Add table
Add a link
Reference in a new issue