some fixes. sub-folders + check when post errors
This commit is contained in:
parent
06946a5c46
commit
94f03fed2f
|
@ -49,6 +49,7 @@ pass_actions = (
|
||||||
pass_db = \
|
pass_db = \
|
||||||
(
|
(
|
||||||
'check',
|
'check',
|
||||||
|
'edit',
|
||||||
'edit-db',
|
'edit-db',
|
||||||
'edit-wip',
|
'edit-wip',
|
||||||
'edit-www',
|
'edit-www',
|
||||||
|
|
|
@ -385,6 +385,7 @@ def check_headers(post_header):
|
||||||
post_err = True
|
post_err = True
|
||||||
else:
|
else:
|
||||||
check_file_uri('image', image_uri, ln + 1)
|
check_file_uri('image', image_uri, ln + 1)
|
||||||
|
if not post_err:
|
||||||
f_uri = web_uri[1:len(web_uri)]
|
f_uri = web_uri[1:len(web_uri)]
|
||||||
files_post = (files_post + "'%s', "%f_uri)
|
files_post = (files_post + "'%s', "%f_uri)
|
||||||
|
|
||||||
|
@ -424,6 +425,7 @@ def check_headers(post_header):
|
||||||
post_err = True
|
post_err = True
|
||||||
else:
|
else:
|
||||||
check_file_uri('file', raw_uri, ln + 1)
|
check_file_uri('file', raw_uri, ln + 1)
|
||||||
|
if not post_err:
|
||||||
f_uri = web_uri[1:len(web_uri)]
|
f_uri = web_uri[1:len(web_uri)]
|
||||||
files_post = (files_post + "'%s', "%f_uri)
|
files_post = (files_post + "'%s', "%f_uri)
|
||||||
|
|
||||||
|
@ -462,6 +464,7 @@ def check_headers(post_header):
|
||||||
post_err = True
|
post_err = True
|
||||||
else:
|
else:
|
||||||
check_file_uri('file', file_uri, ln + 1)
|
check_file_uri('file', file_uri, ln + 1)
|
||||||
|
if not post_err:
|
||||||
f_uri = web_uri[1:len(web_uri)]
|
f_uri = web_uri[1:len(web_uri)]
|
||||||
files_post = (files_post + "'%s', "%f_uri)
|
files_post = (files_post + "'%s', "%f_uri)
|
||||||
|
|
||||||
|
@ -496,6 +499,7 @@ def check_headers(post_header):
|
||||||
snshare = True
|
snshare = True
|
||||||
snpic_url = '%s%s'%(db.domain_www_url, web_uri)
|
snpic_url = '%s%s'%(db.domain_www_url, web_uri)
|
||||||
break
|
break
|
||||||
|
|
||||||
if not snshare:
|
if not snshare:
|
||||||
logs.out("12", '%s %s'%(tyto.headers[6], snpic_name), False)
|
logs.out("12", '%s %s'%(tyto.headers[6], snpic_name), False)
|
||||||
post_err = True
|
post_err = True
|
||||||
|
|
|
@ -76,22 +76,24 @@ def manage_publish(target):
|
||||||
publish_article()
|
publish_article()
|
||||||
|
|
||||||
|
|
||||||
#
|
#===============#
|
||||||
# Let's publish
|
# Let's publish #
|
||||||
#
|
#---------------#
|
||||||
def publish_article():
|
def publish_article():
|
||||||
# Copy wip page to www page
|
# Copy wip page to www page
|
||||||
os.makedirs('%s%s'%(db.srv_www, db.direc_src), exist_ok=True)
|
os.makedirs('%s%s'%(db.srv_www, db.direc_src), exist_ok=True)
|
||||||
shutil.copy2(db.post_wip, db.post_www)
|
shutil.copy2(db.post_wip, db.post_www)
|
||||||
logs.out("33", db.post_www, False)
|
logs.out("33", db.post_www, False)
|
||||||
|
|
||||||
|
tyto.files_to_srv('www')
|
||||||
|
'''
|
||||||
# Copy files registred in article
|
# Copy files registred in article
|
||||||
for uri in db.uris:
|
for uri in db.uris:
|
||||||
f_src = '%s%s'%(db.srv_wip, uri)
|
f_src = '%s%s'%(db.srv_wip, uri)
|
||||||
f_www = '%s%s'%(db.srv_www, uri)
|
f_www = '%s%s'%(db.srv_www, uri)
|
||||||
shutil.copy2(f_src, f_www)
|
shutil.copy2(f_src, f_www)
|
||||||
logs.out("33", f_www, False)
|
logs.out("33", f_www, False)
|
||||||
|
'''
|
||||||
|
|
||||||
# Replace in DB hash_wip and date_wip
|
# Replace in DB hash_wip and date_wip
|
||||||
tyto.replace_in_db(db.post_db, 'www', db.hash_post)
|
tyto.replace_in_db(db.post_db, 'www', db.hash_post)
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#**********************************************************************
|
#**********************************************************************
|
||||||
|
|
||||||
import os, sys, subprocess, locale, base64, datetime
|
import os, sys, subprocess, locale, base64, datetime, shutil
|
||||||
from hashlib import blake2b
|
from hashlib import blake2b
|
||||||
|
|
||||||
import db, logs
|
import db, logs
|
||||||
|
@ -422,3 +422,22 @@ def replace_in_db(post_db, process, hash_post):
|
||||||
file = open(post_db, 'w')
|
file = open(post_db, 'w')
|
||||||
file.write(new_file)
|
file.write(new_file)
|
||||||
file.close()
|
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)
|
||||||
|
|
|
@ -142,13 +142,16 @@ def wip_article(target):
|
||||||
tyto.set_file(db.post_wip, 'New', html.main_page)
|
tyto.set_file(db.post_wip, 'New', html.main_page)
|
||||||
logs.out("33", db.post_wip, False)
|
logs.out("33", db.post_wip, False)
|
||||||
|
|
||||||
|
# Copy needed file to wip
|
||||||
|
tyto.files_to_srv('wip')
|
||||||
|
'''
|
||||||
# Copy needed file to wip
|
# Copy needed file to wip
|
||||||
for uri in db.uris:
|
for uri in db.uris:
|
||||||
f_src = '%s%s'%(db.domain_articles, uri)
|
f_src = '%s%s'%(db.domain_articles, uri)
|
||||||
f_wip = '%s%s'%(db.srv_wip, uri)
|
f_wip = '%s%s'%(db.srv_wip, uri)
|
||||||
shutil.copy2(f_src, f_wip)
|
shutil.copy2(f_src, f_wip)
|
||||||
logs.out("33", f_wip, False)
|
logs.out("33", f_wip, False)
|
||||||
|
'''
|
||||||
|
|
||||||
#=================================#
|
#=================================#
|
||||||
# Create string article from file #
|
# Create string article from file #
|
||||||
|
|
Loading…
Reference in New Issue