diff --git a/src/var/lib/tyto/program/publish.py b/src/var/lib/tyto/program/publish.py index bebea51..e6dfdce 100644 --- a/src/var/lib/tyto/program/publish.py +++ b/src/var/lib/tyto/program/publish.py @@ -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 diff --git a/src/var/lib/tyto/program/stats.py b/src/var/lib/tyto/program/stats.py index f5d1dd4..9263c83 100644 --- a/src/var/lib/tyto/program/stats.py +++ b/src/var/lib/tyto/program/stats.py @@ -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 + + # 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) + if process == 'wip': hash_srv = db.hash_wip + elif process == 'www': hash_srv = db.hash_www + + if not hash_srv: continue - # Check hash status (wip/www) - # wip - if process == 'wip': - if not db.hash_wip: continue - - print(':> [%s] | %s'%(db.title, db.post_src)) - - # Article has changed and could have different stats - if not db.hash_wip == db.hash_chk: - logs.out("9", db.post_src, False) - continue - - sti_articles += 1 - count_stats() + print(':> [%s] | %s'%(db.title, db.post_src)) + + # Article has changed and could have different stats + if hash_srv != db.hash_chk: + logs.out("9", db.post_src, False) + continue + + sti_articles += 1 + count_stats() - # www - elif process == 'www': - if not db.hash_www: continue - - create_stats_file(file_uri) + # Create file if article + if sti_articles > 0: create_stats_file(file_uri) + else: logs.out("28", '(%s stats)'%process, True) #================================# diff --git a/src/var/lib/tyto/program/tyto.py b/src/var/lib/tyto/program/tyto.py index f45d823..6acd320 100644 --- a/src/var/lib/tyto/program/tyto.py +++ b/src/var/lib/tyto/program/tyto.py @@ -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 #----------------------------------