Important changes in checking article DB
This commit is contained in:
parent
3e736f8832
commit
48cfe03254
|
@ -35,8 +35,7 @@ def manage_check(target):
|
|||
domain.domain_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 \
|
||||
|
@ -78,7 +77,8 @@ def check_all():
|
|||
args.target = post_src.rsplit('%s/'%db.in_dir)[1]
|
||||
importlib.reload(db)
|
||||
|
||||
if db.hash_post == db.hash_chk:
|
||||
if not db.db_exists \
|
||||
or db.hash_post == db.hash_chk:
|
||||
continue
|
||||
|
||||
found = True
|
||||
|
@ -96,6 +96,8 @@ def check_all():
|
|||
# Check articles process #
|
||||
#------------------------#
|
||||
def check_process(target):
|
||||
if not db.post_exists: sys.exit(1)
|
||||
|
||||
global post_bottom, article_bottom
|
||||
global post_words
|
||||
global date_wip, hash_wip, date_www, hash_www, post_bottom
|
||||
|
|
|
@ -31,12 +31,12 @@ target = args.target
|
|||
#======================#
|
||||
# Settings
|
||||
#---------
|
||||
domain_active = False
|
||||
domain_active = False
|
||||
incomplete_domain = False
|
||||
db_exists = False
|
||||
post_exists = False
|
||||
|
||||
home_dir = os.path.expanduser('~')
|
||||
db_exists = False
|
||||
post_exists = False
|
||||
db_remove = False
|
||||
home_dir = os.path.expanduser('~')
|
||||
|
||||
try: in_dir = os.getcwd()
|
||||
except: logs.out("13", '', True)
|
||||
|
@ -164,36 +164,42 @@ else:
|
|||
# Conditions from command line #
|
||||
# Get some post settings fom uri #
|
||||
#--------------------------------#
|
||||
# Domain must be valid
|
||||
domain.domain_needed()
|
||||
|
||||
if args.target \
|
||||
and args.action in args.pass_db \
|
||||
and not args.target in args.pass_targets:
|
||||
|
||||
uri_file = '%s/%s'%(in_dir, args.target)
|
||||
uri_id = tyto.get_filesum(uri_file, False)
|
||||
|
||||
if not os.path.exists(uri_file):
|
||||
logs.out("1", uri_file, True)
|
||||
|
||||
# Get hash for uri and content file
|
||||
post_exists = True
|
||||
uri_id = tyto.get_filesum(uri_file, False)
|
||||
hash_post = tyto.get_filesum(uri_file, True)
|
||||
|
||||
# Domain must be valid
|
||||
domain.domain_needed()
|
||||
|
||||
# Set DB file for this post
|
||||
post_db = '%s%s.conf'%(articles_db, uri_id)
|
||||
if not os.path.exists(post_db):
|
||||
db_exists = False
|
||||
# DB
|
||||
post_db = '%s%s.conf'%(articles_db, uri_id)
|
||||
if os.path.exists(post_db):
|
||||
db_exists = True
|
||||
else:
|
||||
if os.stat(post_db).st_size < 1000:
|
||||
os.remove(post_db)
|
||||
db_exists = False
|
||||
|
||||
# Article
|
||||
if os.path.exists(uri_file):
|
||||
post_exists = True
|
||||
hash_post = tyto.get_filesum(uri_file, True)
|
||||
else:
|
||||
post_exists = False
|
||||
logs.out("1", uri_file, False)
|
||||
|
||||
#
|
||||
if db_exists:
|
||||
if not post_exists:
|
||||
db_remove = True
|
||||
elif os.stat(post_db).st_size < 1000:
|
||||
db_remove = True
|
||||
logs.out('23', post_db, False)
|
||||
|
||||
if db_remove:
|
||||
os.remove(post_db)
|
||||
db_exists = False
|
||||
else:
|
||||
db_exists = True
|
||||
|
||||
# Load post database
|
||||
if db_exists:
|
||||
exec(open(post_db).read(),globals())
|
||||
exec(open(post_db).read(),globals())
|
||||
|
||||
|
|
|
@ -33,12 +33,12 @@ def manage_publish(target):
|
|||
#-----------------------------------------
|
||||
if target in args.pass_targets:
|
||||
do = {
|
||||
'all' : create_all,
|
||||
'all' : publish_all,
|
||||
'sidebar' : html.create_sidebar,
|
||||
'navbar' : html.create_navbar,
|
||||
'metas' : html.create_user_metas,
|
||||
'footer' : html.create_user_footer,
|
||||
'template' : create_template,
|
||||
'template' : publish_template,
|
||||
'stats' : stats.manage_stats
|
||||
}
|
||||
|
||||
|
@ -46,8 +46,9 @@ def manage_publish(target):
|
|||
return
|
||||
|
||||
# Database must exists...
|
||||
if not db.db_exists:
|
||||
logs.out("25", db.uri_file, True)
|
||||
if not target: logs.out("5", '', True)
|
||||
if not db.post_exists: sys.exit(1)
|
||||
if not db.db_exists: logs.out("25", db.uri_file, True)
|
||||
|
||||
|
||||
# Publish in www server an article
|
||||
|
@ -104,7 +105,7 @@ def replace_line_pub():
|
|||
#================================#
|
||||
# Publish template in www server #
|
||||
#--------------------------------#
|
||||
def create_template(option):
|
||||
def publish_template(option):
|
||||
print( \
|
||||
'! Note:\n',
|
||||
' - footer, sidebar, metas, navbar\n',
|
||||
|
@ -156,7 +157,7 @@ def create_template(option):
|
|||
#============================================#
|
||||
# Option 'all' to publish again, based on DB #
|
||||
#--------------------------------------------#
|
||||
def create_all(option):
|
||||
def publish_all(option):
|
||||
ask = ''
|
||||
try:
|
||||
ask = input(" ├ Publish again all already published articles ? ")
|
||||
|
@ -178,7 +179,8 @@ def create_all(option):
|
|||
importlib.reload(db)
|
||||
|
||||
# Conditions to publish
|
||||
if not db.hash_www:
|
||||
if not db.db_exists \
|
||||
or not db.hash_www:
|
||||
continue
|
||||
|
||||
print(':> [%s] | %s'%(db.title, db.post_src))
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#**********************************************************************
|
||||
|
||||
import os, re, shutil, importlib
|
||||
import os, re, sys, shutil, importlib
|
||||
import logs, args, db, tyto, html, domain, stats
|
||||
|
||||
|
||||
|
@ -50,8 +50,9 @@ def manage_wip(target):
|
|||
|
||||
# Per article with target
|
||||
#------------------------
|
||||
if not target: logs.out("5", '', True)
|
||||
if not db.db_exists: logs.out("25", db.uri_file, True)
|
||||
if not target: logs.out("5", '', True)
|
||||
if not db.post_exists: sys.exit(1)
|
||||
if not db.db_exists: logs.out("25", db.uri_file, True)
|
||||
|
||||
# Exit if article has changed
|
||||
if db.hash_chk != db.hash_post:
|
||||
|
|
Loading…
Reference in New Issue