modern #2

Merged
absurdo merged 38 commits from modern into master 2025-03-15 00:00:11 +00:00
3 changed files with 42 additions and 5 deletions
Showing only changes of commit 0a3c405b87 - Show all commits

View file

@ -52,7 +52,7 @@ def start():
print('Error: cannot create the directory. Check if exists and if you have permissions')
exit()
# Create folder settings and copy index.py, admin.py
# Create folder settings and copy app.py, admin.py
path_settings=args.path+'/settings'
@ -74,11 +74,11 @@ def start():
try:
shutil.copy(workdir+'/frontend/index.py', args.path+'/index.py')
shutil.copy(workdir+'/frontend/app.py', args.path+'/app.py')
except:
print('Error: cannot copy the file index.py. Check if exists and if you have permissions for this task')
print('Error: cannot copy the file app.py. Check if exists and if you have permissions for this task')
try:

View file

@ -8,6 +8,7 @@ import getpass
from pathlib import Path
from settings import config
from importlib import import_module
import re
def start():
"""Module for create new modules for paramecio
@ -39,6 +40,8 @@ def start():
#f=open('modules/'+args.path+'/index.py', 'w')
name_module=os.path.basename(args.path)
try:
shutil.copy(workdir+'/examples/app.py', 'modules/'+args.path)
@ -46,8 +49,6 @@ def start():
app_file=f.read()
name_module=os.path.basename(args.path)
app_file=app_file.replace('/example', '/'+name_module)
with open('modules/'+args.path+'/app.py', 'w') as f:
@ -61,6 +62,42 @@ def start():
print('Error: cannot copy controller example. Check if you have permissions')
exit(1)
# Edit config.py
module_final='modules.'+name_module
try:
with open('./settings/config.py') as f:
#modules_final='\''+'\', \''.join(final_modules)+'\''
p=re.compile(r"^modules=\[(.*)\]$")
#config_file=p.sub(r"modules=[\1, "+modules_final+"]", "modules=['paramecio.modules.welcome', 'paramecio.modules.admin', 'paramecio.modules.lang', 'modules.pastafari', 'modules.monit', 'modules.example']")
final_config=''
for line in f:
if p.match(line):
line=p.sub(r"modules=[\1, '"+module_final+"']", line)
final_config+=line
with open('./settings/config.py', 'w') as f:
f.write(final_config)
print('Updated configuration for add new modules...')
except:
print('Cannot update configuration, you need add the new module by hand')
# Reload config
config.modules.append(module_final)
# Regenerate modules
regenerate_modules_config()