Articles

Affichage des articles du février, 2018

Mailing list with Python

Image
Aim  : Write a Python script to send an email to a list of customers for instance. The list is in a worksheet on Excel. Procedure  : The recipient list is in an Excel file  named Recipients.xlsx and has one sheet (Sheet1). The first column is LastName, The second is FirstName. The third column is the email address. For this script, we need the openpyxl library. If the library is not installed, we need to install it first. Open a DOS command and type : python –m pip install openpyxl We will also need smtplib to send mails using google servers. For this, manu solutions are possible (See https://support.google.com/a/answer/176600?hl=en ) If we use a Gmail address (or G Suite address), we can send up to 2000 mails per day. The server to use then is smtp.gmail.com. Let us begin the script : from openpyxl import load_workbook import smtplib We will start by creating some variables : myMail="MailAddress" # Mail adress on g

Using Dropbox as Repository in Moodle

Image
Problem : By default the size of file, which could be uploaded in Moodle is limited. In this tutorial, we will be exploring the possibility of using Dropbox as a repository to overcome the limitation. Procedure : Log in as an administrator to the Moodle site. Go to Site Administration then click on Plugins In the section Repositories, click on Manage repositories Enable the Dropbox Dropbox and make it visible In your favourite browser type https://www.dropbox.com/developers/apps Once authenticated, click on My apps then click on the create app button Choose Dropbox API We will create a folder to which the created application will have access We give a name to the folder then click on the Create app button Write down the “App key” and the “App secret” generated by Dropbox. They shall be used in Moodle settings Type in the URI for the oAuth authentication Our app is created in Dropbox

Utiliser Dropbox comme dépôt dans Moodle

Image
Problème  : En général la taille des fichiers est limitée en téléchargement simple sur Moodle.  Procédure  : En tant qu’administrateur, Aller sur Administration du site puis cliquer sur Plugins Aller à la section Dépôts, Cliquer sur Gérer les dépôts Activer le plugin Dropbox (choisir Activé et visible) Aller à l’adresse https://www.dropbox.com/developers/apps Une fois authentifié, cliquer sur My apps puis cliquer sur le bouton create app Choisir Dropbox API Nous allons créer un répertoire auquel nous allons donner à Moodle de droit d’accès Donner un nom à l’application puis cliquer sur le bouton create app Noter l’ "App key" et l’ "App secret" Renseigner l’URI pour l’authentification oAuth L’application est ainsi créée Sur www.dropbox.com Sous Applications On trouve le répertoire qui correspond à l’application créée C’est là où il faut mettre les fichiers volumineux à uti

Mailing list avec Python

Image
Objectif  : Développer un script Python pour envoyer un message à une liste de clients. La liste étant sur un fichier Excel. Procédure  : Fichier Excel Le fichier s’appelle Destinataires.xlsx et comporte une feuille (Feuil1). La première colonne est Nom, la deuxième est Prénom et la troisième colonne est l’adresse mail du destinataire. Pour ce script nous allons besoin de la librairie openpyxl Si la librairie n’est pas installée, dans une fenêtre DOS, taper : python –m pip install openpyxl Nous allons aussi utiliser smtplib pour envoyer les mails à travers les serveurs de google. Pour cela plusieurs solutions sont possibles (voir https://support.google.com/a/answer/176600?hl=en ) On pourra envoyer jusqu’à 2000 messages par jour si on utilise le serveur smtp.gmail.com. Pour cela il suffit d’utiliser une adresse gmail (ou adresse G Suite) pour s’authentifier. Commençons alors le script : from openpyxl import load_workbook import sm