Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
update FTP functions
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Sep 19, 2019
1 parent eb63285 commit d8881b2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
10 changes: 5 additions & 5 deletions _doc/sphinxdoc/source/questions/route_2A_2019.rst
Expand Up @@ -90,14 +90,14 @@ Séance 2 - 17/9

* Rappels sur le langage :epkg:`python`,
`Cheat sheet: Python <http://www.xavierdupre.fr/app/teachpyx/helpsphinx/c_resume/python_sheet.html>`_,
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`
Expand Down
7 changes: 6 additions & 1 deletion _unittests/ut_automation/test_ftp_module_backup.py
Expand Up @@ -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

Expand All @@ -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)


Expand Down
11 changes: 7 additions & 4 deletions src/ensae_teaching_cs/automation/ftp_publish_helper.py
Expand Up @@ -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`.
Expand All @@ -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
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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.
Expand All @@ -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::
Expand Down Expand Up @@ -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

0 comments on commit d8881b2

Please sign in to comment.