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