From 1f6bd96a8ef88af3f9b3752e0e688a30a54f1318 Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 1 May 2023 21:58:47 +0200 Subject: [PATCH] add del --- .gitignore | 5 ++--- import_export_canalblog.py | 9 ++++++++- lib/WPExport.py | 4 ++++ lib/WPImport.py | 5 +++++ 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5628561..a73c961 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ -backup/ -backup1/ -backup2/ +backup*/ +wp-navigation web_scrap.log __pycache__/ diff --git a/import_export_canalblog.py b/import_export_canalblog.py index 2063faf..8250a9e 100644 --- a/import_export_canalblog.py +++ b/import_export_canalblog.py @@ -19,6 +19,7 @@ def download(name_thread, max_thread, url, logger, parser, directory, html, img) if args.img is False: exportWp.downloadImg(webpage) + del exportWp def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, basic, serial): canalblog = canalblog.split(",") @@ -36,10 +37,11 @@ def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, bas exit(1) exportWp = WPExport(name="Thread-{0}".format(int(name_thread) + 1), url=url, logger=logger, parser=parser) webpage = exportWp.getUrlPage(name_thread, max_thread) - + del exportWp for j in wordpress: importWp = WPimport(name=name, basic=basic, wordpress=j, logger=logger, parser=parser) importWp.fromUrl(webpage) + del importWp else: if len(canalblog) != len(wordpress): logger.error("{0} : ERREUR : Le nombre de dossier n'est pas equivalent au nombre d'URL wordpress".format(name)) @@ -54,8 +56,10 @@ def importUrl(name_thread, max_thread, canalblog, logger, parser, wordpress, bas exit(1) exportWp = WPExport(name=name, url=url, logger=logger, parser=parser) webpage = exportWp.getUrlPage(name_thread, max_thread) + del exportWp importWp = WPimport(name=name, basic=basic, wordpress=wordpress[i], logger=logger, parser=parser) importWp.fromUrl(webpage) + del importWp def importDirectory(name_thread, max_thread, directory, logger, parser, wordpress, basic, serial): @@ -67,6 +71,7 @@ def importDirectory(name_thread, max_thread, directory, logger, parser, wordpres importWp = WPimport(name=name, basic=basic, wordpress=i, logger=logger, parser=parser) for j in directory: importWp.fromDirectory(j, name_thread, max_thread) + del importWp else: if len(directory) != len(wordpress): @@ -75,6 +80,7 @@ def importDirectory(name_thread, max_thread, directory, logger, parser, wordpres for i in range(0, len(wordpress)-1): importWp = WPimport(name=name, basic=basic, wordpress=wordpress[i], logger=logger, parser=parser) importWp.fromDirectory(directory[i]) + del importWp @@ -187,6 +193,7 @@ if __name__ == '__main__': if args.css is False: exportWp.downloadCss() + del exportWp if args.html is False or args.img is False: try: diff --git a/lib/WPExport.py b/lib/WPExport.py index 7f738d4..3bc4b6d 100644 --- a/lib/WPExport.py +++ b/lib/WPExport.py @@ -21,6 +21,10 @@ class WPExport: self._request.mount('http://', HTTPAdapter(max_retries=retries)) + # Destructor + def __del__(self): + self._logger.info("{0} : Export finished for {1}".format(self._name, self._url)) + # Public method # Set name diff --git a/lib/WPImport.py b/lib/WPImport.py index 60c79b9..e3ed2ee 100644 --- a/lib/WPImport.py +++ b/lib/WPImport.py @@ -23,6 +23,11 @@ class WPimport: self._request.mount('http://', HTTPAdapter(max_retries=retries)) + + # Destructor + def __del__(self): + self._logger.info("{0} : Import finished for {1}".format(self._name, self._wordpress)) + # Public method def setUrl(self, wordpress):