updated further
This commit is contained in:
@@ -87,18 +87,31 @@ class sftp_remote:
|
||||
if total_attempts == 0:
|
||||
return False
|
||||
|
||||
def change_path(self, pathfile):
|
||||
filename = pathfile.split("/")[-1]
|
||||
pathfile = self.path + filename
|
||||
utime = self.sftp.stat(pathfile).st_mtime
|
||||
last_modified = datetime.fromtimestamp(utime)
|
||||
return pathfile, last_modified
|
||||
|
||||
def delete_remote(self, source_files):
|
||||
def delete_file(self, last_modified, pathfile, delete_time):
|
||||
if (datetime.now() - last_modified) > timedelta(days= delete_time):
|
||||
print('deleting file remotely: ', pathfile)
|
||||
self.sftp.remove(pathfile)
|
||||
|
||||
def delete_remote_demos(self, source_files):
|
||||
self.connect()
|
||||
for pathfile in source_files:
|
||||
pathfile = str(pathfile)
|
||||
if not pathfile.endswith('.dem'):
|
||||
continue
|
||||
filename = pathfile.split("/")[-1]
|
||||
pathfile = self.path + filename
|
||||
utime = self.sftp.stat(pathfile).st_mtime
|
||||
last_modified = datetime.fromtimestamp(utime)
|
||||
if (datetime.now() - last_modified) > timedelta(days=30 * 1.5):
|
||||
print('deleting file remotely: ', pathfile)
|
||||
self.sftp.remove(pathfile)
|
||||
pathfile, last_modified = self.change_path(pathfile)
|
||||
self.delete_file(last_modified, pathfile, 45)
|
||||
self.disconnect()
|
||||
|
||||
def delete_remote_zips(self, zip_file_path):
|
||||
self.connect()
|
||||
if zip_file_path.endswith(".zip"):
|
||||
pathfile, last_modified = self.change_path(zip_file_path)
|
||||
self.delete_file(last_modified, pathfile, 10)
|
||||
self.disconnect()
|
||||
|
||||
Reference in New Issue
Block a user