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