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 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,
'metas' : html.create_user_metas,
'footer' : html.create_user_footer,
'template' : create_template
'template' : create_template,
'stats' : stats.manage_stats
}
do[target]('www')
@ -63,9 +64,9 @@ def manage_publish(target):
if db.hash_wip:
# wip and current article have different hash
if db.hash_post != db.hash_chk:
logs.out("25", db.uri_file, False)
logs.out("9", db.uri_file, False)
err_pub = True
elif db.hash_post != db.hash_wip:
elif db.hash_wip != db.hash_chk:
logs.out("30", db.uri_file, False)
err_pub = True

View File

@ -36,7 +36,7 @@ def manage_stats(process):
do = {
'wip' : loop_articles,
'www' : loop_articles,
'publish' : loop_articles,
'show-wip' : count_stats, # NO
'show_www' : count_stats, # NO
}
@ -60,33 +60,33 @@ def loop_articles(process):
# Get databases of wip's articles
for post_db in os.listdir(db.articles_db):
if post_db.endswith('.conf'):
# 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)
if not post_db.endswith('.conf'): continue
# Check hash status (wip/www)
# wip
if process == 'wip':
if not db.hash_wip: 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)
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 db.hash_wip == db.hash_chk:
logs.out("9", db.post_src, False)
continue
if not hash_srv: continue
sti_articles += 1
count_stats()
print(':> [%s] | %s'%(db.title, db.post_src))
# www
elif process == 'www':
if not db.hash_www: continue
# Article has changed and could have different stats
if hash_srv != db.hash_chk:
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
import db, logs
domain_active = False
home_dir = os.path.expanduser('~')
domain_active = False
home_dir = os.path.expanduser('~')
try: in_dir = os.getcwd()
except: logs.out("13", '', True)
domain_conf = in_dir
domain_conf = in_dir
# Set translations: french, english
#----------------------------------