some new "try" and fixes

This commit is contained in:
Cyrille L 2023-03-07 13:05:47 +01:00
parent 616fed7a8e
commit 337fee3c8c
1 changed files with 46 additions and 26 deletions

View File

@ -182,6 +182,7 @@ def edit_file(edit_file):
if not os.path.exists(edit_file):
logs.out("1", edit_file, True)
try:
file_edit = subprocess.run(
[
'/usr/bin/nano',
@ -189,6 +190,8 @@ def edit_file(edit_file):
edit_file
]
)
except:
logs.out("1", "/usr/bin/nano", True)
#=================#
@ -304,12 +307,14 @@ def protect_icodes(post_bottom, article_bottom):
def protect_bcodes_quotes(process, post_bottom, article_bottom):
global protect_article
global nbr_titles, nbr_bcodes, nbr_quotes # Stats for DB
in_bcode = in_quote = False
end_bcode = end_quote = False
protect_article = ''
temp_article = article_bottom
nbr_titles = nbr_bcodes = nbr_quotes = 0
bcode = quote = ''
end_bcode = end_quote = False
for line in post_bottom:
# Bcode
@ -379,6 +384,7 @@ def protect_bcodes_quotes(process, post_bottom, article_bottom):
def b64(action, content, before, after):
if action == 'Encode':
global b64_content
b64_base64 = ''
content_bytes = content.encode("utf8")
base64_bytes = base64.b64encode(content_bytes)
@ -387,6 +393,7 @@ def b64(action, content, before, after):
elif action == 'Decode':
global src_content
src_content = ''
content_bytes = content.encode("utf8")
base64_bytes = base64.b64decode(content_bytes)
@ -404,8 +411,12 @@ def b64(action, content, before, after):
# to replace hash and date when done #
#------------------------------------#
def replace_in_db(post_db, process, hash_post):
try:
file_db = open(post_db, "r")
lines = file_db.readlines()
except:
logs.out("1", post_db, True)
new_file = ''
for line in lines:
@ -419,9 +430,12 @@ def replace_in_db(post_db, process, hash_post):
if new_file: new_file = '%s%s'%(new_file, line)
else: new_file = line
try:
file = open(post_db, 'w')
file.write(new_file)
file.close()
except:
logs.out("1", post_db, True)
#===================================#
@ -437,7 +451,13 @@ def files_to_srv(server):
# Create folder and subfolders
f_uri = uri.split("/")[-1]
f_uri = uri.rsplit(f_uri)[0]
try:
os.makedirs('%s%s'%(f_dst, f_uri), exist_ok=True)
except:
logs.out('4', '%s%s'%(f_dst, f_uri), True)
try:
shutil.copy2(f_src, f_dst)
logs.out("33", f_dst, False)
except:
logs.out('4', f_dst, True)