Now not create the database if exists
This commit is contained in:
parent
97367ba2c0
commit
16fa9b550a
2 changed files with 52 additions and 49 deletions
|
|
@ -219,65 +219,70 @@ def start():
|
||||||
|
|
||||||
useradmin=UserAdmin(conn)
|
useradmin=UserAdmin(conn)
|
||||||
|
|
||||||
if not useradmin.query(sql):
|
# Check if db exists
|
||||||
|
|
||||||
|
c=0
|
||||||
|
|
||||||
|
with useradmin.query('SHOW DATABASES LIKE "%s"' % db) as cur:
|
||||||
|
c=cur.rowcount
|
||||||
|
|
||||||
|
if c==0:
|
||||||
|
useradmin.query(sql)
|
||||||
|
#print('Error: cannot create database or db doesn\'t exists, check database permissions for this user')
|
||||||
|
|
||||||
|
#if not useradmin.query(sql):
|
||||||
#print('Error: cannot create database, check the data of database')
|
#print('Error: cannot create database, check the data of database')
|
||||||
|
|
||||||
# Check if db exists
|
|
||||||
|
|
||||||
cur=useradmin.query('SHOW DATABASES LIKE "%s"' % db)
|
|
||||||
|
|
||||||
if cur.rowcount()==0:
|
|
||||||
print('Error: cannot create database or db doesn\'t exists, check database permissions for this user')
|
|
||||||
|
|
||||||
else:
|
#else:
|
||||||
|
|
||||||
useradmin.query('use '+db)
|
useradmin.query('use '+db)
|
||||||
|
|
||||||
admin=input('Do you want create admin site? y/n: ')
|
|
||||||
|
|
||||||
if admin=='y' or admin=='Y':
|
admin=input('Do you want create admin site? y/n: ')
|
||||||
|
|
||||||
|
if admin=='y' or admin=='Y':
|
||||||
|
|
||||||
|
try:
|
||||||
|
|
||||||
|
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
||||||
|
|
||||||
|
shutil.copy(workdir+'/settings/config_admin.py.sample', path_settings+'/config_admin.py')
|
||||||
|
|
||||||
|
sql=useradmin.create_table()
|
||||||
|
|
||||||
try:
|
if not useradmin.query(sql):
|
||||||
|
print('Error: cannot create table admin, you can create this table with padmin.py')
|
||||||
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
else:
|
||||||
|
|
||||||
shutil.copy(workdir+'/settings/config_admin.py.sample', path_settings+'/config_admin.py')
|
|
||||||
|
|
||||||
sql=useradmin.create_table()
|
|
||||||
|
|
||||||
if not useradmin.query(sql):
|
# Add admin module to config
|
||||||
print('Error: cannot create table admin, you can create this table with padmin.py')
|
with open(path_settings+'/config.py', 'r') as f:
|
||||||
else:
|
|
||||||
|
|
||||||
# Add admin module to config
|
config_text=f.read()
|
||||||
with open(path_settings+'/config.py', 'r') as f:
|
|
||||||
|
|
||||||
config_text=f.read()
|
|
||||||
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
config_text=config_text.replace("modules=['paramecio.modules.welcome']", "modules=['paramecio.modules.welcome', 'paramecio.modules.admin', 'paramecio.modules.lang']")
|
f.close()
|
||||||
|
|
||||||
|
config_text=config_text.replace("modules=['paramecio.modules.welcome']", "modules=['paramecio.modules.welcome', 'paramecio.modules.admin', 'paramecio.modules.lang']")
|
||||||
|
|
||||||
|
with open(path_settings+'/config.py', 'w') as f:
|
||||||
|
|
||||||
with open(path_settings+'/config.py', 'w') as f:
|
f.write(config_text)
|
||||||
|
|
||||||
f.write(config_text)
|
f.close()
|
||||||
|
|
||||||
f.close()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
||||||
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
||||||
|
|
||||||
except:
|
|
||||||
|
|
||||||
print('Error: cannot copy the file modules.py. Check if exists and if you have permissions for this task')
|
|
||||||
|
|
||||||
print('Created admin site...')
|
except:
|
||||||
|
|
||||||
except:
|
print('Error: cannot copy the file modules.py. Check if exists and if you have permissions for this task')
|
||||||
|
|
||||||
print('Error: cannot copy the file padmin.py. Check if exists and if you have permissions for this task')
|
print('Created admin site...')
|
||||||
exit(1)
|
|
||||||
|
except:
|
||||||
|
|
||||||
|
print('Error: cannot create the database. Check if tables exists in it and if you have permissions for this task')
|
||||||
|
exit(1)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,12 +50,10 @@ env=env_theme(__file__)
|
||||||
|
|
||||||
menu=get_menu(config_admin.modules_admin)
|
menu=get_menu(config_admin.modules_admin)
|
||||||
|
|
||||||
#arr_admin_modules={for k, in menu}
|
|
||||||
#d = {key: value[1] for (key, value) in menu.items()}
|
|
||||||
module_imported={}
|
module_imported={}
|
||||||
|
|
||||||
for k, v in menu.items():
|
for k, v in menu.items():
|
||||||
#print(k[:1])
|
|
||||||
if k[:1]!='/':
|
if k[:1]!='/':
|
||||||
if type(v).__name__=='list':
|
if type(v).__name__=='list':
|
||||||
module_imported[k]=import_module(v[1])
|
module_imported[k]=import_module(v[1])
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue