Remove files found not needed(builtin options). Implement sleeping and catch some errors.

This commit is contained in:
2023-11-04 17:49:11 -04:00
parent e28f647a60
commit 70ce4477a8
6 changed files with 242 additions and 332 deletions

View File

@@ -1,7 +1,6 @@
import ElementTree
import urequests
from urequests import auth
import gc
import gc, sys
import ElementTree
class uNextcloud:
@@ -28,7 +27,7 @@ class uNextcloud:
self.password = password
def get_folder_items(self, folder_path=""):
response = urequests.request("PROPFIND", self.url+"/remote.php/dav/files/"+self.username+"/"+folder_path, auth=urequests.auth.HTTPBasicAuth(self.username, self.password))
response = urequests.request("PROPFIND", self.url+"/remote.php/dav/files/"+self.username+"/"+folder_path, auth=(self.username, self.password))
if 200 <= response.status_code < 300:
file_list = []
try:
@@ -53,7 +52,7 @@ class uNextcloud:
return None
def download_file_to_path(self, url_path, destination_path):
response = urequests.request("GET", self.url+url_path, auth=urequests.auth.HTTPBasicAuth(self.username, self.password))
response = urequests.request("GET", self.url+url_path, auth=(self.username, self.password))
if 200 <= response.status_code < 300:
dest = open(destination_path, 'wb')
data = bytearray(1024)
@@ -65,7 +64,6 @@ class uNextcloud:
break
len += 1024
dest.write(data)
print(gc.mem_free())
dest.close()
response.close()
gc.collect()