updated checkcreds output
This commit is contained in:
parent
69805247bf
commit
23028e13e6
@ -13,7 +13,7 @@ class cPanelAccount():
|
|||||||
def checkCreds(self):
|
def checkCreds(self):
|
||||||
try:
|
try:
|
||||||
resp = requests.get(f"{self.baseURL}/Themes/list", headers=self.headers).json()
|
resp = requests.get(f"{self.baseURL}/Themes/list", headers=self.headers).json()
|
||||||
except json.decoder.JSONDecodeError as e:
|
except Exception as e:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|||||||
@ -51,6 +51,15 @@ def buildDictFromTimeslot(slot):
|
|||||||
slotDict["3days"] = getMigCount(3, slot)
|
slotDict["3days"] = getMigCount(3, slot)
|
||||||
return slotDict
|
return slotDict
|
||||||
|
|
||||||
|
def buildList(originalList, listToAdd):
|
||||||
|
for x in listToAdd:
|
||||||
|
originalList.append(x)
|
||||||
|
return originalList
|
||||||
|
|
||||||
|
def buildStringFromList(list):
|
||||||
|
s = ''.join(x + ',' for x in list)
|
||||||
|
return s
|
||||||
|
|
||||||
def getAllMigrations(limit):
|
def getAllMigrations(limit):
|
||||||
return Migration.objects.all()[:limit]
|
return Migration.objects.all()[:limit]
|
||||||
|
|
||||||
@ -208,7 +217,11 @@ class checkCpanelDetails(APIView):
|
|||||||
print(request.data['hostname'], request.data['username'], request.data['password'])
|
print(request.data['hostname'], request.data['username'], request.data['password'])
|
||||||
acc = cPanelAccount(request.data['hostname'], request.data['username'], request.data['password'])
|
acc = cPanelAccount(request.data['hostname'], request.data['username'], request.data['password'])
|
||||||
if acc.checkCreds():
|
if acc.checkCreds():
|
||||||
return Response(acc.getDomains())
|
domains = acc.getDomains()
|
||||||
|
mainDomain = domains['data']['main_domain']
|
||||||
|
otherDomains = domains['data']['addon_domains']
|
||||||
|
otherDomains = buildList(otherDomains, domains['data']['sub_domains'])
|
||||||
|
return Response({"main_domain": mainDomain, "other_domains": buildStringFromList(otherDomains)})
|
||||||
else:
|
else:
|
||||||
return Response({'Error': 'Please check the credentials'})
|
return Response({'Error': 'Please check the credentials'})
|
||||||
|
|
||||||
Reference in New Issue
Block a user