From 9149a6c5cb51d360078166469a659e3568e74936 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 26 Jun 2023 22:44:42 +0200 Subject: [PATCH] rollback webpage --- import_export_canalblog.py | 6 +++--- lib/WPImport.py | 26 ++++++++++---------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/import_export_canalblog.py b/import_export_canalblog.py index 9594a8b..22e67d8 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -107,13 +107,13 @@ def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, bas del importWp -def importDirectory(name_thread, max_thread, directory, logger, parser, wordpress, basic, serial, ssl_wordpress, create, update, image, tmp, revert): +def importDirectory(name_thread, max_thread, directory, logger, parser, wordpress, basic, serial, ssl_wordpress, create, update, image): name = "Thread-{0}".format(int(name_thread) + 1) directory = directory.split(",") wordpress = wordpress.split(",") if serial is False: for i in wordpress: - importWp = WPimport(name=name, basic=basic, wordpress=i, logger=logger, parser=parser, ssl_wordpress=ssl_wordpress, no_create=create, no_update=update, no_image=image, tmp=tmp, revert=revert) + importWp = WPimport(name=name, basic=basic, wordpress=i, logger=logger, parser=parser, ssl_wordpress=ssl_wordpress, no_create=create, no_update=update, no_image=image) for j in directory: importWp.fromDirectory(j, name_thread, max_thread) del importWp @@ -123,7 +123,7 @@ def importDirectory(name_thread, max_thread, directory, logger, parser, wordpres logger.error("{0} : Error : Number directory is differant 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, tmp=tmp, revert=revert) + 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) importWp.fromDirectory(directory[i]) del importWp diff --git a/lib/WPImport.py b/lib/WPImport.py index 315b0c9..65453da 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -8,7 +8,7 @@ from requests.packages.urllib3.util.retry import Retry class WPimport: # Constructor - def __init__(self, name="Thread-0", basic=None, wordpress="", logger=None, parser="html.parser", ssl_wordpress=True, no_create=False, no_update=False, no_image=False, tmp="/tmp/import_export_canablog", revert=False): + def __init__(self, name="Thread-0", basic=None, wordpress="", logger=None, parser="html.parser", ssl_wordpress=True, no_create=False, no_update=False, no_image=False, tmp="/tmp/import_export_canablog"): self._name = name self._basic = basic self._wordpress = wordpress @@ -29,7 +29,6 @@ class WPimport: self._no_update = no_update self._no_image = no_image self._tmp = tmp - self._revert = revert # Destructor def __del__(self): @@ -76,21 +75,16 @@ class WPimport: def fromDirectory(self, directory="", number_thread=1, max_thread=1): - if self._revert: - self._directory = directory - directory = "{0}/archives".format(directory) - directories = self._getDirectories([], "{0}".format(directory)) - if len(directories) > 0: - files = self._getFiles(directories) - self.fromFile(files, number_thread, max_thread) - else: - self._logger.error("{0} : No files for {1}".format(self._name, directory)) + self._directory = directory + directory = "{0}/archives".format(directory) + directories = self._getDirectories([], "{0}".format(directory)) + if len(directories) > 0: + files = self._getFiles(directories) + self.fromFile(files=files, number_thread=number_thread, max_thread=max_thread) else: - try: - files = open("{0}/{1}.json".format(self._name, self._tmp)) - self.fromFile(files, number_thread, max_thread) - except Exception as ex: - self._logger.error("{0} : Read file json from tmp : {1}".format(self._name, ex)) + self._logger.error("{0} : No files for {1}".format(self._name, directory)) + +