stats for statoolinfos. wip/publish OK. Fix db check for publish

This commit is contained in:
Cyrille L 2023-03-11 17:56:11 +01:00
parent 57b401da70
commit 35794a8ae8
3 changed files with 34 additions and 33 deletions

View File

@ -18,7 +18,7 @@
#********************************************************************** #**********************************************************************
import os, sys, shutil, importlib import os, sys, shutil, importlib
import logs, args, db, html, tyto, domain import logs, args, db, html, tyto, domain, stats
#==============================# #==============================#
@ -39,7 +39,8 @@ def manage_publish(target):
'navbar' : html.create_navbar, 'navbar' : html.create_navbar,
'metas' : html.create_user_metas, 'metas' : html.create_user_metas,
'footer' : html.create_user_footer, 'footer' : html.create_user_footer,
'template' : create_template 'template' : create_template,
'stats' : stats.manage_stats
} }
do[target]('www') do[target]('www')
@ -63,9 +64,9 @@ def manage_publish(target):
if db.hash_wip: if db.hash_wip:
# wip and current article have different hash # wip and current article have different hash
if db.hash_post != db.hash_chk: if db.hash_post != db.hash_chk:
logs.out("25", db.uri_file, False) logs.out("9", db.uri_file, False)
err_pub = True err_pub = True
elif db.hash_post != db.hash_wip: elif db.hash_wip != db.hash_chk:
logs.out("30", db.uri_file, False) logs.out("30", db.uri_file, False)
err_pub = True err_pub = True

View File

@ -36,7 +36,7 @@ def manage_stats(process):
do = { do = {
'wip' : loop_articles, 'wip' : loop_articles,
'www' : loop_articles, 'publish' : loop_articles,
'show-wip' : count_stats, # NO 'show-wip' : count_stats, # NO
'show_www' : count_stats, # NO 'show_www' : count_stats, # NO
} }
@ -60,33 +60,33 @@ def loop_articles(process):
# Get databases of wip's articles # Get databases of wip's articles
for post_db in os.listdir(db.articles_db): for post_db in os.listdir(db.articles_db):
if post_db.endswith('.conf'): if not post_db.endswith('.conf'): continue
# Load DB
post_db = '%s%s'%(db.articles_db, post_db)
exec(open(post_db).read(),globals())
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db)
# Check hash status (wip/www) # Load DB
# wip post_db = '%s%s'%(db.articles_db, post_db)
if process == 'wip': exec(open(post_db).read(),globals())
if not db.hash_wip: continue args.target = post_src.rsplit('%s/'%db.in_dir)[1]
importlib.reload(db)
print(':> [%s] | %s'%(db.title, db.post_src)) # Check hash status (wip/www)
if process == 'wip': hash_srv = db.hash_wip
elif process == 'www': hash_srv = db.hash_www
# Article has changed and could have different stats if not hash_srv: continue
if not db.hash_wip == db.hash_chk:
logs.out("9", db.post_src, False)
continue
sti_articles += 1 print(':> [%s] | %s'%(db.title, db.post_src))
count_stats()
# www # Article has changed and could have different stats
elif process == 'www': if hash_srv != db.hash_chk:
if not db.hash_www: continue logs.out("9", db.post_src, False)
continue
create_stats_file(file_uri) sti_articles += 1
count_stats()
# Create file if article
if sti_articles > 0: create_stats_file(file_uri)
else: logs.out("28", '(%s stats)'%process, True)
#================================# #================================#

View File

@ -21,11 +21,11 @@ import os, sys, subprocess, locale, base64, datetime, shutil
from hashlib import blake2b from hashlib import blake2b
import db, logs import db, logs
domain_active = False domain_active = False
home_dir = os.path.expanduser('~') home_dir = os.path.expanduser('~')
try: in_dir = os.getcwd() try: in_dir = os.getcwd()
except: logs.out("13", '', True) except: logs.out("13", '', True)
domain_conf = in_dir domain_conf = in_dir
# Set translations: french, english # Set translations: french, english
#---------------------------------- #----------------------------------