Compare commits
2 Commits
5399b12133
...
49c1552062
Author | SHA1 | Date | |
---|---|---|---|
49c1552062 | |||
7f800c8f7b |
@ -263,6 +263,8 @@ if __name__ == '__main__':
|
|||||||
for i in wordpress:
|
for i in wordpress:
|
||||||
importWp.setUrl(i)
|
importWp.setUrl(i)
|
||||||
importWp.fromFile(files=args.file.split(","))
|
importWp.fromFile(files=args.file.split(","))
|
||||||
|
menuWp = WPMenu(name="Thread-1", basic=basic, wordpress=args.wordpress, logger=logger, parser=args.parser, ssl_canalblog=ssl_canalblog, ssl_wordpress=ssl_wordpress)
|
||||||
|
menuWp.fromFile("{0}/index.html".format(args.file.split(",")[0]))
|
||||||
if len(args.directory) > 0:
|
if len(args.directory) > 0:
|
||||||
try:
|
try:
|
||||||
with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex:
|
with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex:
|
||||||
@ -273,6 +275,9 @@ if __name__ == '__main__':
|
|||||||
ex.submit(importDirectory, i, int(args.parallel), args.directory, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress, args.create, args.update, args.image, args.revert)
|
ex.submit(importDirectory, i, int(args.parallel), args.directory, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress, args.create, args.update, args.image, args.revert)
|
||||||
for i in range(0, int(args.parallel))
|
for i in range(0, int(args.parallel))
|
||||||
]
|
]
|
||||||
|
wait(wait_for, return_when=ALL_COMPLETED)
|
||||||
|
menuWp = WPMenu(name="Thread-1", basic=basic, wordpress=args.wordpress, logger=logger, parser=args.parser, ssl_canalblog=ssl_canalblog, ssl_wordpress=ssl_wordpress)
|
||||||
|
menuWp.fromFile("{0}/index.html".format(args.directory))
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error("Threading error : {0}".format(err))
|
logger.error("Threading error : {0}".format(err))
|
||||||
if len(args.canalblog) > 0:
|
if len(args.canalblog) > 0:
|
||||||
@ -285,6 +290,10 @@ if __name__ == '__main__':
|
|||||||
ex.submit(importUrl, i, int(args.parallel), args.canalblog, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress, ssl_canalblog, args.create, args.update, args.image, args.revert, args.tmp)
|
ex.submit(importUrl, i, int(args.parallel), args.canalblog, logger, args.parser, args.wordpress, basic, args.serial, ssl_wordpress, ssl_canalblog, args.create, args.update, args.image, args.revert, args.tmp)
|
||||||
for i in range(0, int(args.parallel))
|
for i in range(0, int(args.parallel))
|
||||||
]
|
]
|
||||||
|
wait(wait_for, return_when=ALL_COMPLETED)
|
||||||
|
menuWp = WPMenu(name="Thread-1", basic=basic, wordpress=args.wordpress, logger=logger, parser=args.parser, ssl_canalblog=ssl_canalblog, ssl_wordpress=ssl_wordpress)
|
||||||
|
menuWp.fromUrl(args.canalblog)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
|
@ -272,7 +272,7 @@ class WPMenu:
|
|||||||
if page.status_code == 200:
|
if page.status_code == 200:
|
||||||
result = page.json()
|
result = page.json()
|
||||||
for i in result:
|
for i in result:
|
||||||
if i["title"]["rendered"] == itemMenu["title"]:
|
if self._replaceCaracter(i["title"]["rendered"]) == itemMenu["title"]:
|
||||||
idItemMenu = int(i["id"])
|
idItemMenu = int(i["id"])
|
||||||
self._logger.info("{0} : Length of result for item menus : {1}".format(self._name, len(result)))
|
self._logger.info("{0} : Length of result for item menus : {1}".format(self._name, len(result)))
|
||||||
url = "{1}://{0}/wp-json/wp/v2/menu-items".format(self._wordpress, self._protocol_wordpress)
|
url = "{1}://{0}/wp-json/wp/v2/menu-items".format(self._wordpress, self._protocol_wordpress)
|
||||||
@ -283,7 +283,9 @@ class WPMenu:
|
|||||||
objectt = itemMenu["type"]
|
objectt = itemMenu["type"]
|
||||||
if objectt == "tag":
|
if objectt == "tag":
|
||||||
objectt = "post_tag"
|
objectt = "post_tag"
|
||||||
data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "menus":idMenu, "url":"{0}://{1}".format(self._protocol_wordpress, self._wordpress)}
|
data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "menus":idMenu, "url":"#"}
|
||||||
|
if itemMenu["title"] == "home":
|
||||||
|
data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "menus":idMenu, "url":"{0}://{1}".format(self._protocol_wordpress, self._wordpress)}
|
||||||
if type(itemMenu["id"]) is str:
|
if type(itemMenu["id"]) is str:
|
||||||
if len(itemMenu["id"]) > 0:
|
if len(itemMenu["id"]) > 0:
|
||||||
data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "url": itemMenu["link"], "menus":idMenu, "object":objectt, "object_id":int(itemMenu["id"])}
|
data = {"title": itemMenu["title"], "status": "publish", "parent":parent, "url": itemMenu["link"], "menus":idMenu, "object":objectt, "object_id":int(itemMenu["id"])}
|
||||||
@ -369,6 +371,7 @@ class WPMenu:
|
|||||||
self._logger.info("{0} : add item to menu : {1}".format(self._name, idMenu))
|
self._logger.info("{0} : add item to menu : {1}".format(self._name, idMenu))
|
||||||
parent = 0
|
parent = 0
|
||||||
for i in menu:
|
for i in menu:
|
||||||
|
parent = 0
|
||||||
self._logger.debug("{0} : debug create item menu : {1}".format(self._name, i))
|
self._logger.debug("{0} : debug create item menu : {1}".format(self._name, i))
|
||||||
parent = self._createItemMenu(idMenu, i, parent)
|
parent = self._createItemMenu(idMenu, i, parent)
|
||||||
for j in i["children"]:
|
for j in i["children"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user