projects-jenz/file_mover/move.py

38 lines
1.3 KiB
Python
Raw Normal View History

#!/home/gameservers/mv_map_restrictions/venv/bin/python3
import paramiko
import sys
import os
host = sys.argv[1]
user = sys.argv[2]
pw = sys.argv[3]
def upload_folder(sftp, source_folder, dest_folder):
for root, dirs, files in os.walk(source_folder):
for file in files:
source_path = os.path.join(root, file)
dest_path = os.path.join(dest_folder, os.path.relpath(source_path, source_folder))
try:
sftp.put(source_path, dest_path)
except Exception:
pass
source_file = "/home/gameservers/css_ze/cstrike/addons/sourcemod/configs/mapchooser_extended.cfg"
source_file2 = "/home/gameservers/css_ze/torchlight3/triggers.json"
source_file3 = "/home/gameservers/css_zr/cstrike/addons/sourcemod/configs/unloze_zr/"
dest_file = "/home/nonroot/html/mapchooser_css_ze/mapchooser_extended.cfg"
dest_file2 = "/home/nonroot/html/torch_sounds_ze/triggers.json"
dest_file3 = "/home/nonroot/html/unloze_zr/"
transport = paramiko.Transport((host, int(22)))
transport.connect(username = user, password = pw)
sftp = paramiko.SFTPClient.from_transport(transport)
sftp.put(source_file, dest_file)
sftp.put(source_file2, dest_file2)
upload_folder(sftp, source_file3, dest_file3)
del sftp
transport.close()