From d8881b24480a1d62b2316103bf877f4da1ca4b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?xavier=20dupr=C3=A9?= Date: Thu, 19 Sep 2019 13:14:32 +0200 Subject: [PATCH] update FTP functions --- _doc/sphinxdoc/source/questions/route_2A_2019.rst | 10 +++++----- _unittests/ut_automation/test_ftp_module_backup.py | 7 ++++++- .../automation/ftp_publish_helper.py | 11 +++++++---- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/_doc/sphinxdoc/source/questions/route_2A_2019.rst b/_doc/sphinxdoc/source/questions/route_2A_2019.rst index bf63c1001..c99e6a9e9 100644 --- a/_doc/sphinxdoc/source/questions/route_2A_2019.rst +++ b/_doc/sphinxdoc/source/questions/route_2A_2019.rst @@ -90,14 +90,14 @@ Séance 2 - 17/9 * Rappels sur le langage :epkg:`python`, `Cheat sheet: Python `_, - variable, listes, dictionnaires, boucles, fonctions, + variable, listes, dictionnaires, boucles, fonctions, :ref:`structuresdonneesconversionrst`, :ref:`histogrammerapiderst`, :ref:`mlfeaturesmodelrst` -* Rappels sur :epkg:`pandas`, notion de table, lecture, écriture de fichiers - texte, :epkg:`Excel`, ajout de colonne, opérations entre +* Rappels sur :epkg:`pandas`, notion de table, lecture, écriture de fichiers + texte, :epkg:`Excel`, ajout de colonne, opérations entre colonne, *apply*, opérations standard (sort, filter, group by, join), - :epkg:`numpy`, opérations standard, calcul matriciel, différences - avec un dataframe, + :epkg:`numpy`, opérations standard, calcul matriciel, différences + avec un dataframe, :ref:`2018-09-18rappelspythonrst`, :ref:`2018-09-18rappelspythonpandasmatplotlibrst` * :ref:`td2ecorappels1arst` diff --git a/_unittests/ut_automation/test_ftp_module_backup.py b/_unittests/ut_automation/test_ftp_module_backup.py index 64690872a..dadc6c29b 100644 --- a/_unittests/ut_automation/test_ftp_module_backup.py +++ b/_unittests/ut_automation/test_ftp_module_backup.py @@ -3,6 +3,7 @@ @brief test log(time=60s) """ import unittest +import ftplib from pyquickhelper.pycode import is_travis_or_appveyor, ExtTestCase from ensae_teaching_cs.automation import ftp_list_modules @@ -11,7 +12,11 @@ class TestFtpBackup(ExtTestCase): @unittest.skipIf(is_travis_or_appveyor() is not None, reason="no credentials") def test_ftp_backup(self): - mod = ftp_list_modules() + try: + mod = ftp_list_modules() + except ftplib.error_temp as e: + if '421 Home directory not available' in str(e): + return self.assertNotEmpty(mod) diff --git a/src/ensae_teaching_cs/automation/ftp_publish_helper.py b/src/ensae_teaching_cs/automation/ftp_publish_helper.py index d499ac57c..68c63f97c 100644 --- a/src/ensae_teaching_cs/automation/ftp_publish_helper.py +++ b/src/ensae_teaching_cs/automation/ftp_publish_helper.py @@ -102,7 +102,7 @@ def text_transform(ftpp, filename, content): def publish_documentation(docs, ftpsite=None, login=None, password=None, footer_html=None, content_filter=trigger_on_specific_strings, is_binary=content_as_binary, force_allow=None, - delay=0.5, exc=False, fLOG=print): + delay=0.5, exc=False, ftps='FTP', fLOG=print): """ Publishes the documentation and the setups of a python module on a webiste, it assumes the modules is organized the same way as :epkg:`pyquickhelper`. @@ -119,6 +119,7 @@ def publish_documentation(docs, ftpsite=None, login=None, password=None, except if this string is part of *force_allow* @param delay delay between file transferring (in average) @param exc raise exception if not able to transfer + @param ftps use protocol FTP, TLS, or SFTP @param fLOG logging function *docs* is a list of dictionaries which must contain for each folder @@ -152,7 +153,7 @@ def publish_documentation(docs, ftpsite=None, login=None, password=None, filter_out = "([/\\\\]((moduletoc.html)|(blogtoc.html)|(searchbox.html)))|([.]buildinfo)" - ftp = TransferFTP(ftpsite, login, password, fLOG=fLOG) + ftp = TransferFTP(ftpsite, login, password, ftps=ftps, fLOG=fLOG) for project in docs: @@ -198,7 +199,8 @@ def publish_teachings_to_web(login, ftpsite="ftp.xavierdupre.fr", google_id=None modules=None, password=None, force_allow=None, suffix=("_UT_%d%d_std" % sys.version_info[:2],), delay=0.5, exc=False, exc_transfer=False, - transfer=True, additional_projects=None, fLOG=print): + transfer=True, additional_projects=None, + ftps='FTP', fLOG=print): """ Copies the documentation to the website. @@ -221,6 +223,7 @@ def publish_teachings_to_web(login, ftpsite="ftp.xavierdupre.fr", google_id=None @param transfer starts transfering, otherwise returns the list of transfering task to do @param additional_projects additional projects + @param ftps use protocol FTP, TLS, or SFTP @param fLOG logging function Example of use:: @@ -385,5 +388,5 @@ def _update_path(pth): if transfer: publish_documentation(projects, ftpsite=ftpsite, login=login, password=password, footer_html=footer, force_allow=force_allow, delay=delay, - exc=exc_transfer, fLOG=fLOG) + exc=exc_transfer, ftps=ftps, fLOG=fLOG) return projects