You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.4 KiB
46 lines
1.4 KiB
5 months ago
|
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))
|
||
|
|
||
|
# 遍历所有文件,然后上传
|
||
|
|
||
|
|