Remove files found not needed(builtin options). Implement sleeping and catch some errors.
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user