added check all argument
This commit is contained in:
parent
77ae782037
commit
3e736f8832
|
@ -21,9 +21,9 @@
|
||||||
import sys, os, re, datetime
|
import sys, os, re, datetime
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import gmtime, strftime
|
from time import gmtime, strftime
|
||||||
import time
|
import time, importlib
|
||||||
|
|
||||||
import logs, db, tyto
|
import args, logs, db, domain, tyto
|
||||||
|
|
||||||
post_err = False
|
post_err = False
|
||||||
|
|
||||||
|
@ -32,39 +32,83 @@ post_err = False
|
||||||
# Start checking article #
|
# Start checking article #
|
||||||
#-------------------------#--------------------------------------------
|
#-------------------------#--------------------------------------------
|
||||||
def manage_check(target):
|
def manage_check(target):
|
||||||
|
domain.domain_needed()
|
||||||
|
|
||||||
# target needed
|
# target needed
|
||||||
if not target: logs.out("5", '', True)
|
if not target:
|
||||||
|
logs.out("5", '', True)
|
||||||
|
|
||||||
|
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:
|
||||||
|
res = input(ask)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('')
|
||||||
|
logs.out("255", '', True)
|
||||||
|
if not res in ['y', 'Y']:
|
||||||
|
return
|
||||||
|
check_process(target)
|
||||||
|
|
||||||
|
elif target == "all":
|
||||||
|
check_all()
|
||||||
|
|
||||||
|
else:
|
||||||
|
check_process(target)
|
||||||
|
|
||||||
global date_wip, hash_wip, date_www, hash_www, post_bottom
|
if post_err and not target == 'all':
|
||||||
date_wip = hash_wip = date_www = hash_www = ''
|
logs.out("7", '', True)
|
||||||
|
|
||||||
|
|
||||||
# Article has DB
|
#==============================================#
|
||||||
if db.db_exists:
|
# Argument all #
|
||||||
# ... but domain needs to be active and ready
|
# check all realdy checkded articles #
|
||||||
if not db.domain_active: sys.exit(1)
|
# but check only if article source has changed #
|
||||||
if db.incomplete_domain: sys.exit(1)
|
#----------------------------------------------#
|
||||||
|
def check_all():
|
||||||
|
found = False
|
||||||
|
|
||||||
# ... was already check and not changed
|
for post_db in os.listdir(db.articles_db):
|
||||||
if db.hash_chk == db.hash_post:
|
if post_db.endswith('.conf'):
|
||||||
logs.out("20", db.date_chk, False)
|
# Load DB
|
||||||
ask = ' ├ Check again this article ? '
|
post_db = '%s%s'%(db.articles_db, post_db)
|
||||||
try:
|
exec(open(post_db).read(),globals())
|
||||||
res = input(ask)
|
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||||
except KeyboardInterrupt:
|
importlib.reload(db)
|
||||||
print('')
|
|
||||||
logs.out("255", '', True)
|
if db.hash_post == db.hash_chk:
|
||||||
if not res in ['y', 'Y']: return
|
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)
|
||||||
|
|
||||||
# ... Set values for wip and www from DB
|
|
||||||
|
#========================#
|
||||||
|
# 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
|
date_wip = db.date_wip
|
||||||
hash_wip = db.hash_wip
|
hash_wip = db.hash_wip
|
||||||
date_www = db.date_www
|
date_www = db.date_www
|
||||||
hash_www = db.hash_wip
|
hash_www = db.hash_www
|
||||||
|
|
||||||
# Set variables
|
|
||||||
#--------------
|
|
||||||
global post_bottom, article_bottom
|
|
||||||
global post_words
|
|
||||||
|
|
||||||
# Get extension from target, set short uris
|
# Get extension from target, set short uris
|
||||||
ext_src = os.path.splitext(target)
|
ext_src = os.path.splitext(target)
|
||||||
|
@ -127,7 +171,8 @@ def manage_check(target):
|
||||||
if post_err:
|
if post_err:
|
||||||
if db.db_exists and os.path.exists(db.post_db):
|
if db.db_exists and os.path.exists(db.post_db):
|
||||||
os.remove(db.post_db)
|
os.remove(db.post_db)
|
||||||
logs.out("7", '', True)
|
#logs.out("7", '', False)
|
||||||
|
return
|
||||||
|
|
||||||
# No error
|
# No error
|
||||||
create_database()
|
create_database()
|
||||||
|
@ -787,12 +832,10 @@ def create_database():
|
||||||
'stat_quotes = %d\n'%nbr_quotes + \
|
'stat_quotes = %d\n'%nbr_quotes + \
|
||||||
'stat_lists = %d\n'%post_lists
|
'stat_lists = %d\n'%post_lists
|
||||||
|
|
||||||
'''
|
|
||||||
|
|
||||||
'''
|
|
||||||
database = '%s\n%s'%(database, db_stats)
|
database = '%s\n%s'%(database, db_stats)
|
||||||
tyto.set_file(db.post_db, 'new', database)
|
tyto.set_file(db.post_db, 'new', database)
|
||||||
logs.out("21", '', True)
|
logs.out("21", '', False)
|
||||||
|
|
||||||
|
|
||||||
#=====================#
|
#=====================#
|
||||||
|
|
|
@ -36,8 +36,8 @@ def out(nbr, value, out):
|
||||||
'4' : ':< %sUnable to create file%s: %s'%(CR, CS, value),
|
'4' : ':< %sUnable to create file%s: %s'%(CR, CS, value),
|
||||||
'5' : ':< %sUnused argument%s: [file]'%(CR, CS),
|
'5' : ':< %sUnused argument%s: [file]'%(CR, CS),
|
||||||
'6' : ':< %sUnused "%s"%s in article'%(CR, value, CS),
|
'6' : ':< %sUnused "%s"%s in article'%(CR, value, CS),
|
||||||
'7' : ':< Article %snot valid yet%s'%(CR, CS),
|
'7' : ':< Article %snot yet valid%s'%(CR, CS),
|
||||||
'8' : ':< %sNot paired%s: %s'%(CR, CS, value),
|
'8' : ':< %sNot paired%s %s'%(CR, CS, value),
|
||||||
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS),
|
'9' : ':< Article %shas changed%s. Check it first'%(CR, CS),
|
||||||
'10' : ':< %sUnused domain configuration%s: %s'%(CR, CS, value),
|
'10' : ':< %sUnused domain configuration%s: %s'%(CR, CS, value),
|
||||||
'11' : ':< %sUnused argument%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),
|
'41' : ':? %sIncomplete%s domain "%s"'%(CR, CS, value),
|
||||||
'42' : ':D %sActive%s domain "%s"'%(CG, CS, value),
|
'42' : ':D %sActive%s domain "%s"'%(CG, CS, value),
|
||||||
'43' : ':? %sNo domain%s configured here: %s'%(CY, 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),
|
'51' : ':? %sIncomplete data%s: %s'%(CY, CS, value),
|
||||||
'255' : ';) Maybe later...'
|
'255' : ';) Maybe later...'
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,6 @@ def wip_all(process):
|
||||||
logs.out("25", db.uri_file, False)
|
logs.out("25", db.uri_file, False)
|
||||||
continue
|
continue
|
||||||
wip_article(db.post_src)
|
wip_article(db.post_src)
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
#===================#
|
#===================#
|
||||||
|
|
Loading…
Reference in New Issue