swap loop
This commit is contained in:
parent
e6328135da
commit
be9ad9b934
@ -78,23 +78,28 @@ class WPMenu:
|
|||||||
idMenu = 0
|
idMenu = 0
|
||||||
exist = False
|
exist = False
|
||||||
for i in ["categories", "tags"]:
|
for i in ["categories", "tags"]:
|
||||||
if exist is False:
|
for index in range(1,10):
|
||||||
try:
|
if exist is False:
|
||||||
params = {"search":title, "per_page":"100"}
|
try:
|
||||||
page = self._request_wordpress.get("{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), auth=self._basic, params=params)
|
params = {"search":title, "per_page":"100", "page":index}
|
||||||
if page.status_code == 200:
|
page = self._request_wordpress.get("{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), auth=self._basic, params=params)
|
||||||
result = page.json()
|
if page.status_code == 200:
|
||||||
if len(result) > 0:
|
result = page.json()
|
||||||
idMenu = result[0]["id"]
|
if len(result) > 0:
|
||||||
exist = True
|
for j in result:
|
||||||
else:
|
self._logger.info("{0} info : {1} {2}".format(self._name, j["name"], title))
|
||||||
self._logger.error("{0} : {2} didn't get due status code : {1}".format(self._name, page.status_code, i))
|
if j["name"] == title:
|
||||||
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
idMenu = j["id"]
|
||||||
except ConnectionError as err:
|
exist = True
|
||||||
self._logger.error("{0} : Connection error for get url {1} : {2}".format(self._name, "{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), err))
|
|
||||||
exit(1)
|
else:
|
||||||
except Exception as err:
|
self._logger.error("{0} : {2} didn't get due status code : {1}".format(self._name, page.status_code, i))
|
||||||
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, "{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), err))
|
self._logger.debug("{0} : {1}".format(self._name, page.content))
|
||||||
|
except ConnectionError as err:
|
||||||
|
self._logger.error("{0} : Connection error for get url {1} : {2}".format(self._name, "{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), err))
|
||||||
|
exit(1)
|
||||||
|
except Exception as err:
|
||||||
|
self._logger.error("{0} : Exception error for get url {1} : {2}".format(self._name, "{2}://{0}/wp-json/wp/v2/{1}".format(self._wordpress, i, self._protocol_wordpress), err))
|
||||||
return idMenu
|
return idMenu
|
||||||
|
|
||||||
def _menu(self, content):
|
def _menu(self, content):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user