Fehler abfangen
This commit is contained in:
parent
b5c9d05de3
commit
b0525d99d3
Binary file not shown.
|
|
@ -1181,40 +1181,46 @@ def getNCDirInfosURL(request, ncid):
|
|||
@register.simple_tag
|
||||
def getAGGroupQuotaData(request):
|
||||
r = requests.request("PROPFIND", settings.NEXTCLOUD_URL + "remote.php/dav/files/" + request.user.username + "/Agenturdaten", headers={'Content-Type' : 'text/xml', 'Authorization' : "Bearer " + request.user.profile.nc_sid})
|
||||
|
||||
# IN USE
|
||||
split_response = r.text.split("<d:quota-used-bytes>")
|
||||
inuse = split_response[1].split("</d:quota-used-bytes>")[0]
|
||||
|
||||
# QUOTA
|
||||
split_response = r.text.split("<d:quota-available-bytes>")
|
||||
quota = split_response[1].split("</d:quota-available-bytes>")[0]
|
||||
try:
|
||||
# IN USE
|
||||
split_response = r.text.split("<d:quota-used-bytes>")
|
||||
inuse = split_response[1].split("</d:quota-used-bytes>")[0]
|
||||
|
||||
# QUOTA
|
||||
split_response = r.text.split("<d:quota-available-bytes>")
|
||||
quota = split_response[1].split("</d:quota-available-bytes>")[0]
|
||||
|
||||
# PERCENT VALUE
|
||||
percent = (100 / int(quota))*int(inuse)
|
||||
# PERCENT VALUE
|
||||
percent = (100 / int(quota))*int(inuse)
|
||||
return [quota, inuse, str(round(percent, 0)).replace(",", ".")]
|
||||
except:
|
||||
return [0, 0, 0]
|
||||
|
||||
return [quota, inuse, str(round(percent, 0)).replace(",", ".")]
|
||||
|
||||
|
||||
|
||||
# User QUOTA
|
||||
import re, math
|
||||
@register.simple_tag
|
||||
def getUserQuotaData(userdata):
|
||||
r = requests.request("GET", settings.NEXTCLOUD_URL + "/ocs/v1.php/cloud/users/" + userdata.username, auth=(settings.NEXTCLOUD_USER_API, settings.NEXTCLOUD_PW_API), headers={'Content-Type' : 'text/xml', 'OCS-APIRequest': "true"})
|
||||
try:
|
||||
quotadata = [int(s) for s in re.findall('<quota>(.+?)</quota>', r.text)]
|
||||
inuse = [int(s) for s in re.findall('<used>(.+?)</used>', r.text)]
|
||||
|
||||
quotadata_value = quotadata[0]
|
||||
valuequota_MB = 0
|
||||
counter = 0
|
||||
while(quotadata_value > 9999 or counter > 3):
|
||||
quotadata_value = quotadata_value / 1024
|
||||
counter += 1
|
||||
|
||||
valuequota_MB = round(quotadata_value, 0)
|
||||
|
||||
quotadata = [int(s) for s in re.findall('<quota>(.+?)</quota>', r.text)]
|
||||
inuse = [int(s) for s in re.findall('<used>(.+?)</used>', r.text)]
|
||||
|
||||
quotadata_value = quotadata[0]
|
||||
valuequota_MB = 0
|
||||
counter = 0
|
||||
while(quotadata_value > 9999 or counter > 3):
|
||||
quotadata_value = quotadata_value / 1024
|
||||
counter += 1
|
||||
|
||||
valuequota_MB = round(quotadata_value, 0)
|
||||
# PERCENT
|
||||
percent = (100 / int(quotadata[0]))*int(inuse[0])
|
||||
|
||||
# PERCENT
|
||||
percent = (100 / int(quotadata[0]))*int(inuse[0])
|
||||
|
||||
return [quotadata[0], inuse[0], str(round(percent, 0)).replace(",", "."), str(valuequota_MB).split(".")[0]]
|
||||
return [quotadata[0], inuse[0], str(round(percent, 0)).replace(",", "."), str(valuequota_MB).split(".")[0]]
|
||||
except:
|
||||
return [0, 0, 0, 0]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue