indev. domain status

This commit is contained in:
Cyrille L 2023-03-26 12:30:51 +02:00
parent d487b21c57
commit 9bb3bfc086
13 changed files with 116 additions and 60 deletions

View File

@ -41,6 +41,9 @@ import args
action = args.set_action()
target = args.set_target()
# Check domain
import dom, status
status.domain()
# Command start argument
import check, form, html, new, publish, show, wip, infos
@ -59,6 +62,7 @@ actions = {
'show-db' : show.manage,
'show-wip' : show.manage,
'show-www' : show.manage,
'status' : status.check,
'template' : publish.manage_publish,
'wip' : wip.manage_wip,
}

View File

@ -38,6 +38,7 @@ actions = \
'show-db',
'show-wip',
'show-www',
'status',
'wip',
'publish'
)

View File

@ -22,7 +22,8 @@ import time, importlib, sys, os, re, datetime
from datetime import datetime
from time import gmtime, strftime
import args, logs, dom, db, form, tyto
import args, dom, logs, status, db, form, tyto
# load locale translation
trans_dir = '/var/lib/tyto/translations'
@ -57,8 +58,8 @@ post_err = False
# Start checking article #
#-------------------------#--------------------------------------------
def manage(target):
if not dom.exists: logs.out("10", '', True)
dom.valid()
# target needed
if not target:
logs.out("5", args.action, True)

View File

@ -19,7 +19,8 @@
import os
import args, dom, form, tyto, logs
import args, logs, dom, form, tyto
remove = exists = post = corrupt = False
try: in_dir = os.getcwd()
@ -30,7 +31,7 @@ if args.target \
and not args.target in args.pass_targets:
# Domain must be valid
dom.valid()
if not dom.exists: logs.out("10", '', True)
uri_file = '%s/%s'%(in_dir, args.target)
uri_id = tyto.get_filesum(uri_file, False)

View File

@ -20,7 +20,7 @@
import os, sys, importlib, locale
lib = 'tyto_domain'
exists = incomplete = active = valid = shortname = False
exists = incomplete = active = ready = shortname = False
local_user = articles_db = activated = False
hole = False
@ -51,7 +51,7 @@ if not hole:
if activated:
active = True
# Settings for domain, check if db is not corrupted
values = \
dom_values = \
(
'directory',
'database',
@ -114,9 +114,20 @@ if not hole:
'activated'
)
create_files = \
(
'navbar_f',
'sidebar_f',
'metas_f',
'footer_f',
'footer_about_f'
)
err_val = (()) # Make a list from values error
dir_new = (()) # Make a list for directories to create
for value in values:
file_new = (()) # Make a list for files to check
file_mod = (()) # male a list for modules files to create
for value in dom_values:
try:
eval(str(value))
except:
@ -124,23 +135,29 @@ if not hole:
incomplete = True
active = False
# Check if directory exists
if not incomplete and value.endswith('_d'):
if not os.path.exists(eval(str(value))):
os.makedirs(eval(str(value)), exist_ok=True)
dir_new = dir_new + ((eval(str(value))),)
if articles_db and not os.path.exists(articles_db):
incomplete = True
#==============================================#
# When an active and complete domain is needed #
#----------------------------------------------#
if exists and not incomplete and active: valid = True
if not incomplete and active:
ready = True
for value in dom_values:
# Check if directory exists and create it
if value.endswith('_d') and \
not os.path.exists(eval(str(value))):
os.makedirs(eval(str(value)), exist_ok=True)
dir_new = dir_new + ((eval(str(value))),)
# Check if file exists
if value.endswith('_f') and \
not os.path.exists(eval(str(value))):
if value in create_files:
file_mod = file_mod + ((value),)
else:
file_new = file_new + ((eval(str(value))),)
#====================================#
# Check if domain is valid and ready #
# Check if domain is ready and ready #
#------------------------------------#
def valid():
if incomplete: sys.exit(41)

View File

@ -58,7 +58,10 @@ answer_yes = ('y', 'Y', 'yes', 'Yes', 'YES',
# target: 3rd argument #
#--------------------------#
def manage(target):
if not dom.exists or dom.incomplete:
if not dom.exists:
logs.out("43", '', False)
create_domain(target)
elif dom.incomplete:
create_domain(target)
else:
try:
@ -700,23 +703,14 @@ def create_domain(target):
print('')
# Create domain_footer_about (user custom description in footer)
#---------------------------------------------------------------
if not tyto.exists(footer_about_f):
set_f = '%s\n'%tr.footer_about_doc%(tyto.Tyto,
footer_about_f
) + \
'<p id="footer_about">%s</p>'%about
tyto.set_file(footer_about_f, False, set_f)
logs.out("32", footer_about_f, False)
# Create in _configs files
#-------------------------
# Create in _configs/ modules files
#----------------------------------
create_sidebar('form')
create_navbar('form')
create_metas('form')
create_footer('form')
create_footer_about('form')
print(tr.form_ready)
@ -725,7 +719,7 @@ def create_domain(target):
# metas_load source file #
#------------------------#
def create_metas(option):
dom.valid()
if not dom.valid: dom.valid()
# Defaut metas valuees when FIRST created
metas_srvs = \
@ -816,8 +810,7 @@ def create_metas(option):
# sidebar load file translated #
#------------------------------#
def create_sidebar(option):
# Check if can process
dom.valid()
if not dom.valid: dom.valid()
# Create an empty html file in wip/www server if not exists
if not tyto.exists(dom.wip_sidebar_f):
@ -883,7 +876,7 @@ def create_sidebar(option):
# navbar load file translated #
#-----------------------------#
def create_navbar(option):
dom.valid()
if not dom.valid: dom.valid()
# Create an empty html file in wip/www server if not exists
if not tyto.exists(dom.wip_navbar_f):
@ -950,7 +943,7 @@ def create_navbar(option):
# footer load file translated #
#-----------------------------#
def create_footer(option):
dom.valid()
if not dom.valid: dom.valid()
# Default footer contents
#------------------------
@ -976,8 +969,7 @@ def create_footer(option):
'%stitle="%s"\n'%(9 * ' ', tr.go_home) + \
'%sid="footer_title_link">%s</a>'%(9 * ' ', dom.title)
# Create footer_about
# from custom content in footer_about_f
# Insert content of footer_about_f or default if not exists
footer_about = ''
if tyto.exists(dom.footer_about_f):
footer_custom = open(dom.footer_about_f).read()
@ -1007,6 +999,7 @@ def create_footer(option):
'%stitle="%s - %s"\n'%(11 * ' ', tr.terms_t, dom.title) + \
'%sclass="footer_item_link">%s</a>'%(11 * ' ', tr.terms_s)
# create laws links from terms and legal if exists
footer_laws = ''
if dom.terms_url and dom.legal_url:
footer_laws = '%s - \n%s%s'%(legal_link, 8 * ' ', terms_link)
@ -1117,3 +1110,14 @@ def create_footer(option):
' class="footer_item_link">%s</a> %s\n'%() + \
' </li>\n'
"""
def create_footer_about(option):
if not tyto.exists(dom.footer_about_f):
set_f = '%s\n'%tr.footer_about_doc%(tyto.Tyto,
dom.footer_about_f
) + \
'<p id="footer_about">%s</p>'%dom.about
tyto.set_file(dom.footer_about_f, False, set_f)
logs.out("32", dom.footer_about_f, False)

View File

@ -64,6 +64,7 @@ def tyto(target):
' edit_www: Edit html file in www server\n'
' new : Create new (domain, sidebar/footer... config\'s file)\n'
' show : Show content of config\'s file\n'
' show-about: Show content of custom footer config\n'
' show-db : Show content of article\'s database\n'
' show-wip: Show HTML file in wip server\n'
' show-www: Show HTML file in www server\n\n'

View File

@ -18,7 +18,7 @@
#**********************************************************************
import os, sys
import lang, status
import lang
# Set colors
CS = '\033[0;0m'
@ -40,8 +40,8 @@ def out(nbr, value, out):
'7' : '%s%s%s > %s'%(CR, lang.post_inv, CS, value),
'8' : '%s%s%s %s'%(CR, lang.mark_np, CS, value),
'9' : ' ╞ Article %shas changed%s. Check it first'%(CR, CS),
'10' : ' %sUnused domain configuration%s: %s'%(CR, CS, value),
'11' : ' %s%s%s: %s'%(CR, lang.err_arg, CS, value),
'10' : ' %s%s%s'%(CR, lang.dom_no, CS),
'11' : ' %s%s%s > %s'%(CR, lang.err_arg, CS, value),
'12' : '%sUnused "%s"%s in article\'s header'%(CR, value, CS),
'13' : '%s%s%s'%(CR, lang.no_fidi, CS),
'14' : '%sMismatch%s program start'%(CR, CS),
@ -52,12 +52,12 @@ def out(nbr, value, out):
'19' : ' ╞ Article %swip%s on: %s'%(CG, CS, value),
'20' : '%s%s%s %s'%(CG, lang.check_on, CS, value),
'21' : '%s%s%s > %s'%(CG, lang.post_val, CS, value),
'22' : '%sNot paired%s symbols: %s'%(CY, CS, value),
'23' : '%s%s%s: %s'%(CY, lang.db_inv, CS, value),
'24' : '%sUnused resource%s %s'%(CY, CS, value),
'22' : '%s%s%s %s'%(CY, lang.symb_np, CS, value),
'23' : '%s%s%s > %s'%(CY, lang.db_inv, CS, value),
'24' : '%s%s%s > %s'%(CY, lang.unused_r, CS, value),
'25' : ' ╞ Article %snot yet checked%s: %s'%(CY, CS, value),
'26' : '%sNo index%s article %s'%(CY, CS, value),
'28' : 'Nothing to do %s'%value,
'28' : '%s (%s)'%(lang.ntd, value),
'29' : '%sEmpty configuration%s %s'%(CY, CS, value),
'30' : ' ╞ Article %snot yet wip%s: %s'%(CY, CS, value),
'31' : ' ╞ Not included. %sMax items reached%s %s'%(CY, CS, value),
@ -82,4 +82,3 @@ def out(nbr, value, out):
if int(nbr) == 21: nbr = 0
if out: sys.exit(int(nbr))
status.domain()

View File

@ -20,7 +20,6 @@
import os, sys, importlib
import args, lang, logs, dom, db, form, tyto, check, stats
#======================#
# From command line: #
# - 'showdb' / 'show' #
@ -29,6 +28,8 @@ import args, lang, logs, dom, db, form, tyto, check, stats
# final html, db, load #
#----------------------#
def manage(target):
# Domain must be valid
if not dom.exists: logs.out("10", '', True)
if not target == "domain": dom.valid()
do = False

View File

@ -18,7 +18,7 @@
#**********************************************************************
import os, importlib
import args, logs, dom, form, tyto, show
import args, dom, logs, form, tyto, show
sti_anchors = sti_abbrs = sti_links = 0
sti_images = sti_files = sti_raws = 0

View File

@ -17,11 +17,11 @@
#**********************************************************************
import logs, dom, tyto
import dom, logs, tyto, form
def domain():
if dom.hole: logs.out("13", '', True)
elif not dom.shortname: logs.out("43", '', False)
elif not dom.shortname: return
elif dom.incomplete: logs.out("41", dom.shortname, False)
elif dom.activated: logs.out("42", dom.shortname, False)
elif not dom.activated: logs.out("40", dom.shortname, False)
@ -30,5 +30,28 @@ def domain():
for err_val in dom.err_val:
logs.out("16", err_val, False)
# Missing directories was created
for dir_new in dom.dir_new:
logs.out("33", dir_new, False)
# Create missing modules files
create_files = \
{
'navbar_f' : form.create_navbar,
'sidebar_f' : form.create_sidebar,
'metas_f' : form.create_metas,
'footer_f' : form.create_footer,
'footer_about_f': form.create_footer_about
}
for value in dom.file_mod:
create_files[value]('form')
#==============================#
# On demand with status action #
#------------------------------#
def check(target):
if target == "domain":
for file_new in dom.file_new:
logs.out("24", file_new, False)

View File

@ -13,6 +13,7 @@
# Generic
line = "Ligne"
ntd = "Nothing to do"
unused_r = "Unused ressource"
unused_c = "Unused database value"
db_inv = "Corrupted article's database"
@ -38,5 +39,6 @@ sep_inv = "Unused separator in article"
unused_v = "Unused value in article"
unused_p = "Empty article"
mark_np = "Not paired marks"
symb_np = "Not paired symbols"
laterout = "Maybe later..."

View File

@ -13,6 +13,7 @@
# Generique
linecol = "Line"
ntd = "Rien à faire"
unused_r = "Ressource manquante"
unused_c = "Valeur de la base de donnée manquante"
db_inv = "Base de donnée de l'article corrompue"
@ -38,5 +39,6 @@ sep_inv = "Séparateur manquant dans l'article"
unused_v = "Valeur manquante dans l'article"
unused_p = "L'article est vide"
mark_np = "Marqueurs non pairs"
symb_np = "Symboles non pairs"
laterout = "Pour plus tard..."