1 Star 0 Fork 0

何俊峰/SFTP的Server和Client

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.py 1.88 KB
一键复制 编辑 原始数据 按行查看 历史
frederic he 提交于 2024-06-12 14:02 . 上传代码文件
import subprocess
import sys
import threading
import os
from datetime import datetime
import time
import json
import platform
from ProjectConfig import *
def create_directory_based_on_date():
while True:
# get current datetime
current_date = datetime.now().strftime('%Y%m%d')
directory_name = current_date
directory_path = os.path.join(CONFIG.get("root_dir"), directory_name)
if not os.path.exists(directory_path):
os.makedirs(directory_path)
print("Directory '{}' has been created.".format(directory_path))
else:
print("Directory '{}' already exists.".format(directory_path))
time.sleep(3)
def start_project(script_name):
"""Launch the specified Python script, ensuring compatibility across all platforms"""
return subprocess.Popen([sys.executable, script_name])
def main():
# thread = threading.Thread(target=create_directory_based_on_date)
# thread.start()
# start server
server_path = os.path.join(project_folder_path, 'SftpServerMax.py')
process1 = start_project(server_path)
# start client
client_path = os.path.join(project_folder_path, 'LogMiddleWarePro.py')
process2 = start_project(client_path)
process1.wait()
process2.wait()
def test():
print(os.path.join(os.getcwd(), 'config.json'))
# Get the operating system type
system_type = platform.system()
# Set the desktop path according to the operating system type
if system_type == "Windows":
desktop_path = os.path.join(os.path.expanduser("~"), "Desktop")
elif system_type == "Darwin": # The system type for macOS is "Darwin"
desktop_path = os.path.join(os.path.expanduser("~"), "Desktop")
else:
desktop_path = os.path.join(os.path.expanduser("~"), "Desktop") # Default case
print(desktop_path)
if __name__ == '__main__':
# main()
test()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/frederic-he/ServerClientOfSftp.git
git@gitee.com:frederic-he/ServerClientOfSftp.git
frederic-he
ServerClientOfSftp
SFTP的Server和Client
master

搜索帮助