fix #743 支持Rclone

This commit is contained in:
jxxghp
2023-10-11 12:16:41 +08:00
parent 5778e86260
commit 0e35cec6e2
7 changed files with 61 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import os
import platform
import re
import shutil
import subprocess
import sys
from pathlib import Path
from typing import List, Union, Tuple
@ -118,6 +119,54 @@ class SystemUtils:
print(str(err))
return -1, str(err)
@staticmethod
def rclone_move(src: Path, dest: Path):
"""
Rclone移动
"""
try:
retcode = subprocess.run(
[
'rclone', 'moveto',
str(src),
f'MP:{dest}'
],
startupinfo=SystemUtils.__get_hidden_shell()
).returncode
return retcode, ""
except Exception as err:
print(str(err))
return -1, str(err)
@staticmethod
def rclone_copy(src: Path, dest: Path):
"""
Rclone复制
"""
try:
retcode = subprocess.run(
[
'rclone', 'copyto',
str(src),
f'MP:{dest}'
],
startupinfo=SystemUtils.__get_hidden_shell()
).returncode
return retcode, ""
except Exception as err:
print(str(err))
return -1, str(err)
@staticmethod
def __get_hidden_shell():
if SystemUtils.is_windows():
st = subprocess.STARTUPINFO()
st.dwFlags = subprocess.STARTF_USESHOWWINDOW
st.wShowWindow = subprocess.SW_HIDE
return st
else:
return None
@staticmethod
def list_files(directory: Path, extensions: list, min_filesize: int = 0) -> List[Path]:
"""