Fehler abfangen
This commit is contained in:
parent
b5c9d05de3
commit
b0525d99d3
Binary file not shown.
|
|
@ -1181,7 +1181,7 @@ def getNCDirInfosURL(request, ncid):
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def getAGGroupQuotaData(request):
|
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})
|
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})
|
||||||
|
try:
|
||||||
# IN USE
|
# IN USE
|
||||||
split_response = r.text.split("<d:quota-used-bytes>")
|
split_response = r.text.split("<d:quota-used-bytes>")
|
||||||
inuse = split_response[1].split("</d:quota-used-bytes>")[0]
|
inuse = split_response[1].split("</d:quota-used-bytes>")[0]
|
||||||
|
|
@ -1192,15 +1192,19 @@ def getAGGroupQuotaData(request):
|
||||||
|
|
||||||
# PERCENT VALUE
|
# PERCENT VALUE
|
||||||
percent = (100 / int(quota))*int(inuse)
|
percent = (100 / int(quota))*int(inuse)
|
||||||
|
|
||||||
return [quota, inuse, str(round(percent, 0)).replace(",", ".")]
|
return [quota, inuse, str(round(percent, 0)).replace(",", ".")]
|
||||||
|
except:
|
||||||
|
return [0, 0, 0]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# User QUOTA
|
# User QUOTA
|
||||||
import re, math
|
import re, math
|
||||||
@register.simple_tag
|
@register.simple_tag
|
||||||
def getUserQuotaData(userdata):
|
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"})
|
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)]
|
quotadata = [int(s) for s in re.findall('<quota>(.+?)</quota>', r.text)]
|
||||||
inuse = [int(s) for s in re.findall('<used>(.+?)</used>', r.text)]
|
inuse = [int(s) for s in re.findall('<used>(.+?)</used>', r.text)]
|
||||||
|
|
||||||
|
|
@ -1217,4 +1221,6 @@ def getUserQuotaData(userdata):
|
||||||
percent = (100 / int(quotadata[0]))*int(inuse[0])
|
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