added check all argument

This commit is contained in:
Cyrille L 2023-03-16 14:55:02 +01:00
parent 77ae782037
commit 3e736f8832
3 changed files with 78 additions and 35 deletions

View File

@ -21,9 +21,9 @@
import sys, os, re, datetime
from datetime import datetime
from time import gmtime, strftime
import time
import time, importlib
import logs, db, tyto
import args, logs, db, domain, tyto
post_err = False
@ -32,20 +32,15 @@ post_err = False
# Start checking article #
#-------------------------#--------------------------------------------
def manage_check(target):
domain.domain_needed()
# target needed
if not target: logs.out("5", '', True)
if not target:
logs.out("5", '', True)
global date_wip, hash_wip, date_www, hash_www, post_bottom
date_wip = hash_wip = date_www = hash_www = ''
# Article has DB
if db.db_exists:
# ... but domain needs to be active and ready
if not db.domain_active: sys.exit(1)
if db.incomplete_domain: sys.exit(1)
# ... was already check and not changed
if db.hash_chk == db.hash_post:
elif not target == 'all' \
and db.db_exists \
and db.hash_chk == db.hash_post:
logs.out("20", db.date_chk, False)
ask = ' ├ Check again this article ? '
try:
@ -53,18 +48,67 @@ def manage_check(target):
except KeyboardInterrupt:
print('')
logs.out("255", '', True)
if not res in ['y', 'Y']: return
if not res in ['y', 'Y']:
return
check_process(target)
# ... Set values for wip and www from DB
elif target == "all":
check_all()
else:
check_process(target)
if post_err and not target == 'all':
logs.out("7", '', True)
#==============================================#
# Argument all #
# check all realdy checkded articles #
# but check only if article source has changed #
#----------------------------------------------#
def check_all():
found = False
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 db.hash_post == db.hash_chk:
continue
found = True
print(':> [%s] | %s'%(db.title, db.post_src))
check_process(args.target)
if post_err:
logs.out("44", args.target, False)
if not found:
logs.out("28", '(check)', True)
#========================#
# Check articles process #
#------------------------#
def check_process(target):
global post_bottom, article_bottom
global post_words
global date_wip, hash_wip, date_www, hash_www, post_bottom
global post_err
date_wip = hash_wip = date_www = hash_www = ''
post_err = False
# Set values for wip and www from DB
if db.db_exists:
date_wip = db.date_wip
hash_wip = db.hash_wip
date_www = db.date_www
hash_www = db.hash_wip
# Set variables
#--------------
global post_bottom, article_bottom
global post_words
hash_www = db.hash_www
# Get extension from target, set short uris
ext_src = os.path.splitext(target)
@ -127,7 +171,8 @@ def manage_check(target):
if post_err:
if db.db_exists and os.path.exists(db.post_db):
os.remove(db.post_db)
logs.out("7", '', True)
#logs.out("7", '', False)
return
# No error
create_database()
@ -787,12 +832,10 @@ def create_database():
'stat_quotes = %d\n'%nbr_quotes + \
'stat_lists = %d\n'%post_lists
'''
'''
database = '%s\n%s'%(database, db_stats)
tyto.set_file(db.post_db, 'new', database)
logs.out("21", '', True)
logs.out("21", '', False)
#=====================#

View File

@ -36,8 +36,8 @@ def out(nbr, value, out):
'4' : ':< %sUnable to create file%s: %s'%(CR, CS, value),
'5' : ':< %sUnused argument%s: [file]'%(CR, CS),
'6' : ':< %sUnused "%s"%s in article'%(CR, value, CS),
'7' : ':< Article %snot valid yet%s'%(CR, CS),
'8' : ':< %sNot paired%s: %s'%(CR, CS, value),
'7' : ':< Article %snot yet valid%s'%(CR, CS),
'8' : ':< %sNot paired%s %s'%(CR, CS, value),
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS),
'10' : ':< %sUnused domain configuration%s: %s'%(CR, CS, value),
'11' : ':< %sUnused argument%s: %s'%(CR, CS, value),
@ -64,6 +64,7 @@ def out(nbr, value, out):
'41' : ':? %sIncomplete%s domain "%s"'%(CR, CS, value),
'42' : ':D %sActive%s domain "%s"'%(CG, CS, value),
'43' : ':? %sNo domain%s configured here: %s'%(CY, CS, value),
'44' : ':! %sCheck again manually%s "tyto check %s"'%(CY, CS, value),
'51' : ':? %sIncomplete data%s: %s'%(CY, CS, value),
'255' : ';) Maybe later...'
}

View File

@ -101,7 +101,6 @@ def wip_all(process):
logs.out("25", db.uri_file, False)
continue
wip_article(db.post_src)
return
#===================#