some fixes. sub-folders + check when post errors

This commit is contained in:
Cyrille L 2023-03-07 11:02:55 +01:00
parent 06946a5c46
commit 94f03fed2f
5 changed files with 41 additions and 12 deletions

View File

@ -49,6 +49,7 @@ pass_actions = (
pass_db = \
(
'check',
'edit',
'edit-db',
'edit-wip',
'edit-www',

View File

@ -385,6 +385,7 @@ def check_headers(post_header):
post_err = True
else:
check_file_uri('image', image_uri, ln + 1)
if not post_err:
f_uri = web_uri[1:len(web_uri)]
files_post = (files_post + "'%s', "%f_uri)
@ -424,6 +425,7 @@ def check_headers(post_header):
post_err = True
else:
check_file_uri('file', raw_uri, ln + 1)
if not post_err:
f_uri = web_uri[1:len(web_uri)]
files_post = (files_post + "'%s', "%f_uri)
@ -462,6 +464,7 @@ def check_headers(post_header):
post_err = True
else:
check_file_uri('file', file_uri, ln + 1)
if not post_err:
f_uri = web_uri[1:len(web_uri)]
files_post = (files_post + "'%s', "%f_uri)
@ -496,6 +499,7 @@ def check_headers(post_header):
snshare = True
snpic_url = '%s%s'%(db.domain_www_url, web_uri)
break
if not snshare:
logs.out("12", '%s %s'%(tyto.headers[6], snpic_name), False)
post_err = True

View File

@ -76,22 +76,24 @@ def manage_publish(target):
publish_article()
#
# Let's publish
#
#===============#
# Let's publish #
#---------------#
def publish_article():
# Copy wip page to www page
os.makedirs('%s%s'%(db.srv_www, db.direc_src), exist_ok=True)
shutil.copy2(db.post_wip, db.post_www)
logs.out("33", db.post_www, False)
tyto.files_to_srv('www')
'''
# Copy files registred in article
for uri in db.uris:
f_src = '%s%s'%(db.srv_wip, uri)
f_www = '%s%s'%(db.srv_www, uri)
shutil.copy2(f_src, f_www)
logs.out("33", f_www, False)
'''
# Replace in DB hash_wip and date_wip
tyto.replace_in_db(db.post_db, 'www', db.hash_post)

View File

@ -17,7 +17,7 @@
#**********************************************************************
import os, sys, subprocess, locale, base64, datetime
import os, sys, subprocess, locale, base64, datetime, shutil
from hashlib import blake2b
import db, logs
@ -422,3 +422,22 @@ def replace_in_db(post_db, process, hash_post):
file = open(post_db, 'w')
file.write(new_file)
file.close()
#===================================#
# Copy files used by article to srv #
#-----------------------------------#
def files_to_srv(server):
for uri in db.uris:
# Destination file to server
f_src = '%s%s'%(db.domain_articles, uri)
if server == 'wip': f_dst = '%s%s'%(db.srv_wip, uri)
elif server == 'www': f_dst = '%s%s'%(db.srv_www, uri)
# Create folder and subfolders
f_uri = uri.split("/")[-1]
f_uri = uri.rsplit(f_uri)[0]
os.makedirs('%s%s'%(f_dst, f_uri), exist_ok=True)
shutil.copy2(f_src, f_dst)
logs.out("33", f_dst, False)

View File

@ -142,13 +142,16 @@ def wip_article(target):
tyto.set_file(db.post_wip, 'New', html.main_page)
logs.out("33", db.post_wip, False)
# Copy needed file to wip
tyto.files_to_srv('wip')
'''
# Copy needed file to wip
for uri in db.uris:
f_src = '%s%s'%(db.domain_articles, uri)
f_wip = '%s%s'%(db.srv_wip, uri)
shutil.copy2(f_src, f_wip)
logs.out("33", f_wip, False)
'''
#=================================#
# Create string article from file #