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)
|
||||
|
||||
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')
|
||||
|
||||
# Check if db exists
|
||||
|
||||
cur=useradmin.query('SHOW DATABASES LIKE "%s"' % db)
|
||||
#else:
|
||||
|
||||
if cur.rowcount()==0:
|
||||
print('Error: cannot create database or db doesn\'t exists, check database permissions for this user')
|
||||
useradmin.query('use '+db)
|
||||
|
||||
else:
|
||||
admin=input('Do you want create admin site? y/n: ')
|
||||
|
||||
useradmin.query('use '+db)
|
||||
if admin=='y' or admin=='Y':
|
||||
|
||||
admin=input('Do you want create admin site? y/n: ')
|
||||
try:
|
||||
|
||||
if admin=='y' or admin=='Y':
|
||||
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
||||
|
||||
try:
|
||||
shutil.copy(workdir+'/settings/config_admin.py.sample', path_settings+'/config_admin.py')
|
||||
|
||||
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
||||
sql=useradmin.create_table()
|
||||
|
||||
shutil.copy(workdir+'/settings/config_admin.py.sample', path_settings+'/config_admin.py')
|
||||
if not useradmin.query(sql):
|
||||
print('Error: cannot create table admin, you can create this table with padmin.py')
|
||||
else:
|
||||
|
||||
sql=useradmin.create_table()
|
||||
# Add admin module to config
|
||||
with open(path_settings+'/config.py', 'r') as f:
|
||||
|
||||
if not useradmin.query(sql):
|
||||
print('Error: cannot create table admin, you can create this table with padmin.py')
|
||||
else:
|
||||
config_text=f.read()
|
||||
|
||||
# Add admin module to config
|
||||
with open(path_settings+'/config.py', 'r') as f:
|
||||
f.close()
|
||||
|
||||
config_text=f.read()
|
||||
config_text=config_text.replace("modules=['paramecio.modules.welcome']", "modules=['paramecio.modules.welcome', 'paramecio.modules.admin', 'paramecio.modules.lang']")
|
||||
|
||||
f.close()
|
||||
with open(path_settings+'/config.py', 'w') as f:
|
||||
|
||||
config_text=config_text.replace("modules=['paramecio.modules.welcome']", "modules=['paramecio.modules.welcome', 'paramecio.modules.admin', 'paramecio.modules.lang']")
|
||||
f.write(config_text)
|
||||
|
||||
with open(path_settings+'/config.py', 'w') as f:
|
||||
f.close()
|
||||
|
||||
f.write(config_text)
|
||||
try:
|
||||
|
||||
f.close()
|
||||
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
||||
|
||||
try:
|
||||
except:
|
||||
|
||||
shutil.copy(workdir+'/settings/modules.py.admin', path_settings+'/modules.py')
|
||||
print('Error: cannot copy the file modules.py. Check if exists and if you have permissions for this task')
|
||||
|
||||
except:
|
||||
print('Created admin site...')
|
||||
|
||||
print('Error: cannot copy the file modules.py. Check if exists and if you have permissions for this task')
|
||||
except:
|
||||
|
||||
print('Created admin site...')
|
||||
|
||||
except:
|
||||
|
||||
print('Error: cannot copy the file padmin.py. Check if exists and if you have permissions for this task')
|
||||
exit(1)
|
||||
print('Error: cannot create the database. Check if tables exists in it and if you have permissions for this task')
|
||||
exit(1)
|
||||
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -50,12 +50,10 @@ env=env_theme(__file__)
|
|||
|
||||
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={}
|
||||
|
||||
for k, v in menu.items():
|
||||
#print(k[:1])
|
||||
|
||||
if k[:1]!='/':
|
||||
if type(v).__name__=='list':
|
||||
module_imported[k]=import_module(v[1])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue