diff --git a/import_export_canalblog.py b/import_export_canalblog.py index 22e67d8..a0552ee 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -54,7 +54,6 @@ def download(name_thread, max_thread, url, logger, parser, directory, html, img, del exportWp - def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, basic, serial, ssl_wordpress, ssl_canalblog, create, update, image, revert, tmp): canalblog = canalblog.split(",") wordpress = wordpress.split(",") @@ -120,7 +119,7 @@ def importDirectory(name_thread, max_thread, directory, logger, parser, wordpres else: if len(directory) != len(wordpress): - logger.error("{0} : Error : Number directory is differant than wordpress".format(name)) + logger.error("{0} : Error : Number directory is different than wordpress".format(name)) exit(1) for i in range(0, len(wordpress)-1): importWp = WPimport(name=name, basic=basic, wordpress=wordpress[i], logger=logger, parser=parser, ssl_wordpress=ssl_wordpress, no_create=create, no_update=update, no_image=image) @@ -252,7 +251,7 @@ if __name__ == '__main__': wait_for = [ ex.submit(remove, i, args.parallel, args, basic, logger, ssl_wordpress) for i in range(0, int(args.parallel)) ] wait(wait_for, return_when=ALL_COMPLETED) wait_for = [ - 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, TMP, 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) for i in range(0, int(args.parallel)) ] except Exception as err: @@ -262,6 +261,13 @@ if __name__ == '__main__': with futures.ThreadPoolExecutor(max_workers=int(args.parallel)) as ex: wait_for = [ ex.submit(remove, i, args.parallel, args, basic, logger, ssl_wordpress) for i in range(0, int(args.parallel)) ] wait(wait_for, return_when=ALL_COMPLETED) + if args.revert is True: + files_tmp = glob.glob("{0}/*.json".format(tmp)) + if len(files_tmp) > 0: + if len(files_tmp) != args.parallel: + for file_r in files_tmp: + os.remove(file_r) + wait_for = [ 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, TMP) for i in range(0, int(args.parallel))