blob: af3fd3db9106309dfc0ba1f18091b70690f583fa (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
try:
from serenitas.utils.env import DAILY_DIR
except KeyError:
sys.exit("Please set 'DAILY_DIR' in the environment")
from serenitas.utils.remote import SftpClient
def download_files():
sftp = SftpClient.from_creds("ice")
dst = DAILY_DIR / "ICE_reports"
import stat
for f in sftp.client.listdir_attr("/"):
local_file = dst / f.filename
if (not local_file.exists()) and (not stat.S_ISDIR(f.st_mode)):
sftp.client.get(f"//{f.filename}", localpath=local_file)
if __name__ == "__main__":
download_files()
|