generated from pavel.muhortov/template-bash
split logging by logger
This commit is contained in:
parent
bff385d0a5
commit
ba72ef9407
|
@ -608,7 +608,6 @@ class FFmpeg:
|
||||||
|
|
||||||
|
|
||||||
class Connect:
|
class Connect:
|
||||||
# pylint: disable=W0105
|
|
||||||
"""Set of connection methods (functions) for various protocols.
|
"""Set of connection methods (functions) for various protocols.
|
||||||
"""
|
"""
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -778,7 +777,7 @@ class Connect:
|
||||||
sftp.put(localpath=src_file, remotepath=dst_file)
|
sftp.put(localpath=src_file, remotepath=dst_file)
|
||||||
sftp.stat(dst_file)
|
sftp.stat(dst_file)
|
||||||
sftp.close()
|
sftp.close()
|
||||||
local_logger.info(msg=dst_file + ' saved')
|
local_logger.info(msg='sftp://' + hostname + dst_file + ' saved')
|
||||||
return dst_file
|
return dst_file
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
local_logger.debug(msg='error: ' + '\n' + str(error))
|
local_logger.debug(msg='error: ' + '\n' + str(error))
|
||||||
|
@ -790,7 +789,7 @@ class Connect:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
# pylint: disable=W0718
|
# pylint: disable=W0718
|
||||||
def ftp_file_search(
|
def ftp_file_search(
|
||||||
root_path: (str),
|
root_path: str,
|
||||||
search_name: (str, type(None)) = None,
|
search_name: (str, type(None)) = None,
|
||||||
ftp: FTP = None,
|
ftp: FTP = None,
|
||||||
hostname: str = None,
|
hostname: str = None,
|
||||||
|
@ -817,9 +816,9 @@ class Connect:
|
||||||
+ '\n' + 'root_path: ' + root_path
|
+ '\n' + 'root_path: ' + root_path
|
||||||
+ '\n' + 'search_name: ' + str(search_name)
|
+ '\n' + 'search_name: ' + str(search_name)
|
||||||
+ '\n' + 'ftp: ' + str(ftp)
|
+ '\n' + 'ftp: ' + str(ftp)
|
||||||
+ '\n' + 'hostname: ' + hostname
|
+ '\n' + 'hostname: ' + str(hostname)
|
||||||
+ '\n' + 'username: ' + username
|
+ '\n' + 'username: ' + str(username)
|
||||||
+ '\n' + 'password: ' + password
|
+ '\n' + 'password: ' + str(password)
|
||||||
)
|
)
|
||||||
parent = False
|
parent = False
|
||||||
if not ftp:
|
if not ftp:
|
||||||
|
@ -852,7 +851,7 @@ class Connect:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
# pylint: disable=W0718,C0116
|
# pylint: disable=W0718
|
||||||
def ftp_get_file(
|
def ftp_get_file(
|
||||||
src_file: str,
|
src_file: str,
|
||||||
dst_file: str,
|
dst_file: str,
|
||||||
|
@ -895,7 +894,7 @@ class Connect:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
# pylint: disable=W0718,C0116
|
# pylint: disable=W0718
|
||||||
def ftp_put_file(
|
def ftp_put_file(
|
||||||
src_file: str,
|
src_file: str,
|
||||||
dst_file: str,
|
dst_file: str,
|
||||||
|
@ -941,7 +940,7 @@ class Connect:
|
||||||
with open(src_file, "rb") as file:
|
with open(src_file, "rb") as file:
|
||||||
ftp.storbinary(f"STOR {dst_file}", file)
|
ftp.storbinary(f"STOR {dst_file}", file)
|
||||||
ftp.quit()
|
ftp.quit()
|
||||||
local_logger.info(msg=dst_file + ' saved')
|
local_logger.info(msg='ftp://' + hostname + dst_file + ' saved')
|
||||||
return True
|
return True
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
local_logger.debug(msg='error: ' + '\n' + str(error))
|
local_logger.debug(msg='error: ' + '\n' + str(error))
|
||||||
|
@ -2408,7 +2407,8 @@ class Sequence:
|
||||||
dst_file=dst_file,
|
dst_file=dst_file,
|
||||||
hostname=hostname,
|
hostname=hostname,
|
||||||
username=username,
|
username=username,
|
||||||
password=userpass
|
password=userpass,
|
||||||
|
logger_alias=logger_alias
|
||||||
):
|
):
|
||||||
try:
|
try:
|
||||||
remove(src_file)
|
remove(src_file)
|
||||||
|
@ -2425,9 +2425,14 @@ class Sequence:
|
||||||
+ records_file_name
|
+ records_file_name
|
||||||
)
|
)
|
||||||
response = Connect.ssh_put_file(
|
response = Connect.ssh_put_file(
|
||||||
src_file=src_file, dst_file=dst_file,
|
src_file=src_file,
|
||||||
hostname=hostname, port=hostport,
|
dst_file=dst_file,
|
||||||
username=username, password=userpass)
|
hostname=hostname,
|
||||||
|
port=hostport,
|
||||||
|
username=username,
|
||||||
|
password=userpass,
|
||||||
|
logger_alias=logger_alias
|
||||||
|
)
|
||||||
if response != 'ERROR':
|
if response != 'ERROR':
|
||||||
try:
|
try:
|
||||||
remove(src_file)
|
remove(src_file)
|
||||||
|
@ -2584,7 +2589,7 @@ class Convert:
|
||||||
+ ' -y'
|
+ ' -y'
|
||||||
)
|
)
|
||||||
|
|
||||||
if FFmpeg.run(raw=video_conv_conf) == 0:
|
if FFmpeg.run(raw=video_conv_conf, logger_alias=logger_alias) == 0:
|
||||||
temp_files.append(video_temp_path)
|
temp_files.append(video_temp_path)
|
||||||
|
|
||||||
if '://' in video_dest_path:
|
if '://' in video_dest_path:
|
||||||
|
@ -2613,7 +2618,8 @@ class Convert:
|
||||||
dst_file=video_hostpath + '/' + video_converted,
|
dst_file=video_hostpath + '/' + video_converted,
|
||||||
hostname=video_hostname,
|
hostname=video_hostname,
|
||||||
username=video_dest_user,
|
username=video_dest_user,
|
||||||
password=video_dest_pass
|
password=video_dest_pass,
|
||||||
|
logger_alias=logger_alias
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
elif image_hosttype == 'sftp':
|
elif image_hosttype == 'sftp':
|
||||||
|
@ -2730,7 +2736,8 @@ class Publish:
|
||||||
search_name=name + '_' + video_find_sufx + '.mp4',
|
search_name=name + '_' + video_find_sufx + '.mp4',
|
||||||
hostname=video_hostname,
|
hostname=video_hostname,
|
||||||
username=video_root_user,
|
username=video_root_user,
|
||||||
password=video_root_pass
|
password=video_root_pass,
|
||||||
|
logger_alias=logger_alias
|
||||||
)
|
)
|
||||||
makedirs(temp_path, exist_ok=True)
|
makedirs(temp_path, exist_ok=True)
|
||||||
for video in video_found:
|
for video in video_found:
|
||||||
|
@ -2739,7 +2746,8 @@ class Publish:
|
||||||
dst_file=temp_path + sep + path.basename(video),
|
dst_file=temp_path + sep + path.basename(video),
|
||||||
hostname=video_hostname,
|
hostname=video_hostname,
|
||||||
username=video_root_user,
|
username=video_root_user,
|
||||||
password=video_root_pass
|
password=video_root_pass,
|
||||||
|
logger_alias=logger_alias
|
||||||
):
|
):
|
||||||
temp_files.append(temp_path + sep + path.basename(video))
|
temp_files.append(temp_path + sep + path.basename(video))
|
||||||
video_files[publish_period][name] = (
|
video_files[publish_period][name] = (
|
||||||
|
@ -2757,7 +2765,8 @@ class Publish:
|
||||||
targets_media_files=video_files,
|
targets_media_files=video_files,
|
||||||
period=publish_date['period'],
|
period=publish_date['period'],
|
||||||
amount=publish_amount,
|
amount=publish_amount,
|
||||||
chat=tg_chat_id
|
chat=tg_chat_id,
|
||||||
|
logger_alias=logger_alias
|
||||||
)
|
)
|
||||||
if wp_site_name:
|
if wp_site_name:
|
||||||
wp = Wordpress(
|
wp = Wordpress(
|
||||||
|
@ -2770,7 +2779,8 @@ class Publish:
|
||||||
targets_media_files=video_files,
|
targets_media_files=video_files,
|
||||||
period=publish_date['period'],
|
period=publish_date['period'],
|
||||||
amount=publish_amount,
|
amount=publish_amount,
|
||||||
page_id=wp_update_page_id
|
page_id=wp_update_page_id,
|
||||||
|
logger_alias=logger_alias
|
||||||
)
|
)
|
||||||
|
|
||||||
for temp_file in temp_files:
|
for temp_file in temp_files:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user