удалять, тоже через sftp
#!/usr/bin/python
import cv2
import os
import pysftp
stream_url = 'http://192.168.2.67/action/snapshot/'
absolute_script_dir = os.path.dirname(os.path.realpath(__file__))
save_dir = absolute_script_dir + '/snapshots/'
save_path = save_dir + '/snapshot.jpg'
cap = cv2.VideoCapture(stream_url)
ret, frame = cap.read()
cv2.imwrite(save_path, frame)
cnopts = pysftp.CnOpts()
cnopts.hostkeys = None
with pysftp.Connection('ftp.ru', username='user', password='pass', cnopts=cnopts) as sftp:
remote = 'telega/snapshot.jpg'
local = 'C:\\telega\\snapshots\\snapshot.jpg'
sftp.put(local,remote)
sftp.close()
ошибка
Warning (from warnings module):
File “C:\Users\checkout\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pysftp\__init__.py”, line 61
warnings.warn(wmsg, UserWarning)
UserWarning: Failed to load HostKeys from C:\Users\checkout\.ssh\known_hosts. You will need to explicitly load HostKeys (cnopts.hostkeys.load(filename)) or disableHostKey checking (cnopts.hostkeys = None).