Compare commits
2 Commits
4288eca551
...
0e282894a6
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e282894a6 | |||
| e14677e701 |
15
pywallter.py
15
pywallter.py
@ -18,7 +18,7 @@ from views.logs import logs
|
|||||||
from views.loginlogout import loginlogout
|
from views.loginlogout import loginlogout
|
||||||
from views.gallery import mygallery
|
from views.gallery import mygallery
|
||||||
|
|
||||||
from tools.databaseinit import init_db, init_dir, db_migrate
|
from tools.databaseinit import init_db, check_directories, db_migrate
|
||||||
|
|
||||||
import glob, os, sys, time
|
import glob, os, sys, time
|
||||||
|
|
||||||
@ -26,22 +26,25 @@ app = Flask( 'pywallter' )
|
|||||||
app.config.from_pyfile('config.py')
|
app.config.from_pyfile('config.py')
|
||||||
bcrypt = Bcrypt(app)
|
bcrypt = Bcrypt(app)
|
||||||
|
|
||||||
init_db()
|
|
||||||
db_migrate()
|
|
||||||
if init_dir():
|
|
||||||
print ("Le repertoire des utilisateurs a été créer")
|
|
||||||
|
|
||||||
|
|
||||||
#### Variables Globales #########################################################################
|
#### Variables Globales #########################################################################
|
||||||
|
|
||||||
|
|
||||||
DOSSIER_PERSO= app.config['DOSSIER_APP']
|
DOSSIER_PERSO= app.config['DOSSIER_APP']
|
||||||
|
DATABASE= app.config['DATABASE']
|
||||||
extensionimg = app.config['EXT_IMG']
|
extensionimg = app.config['EXT_IMG']
|
||||||
MAIL_SERVER = app.config['MAIL_SERVER']
|
MAIL_SERVER = app.config['MAIL_SERVER']
|
||||||
XMPP_SERVER = app.config['XMPP_SERVER']
|
XMPP_SERVER = app.config['XMPP_SERVER']
|
||||||
#################################################################################################
|
#################################################################################################
|
||||||
|
|
||||||
|
init_db(DATABASE)
|
||||||
|
check_directories(DOSSIER_PERSO)
|
||||||
|
db_migrate(DATABASE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
xmpp_server_not_installed = system('whereis prosodyctl')
|
xmpp_server_not_installed = system('whereis prosodyctl')
|
||||||
mail_server_not_installed = system('whereis set_mail_alias') + system('whereis set_mail_passwd') + \
|
mail_server_not_installed = system('whereis set_mail_alias') + system('whereis set_mail_passwd') + \
|
||||||
system('whereis dovecot') + system('whereis smtpd')
|
system('whereis dovecot') + system('whereis smtpd')
|
||||||
|
|||||||
@ -5,17 +5,12 @@ from tools.utils import gen_token
|
|||||||
from flask_bcrypt import Bcrypt
|
from flask_bcrypt import Bcrypt
|
||||||
|
|
||||||
app = Flask( 'pywallter' )
|
app = Flask( 'pywallter' )
|
||||||
app.config.from_pyfile('config.py')
|
|
||||||
bcrypt = Bcrypt(app)
|
bcrypt = Bcrypt(app)
|
||||||
|
|
||||||
DATABASE = app.config['DATABASE']
|
|
||||||
DOSSIER_PERSO = app.config['DOSSIER_APP']
|
|
||||||
DATABASE = app.config['DATABASE']
|
|
||||||
|
|
||||||
|
|
||||||
|
def init_db(database):
|
||||||
def init_db():
|
conn = sqlite3.connect(database)
|
||||||
conn = sqlite3.connect(DATABASE)
|
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS users(
|
CREATE TABLE IF NOT EXISTS users(
|
||||||
@ -81,14 +76,16 @@ def init_db():
|
|||||||
conn.close()
|
conn.close()
|
||||||
print ('table posts OK')
|
print ('table posts OK')
|
||||||
|
|
||||||
def init_dir():
|
def check_directories(users_folder):
|
||||||
if os.path.isdir('users'):
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
os.makedirs('./users/')
|
|
||||||
|
|
||||||
def db_migrate():
|
if os.path.isdir(users_folder):
|
||||||
conn = sqlite3.connect(DATABASE)
|
print("Le dossier {} existe".format(users_folder))
|
||||||
|
else:
|
||||||
|
os.makedirs(users_folder)
|
||||||
|
print("Le dossier {} a été créé".format(users_folder))
|
||||||
|
|
||||||
|
def db_migrate(database):
|
||||||
|
conn = sqlite3.connect(database)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
|
||||||
cursor.execute("""SELECT name FROM PRAGMA_TABLE_INFO('users');""")
|
cursor.execute("""SELECT name FROM PRAGMA_TABLE_INFO('users');""")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user