zhangshu
5 months ago
5 changed files with 77 additions and 7 deletions
@ -0,0 +1,45 @@ |
|||||
|
import os |
||||
|
import shutil |
||||
|
import paramiko |
||||
|
import argparse |
||||
|
import Contant |
||||
|
from LoggerUtils import Logger, initLogger |
||||
|
import configparser |
||||
|
import requests |
||||
|
import time |
||||
|
import json |
||||
|
|
||||
|
if __name__ == "__main__": |
||||
|
# 读取配置文件 |
||||
|
with open('search_video_config.json', 'r', encoding='utf-8') as f: |
||||
|
# 使用json.load()方法读取文件内容 |
||||
|
data = json.load(f) |
||||
|
# 初始化日志 |
||||
|
Contant.logDir = data['log']['dir'] |
||||
|
Contant.logFileName = data['log']['fileName'] |
||||
|
initLogger(Contant.logDir, Contant.logFileName) |
||||
|
|
||||
|
# 设置sftp client |
||||
|
hostname = data['sftp']['hostname'] |
||||
|
port = data['sftp']['port'] |
||||
|
username = data['sftp']['username'] |
||||
|
password = data['sftp']['password'] |
||||
|
|
||||
|
Logger.info("host:{},port:{},username:{},password:{}".format( |
||||
|
hostname, port, username, password)) |
||||
|
|
||||
|
ssh_client = paramiko.SSHClient() |
||||
|
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
||||
|
sftp_client = None # 设置默认值 |
||||
|
ssh_client.connect(hostname, port, username, password) |
||||
|
# 创建SFTP客户端 |
||||
|
sftp_client = ssh_client.open_sftp() |
||||
|
Logger.info("SFTP客户端已经建立:{}".format(sftp_client)) |
||||
|
|
||||
|
remote_root = "/Inbound/YouTube Captions" |
||||
|
local_root = data['sftp']['local'] |
||||
|
Logger.info("remote_root:{},local_root:{}".format(remote_root, local_root)) |
||||
|
|
||||
|
# 遍历所有文件,然后上传 |
||||
|
|
||||
|
|
@ -0,0 +1,20 @@ |
|||||
|
{ |
||||
|
"mysql": { |
||||
|
"host": "47.108.20.249", |
||||
|
"port": "3306", |
||||
|
"username": "root", |
||||
|
"password": "casino888!", |
||||
|
"database": "youtube" |
||||
|
}, |
||||
|
"log": { |
||||
|
"dir": "./logs", |
||||
|
"fileName": "sftp" |
||||
|
}, |
||||
|
"sftp": { |
||||
|
"local": "E:/code/tmp/main", |
||||
|
"hostname": "filetransfer.blackrock.com", |
||||
|
"port": "22", |
||||
|
"username": "ftp_yunbo", |
||||
|
"password": "s8v{8SJr" |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue