module automation.ftp_publish_helper

Short summary

module ensae_teaching_cs.automation.ftp_publish_helper

Helpers to publish the documentation of python to a website.

source on GitHub

Functions

function

truncated documentation

content_as_binary

Overloads function content_as_finary

publish_documentation

Publishes the documentation and the setups of a python module on a webiste, it assumes the modules is organized the …

publish_teachings_to_web

Copies the documentation to the website.

text_transform

if filename is rss.xml, replaces the string __BLOG_ROOT__ by self._root_web

trigger_on_specific_strings

Looks for specific string such as USERNAME, USERDNSDOMAIN, HOMEPATH, USERNAME, COMPUTERNAME, LOGONSERVER, …

Documentation

Helpers to publish the documentation of python to a website.

source on GitHub

ensae_teaching_cs.automation.ftp_publish_helper.content_as_binary(filename)[source]

Overloads function content_as_finary from pyquickhelper. Determines if filename is binary or None before transfering it.

Paramètres

filename – filename

Renvoie

boolean

source on GitHub

ensae_teaching_cs.automation.ftp_publish_helper.publish_documentation(docs, ftpsite=None, login=None, password=None, footer_html=None, content_filter=<function trigger_on_specific_strings>, is_binary=<function content_as_binary>, force_allow=None, delay=0.5, exc=False, fLOG=<built-in function print>)[source]

Publishes the documentation and the setups of a python module on a webiste, it assumes the modules is organized the same way as pyquickhelper.

Paramètres
  • docs – list of dictionaries (see below)

  • ftpsite – something like ftp.something.

  • login – login

  • password – password

  • footer_html – append this HTML code to any uploaded page (such a javascript code to count the audience)

  • content_filter – filter the content of a file (it raises an exception if the result is None), appies only on text files

  • is_binary – a function to tell if a content of a file is binary or not

  • force_allow – a file is not published if it contains something which looks like credentials except if this string is part of force_allow

  • delay – delay between file transferring (in average)

  • exc – raise exception if not able to transfer

  • fLOG – logging function

docs is a list of dictionaries which must contain for each folder to transfer:

  • local: local folder

  • root_local: local paths will be related to this root

  • root_web: prefix to add to the remote paths

  • status_file: a file where the function populates the transfered files and some information about them

A local file is composed by <local_root>/<relative_path>, it will be uploaded to <web_root>/<relative_path>.

source on GitHub

ensae_teaching_cs.automation.ftp_publish_helper.publish_teachings_to_web(login, ftpsite='ftp.xavierdupre.fr', google_id=None, location='c:\\jenkins\\pymy\\%s\\%s%s\\dist\\%s', rootw='/www/htdocs/app/%s/%s', rootw2='/lesenfantscodaient.fr', folder_status='.', layout=[('html', 'helpsphinx')], modules=None, password=None, force_allow=None, suffix=('_UT_37_std',), delay=0.5, exc=False, exc_transfer=False, transfer=True, additional_projects=None, fLOG=<built-in function print>)[source]

Copies the documentation to the website.

Paramètres
  • login – login

  • ftpsite – ftp site

  • google_id – google_id

  • location – location of Jenkins build

  • rootw – root on ftp site

  • rootw2 – root for lesenfantscodaient.fr

  • folder_status – folder status

  • modules – list of modules to publish, if None, use get_teaching_modules

  • password – if None, if will asked

  • layout – last part of the folders

  • suffix – suffixes to append to the project name

  • force_allow – allow to publish files even if they contain these strings whereas they seem to be credentials

  • delay – delay between two files being transferred

  • exc – raise exception if not found (True) or skip (False)

  • exc_transfer – raise an exception if cannot be transfered

  • transfer – starts transfering, otherwise returns the list of transfering task to do

  • additional_projects – additional projects

  • fLOG – logging function

Example of use:

import sys
import os
from pyquickhelper.filehelper import TransferFTP, FileTreeNode, FolderTransferFTP
from tkinterquickhelper.funcwin import open_window_params
from ensae_teaching_cs.automation.ftp_publish_helper import publish_teachings_to_web

login = "..."
website = "ftp...."
rootw = "/www/htdocs/app/%s/%s"
rootw2 = "/lesenfantscodaient.fr"

password = None

publish_teachings_to_web(login, ftpsite=website,
    google_id="google_id",
    location="<something>\\%s\\%s%s\\dist\\%s",
    rootw=rootw, rootw2=rootw2,
    folder_status=os.path.abspath("."),
    password=password)

Example of an additional projects:

other_projects = [dict(status_file="status_projects.txt"),
                       root_local="...", root_web="...")]

source on GitHub

ensae_teaching_cs.automation.ftp_publish_helper.text_transform(ftpp, filename, content)[source]

if filename is rss.xml, replaces the string __BLOG_ROOT__ by self._root_web

Paramètres
  • ftpp – object FolderTransferFTP

  • filename – filename

  • content – content of the file

Renvoie

new content

source on GitHub

ensae_teaching_cs.automation.ftp_publish_helper.trigger_on_specific_strings(content, filename=None, force_allow=None)[source]

Looks for specific string such as USERNAME, USERDNSDOMAIN, HOMEPATH, USERNAME, COMPUTERNAME, LOGONSERVER, USER, HOME, LOGNAME and returns None if it was found or modifies the content to remove it.

Paramètres
  • content – content of a file

  • filename – only used when an exception is raised

  • force_allow – allow these expressions even if they seem to be credentials

Renvoie

modified content

source on GitHub