check: corrupt database. wip: add hash and date to database
This commit is contained in:
parent
2d2d3b564e
commit
cee1c67739
|
@ -50,9 +50,14 @@ def manage_check(target, option):
|
||||||
return
|
return
|
||||||
|
|
||||||
if db_exists:
|
if db_exists:
|
||||||
|
try:
|
||||||
exec(open(tyto.post_db).read(),globals())
|
exec(open(tyto.post_db).read(),globals())
|
||||||
|
try:
|
||||||
if hash_chk == tyto.hash_post and not option == 'Force':
|
if hash_chk == tyto.hash_post and not option == 'Force':
|
||||||
tyto.exiting("20", date_chk, True)
|
tyto.exiting("20", date_chk, True)
|
||||||
|
except: pass
|
||||||
|
except: pass
|
||||||
|
|
||||||
|
|
||||||
# Start processes
|
# Start processes
|
||||||
file_to_string(tyto.uri_root)
|
file_to_string(tyto.uri_root)
|
||||||
|
@ -604,12 +609,12 @@ def create_database():
|
||||||
'wip_uri = "%s%s"\n'%(srv_wip, web_uri) + \
|
'wip_uri = "%s%s"\n'%(srv_wip, web_uri) + \
|
||||||
'www_uri = "%s%s"\n'%(srv_www, web_uri) + \
|
'www_uri = "%s%s"\n'%(srv_www, web_uri) + \
|
||||||
'http_uri = "%s"\n'%tyto.web_uri + \
|
'http_uri = "%s"\n'%tyto.web_uri + \
|
||||||
'hash_wip = ""\n' + \
|
|
||||||
'date_www = ""\n' + \
|
|
||||||
'hash_www = ""\n' + \
|
|
||||||
'date_chk = "%s"\n'%tyto.nowdate() + \
|
'date_chk = "%s"\n'%tyto.nowdate() + \
|
||||||
'hash_chk = "%s"\n'%tyto.hash_post + \
|
'hash_chk = "%s"\n'%tyto.hash_post + \
|
||||||
'date_wip = ""\n' + \
|
'date_wip = ""\n' + \
|
||||||
|
'hash_wip = ""\n' + \
|
||||||
|
'date_www = ""\n' + \
|
||||||
|
'hash_www = ""\n' + \
|
||||||
'\n# Post configuration from needed tags\n' + \
|
'\n# Post configuration from needed tags\n' + \
|
||||||
'title = "%s"\n'%title + \
|
'title = "%s"\n'%title + \
|
||||||
'about = "%s"\n'%about + \
|
'about = "%s"\n'%about + \
|
||||||
|
|
|
@ -232,6 +232,12 @@ def get_db_post(target):
|
||||||
if os.path.exists(post_db): db_exists = True
|
if os.path.exists(post_db): db_exists = True
|
||||||
else : db_exists = False
|
else : db_exists = False
|
||||||
|
|
||||||
|
# Check if null byte
|
||||||
|
if db_exists and os.stat(post_db).st_size < 1000:
|
||||||
|
os.remove(post_db)
|
||||||
|
exiting('23', post_db, False)
|
||||||
|
db_exists = False
|
||||||
|
|
||||||
return(db_exists)
|
return(db_exists)
|
||||||
|
|
||||||
|
|
||||||
|
@ -449,6 +455,33 @@ def b64(action, content, before, after):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Replace in post_db
|
||||||
|
# Used for wip and publish
|
||||||
|
# to replace hash and date when done
|
||||||
|
#
|
||||||
|
def replace_in_db(post_db, process, hash_post):
|
||||||
|
file_db = open(post_db, "r")
|
||||||
|
lines = file_db.readlines()
|
||||||
|
new_file = ''
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if line.startswith('hash_%s'%process):
|
||||||
|
line = line.replace(line, 'hash_%s = "%s"'%(process, hash_post))
|
||||||
|
new_file = '%s%s\n'%(new_file, line)
|
||||||
|
elif line.startswith('date_%s'%process):
|
||||||
|
line = line.replace(line, 'date_%s = "%s"'%(process, nowdate()))
|
||||||
|
new_file = '%s%s\n'%(new_file, line)
|
||||||
|
else:
|
||||||
|
if new_file: new_file = '%s%s'%(new_file, line)
|
||||||
|
else: new_file = line
|
||||||
|
|
||||||
|
file = open(post_db, 'w')
|
||||||
|
file.write(new_file)
|
||||||
|
file.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#================================#
|
#================================#
|
||||||
# Exit from program with message #
|
# Exit from program with message #
|
||||||
#--------------------------------#
|
#--------------------------------#
|
||||||
|
@ -467,6 +500,7 @@ def exiting(nbr, value, out):
|
||||||
'20' : ':D Article already up-to-date on: %s'%value,
|
'20' : ':D Article already up-to-date on: %s'%value,
|
||||||
'21' : ':D \033[1;32mArticle is valid\033[0;0m and ready to wip',
|
'21' : ':D \033[1;32mArticle is valid\033[0;0m and ready to wip',
|
||||||
'22' : ':? Symbols: %s \033[1;33mnot paired\033[0;0m'%value,
|
'22' : ':? Symbols: %s \033[1;33mnot paired\033[0;0m'%value,
|
||||||
|
'23' : ':< \033[1;33mDatabase was corrupt\033[0;0m: %s'%value,
|
||||||
'255' : ':| Maybe later...'
|
'255' : ':| Maybe later...'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@ def wip_article(target):
|
||||||
|
|
||||||
# Result (temp display)
|
# Result (temp display)
|
||||||
print(article_bottom)
|
print(article_bottom)
|
||||||
|
tyto.replace_in_db(tyto.post_db, 'wip', tyto.hash_post)
|
||||||
|
|
||||||
|
|
||||||
#=================================#
|
#=================================#
|
||||||
|
|
Loading…
Reference in New Issue