User:JogoBot/Euroexchange

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Job slug: euroexchange
Mode: automatic (unattended)
Location: Tool jogobot on Wikimedia Toolforge
Programming language(s): Python, GnuPlot
Framework: Pywikibot
Code: https://git.golderweb.de/wiki/jogobot-euroexchange
Data files: https://git.golderweb.de/wiki/jogobot-euroexchange-data
Logs: current, all

The Bot daily fetches exchange rate data as zipped CSV from ECB: Euro foreign exchange reference rates (CSV file (zip)). Based on this data it generates and uploads exchange rate charts.


Configuration[edit]

Jobs[edit]

The charts which shall be updated are configured in jobs.json file (currently used version). Each entry has the following format

{       
        "image" : "Filename.svg",
        "script" : "Scriptname",
        "freq" : 1
}
  • image Defines the filename of chart file on commons, without the File: prefix. The file must already exist!
  • script Defines the GnuPlot script, used to generate the chart file.
  • freq Defines the chart file update period in days.

GnuPlot scripts[edit]

The Bot uses GnuPlot to generate the charts. The currently available scripts can be found here. The scripts must be compatible with GnuPlot Version 4.6, since this is used on Wikimedia Toolforge.

The Bot script provides two environment variables to GnuPlot:

  • INFILE Absolute path to CSV file fetched from ECB
  • OUTFILE Absolute path for the file, which shall be generated

They can be imported in GnuPlot script and then used as normal GnuPlot variables like this:

infile=system("echo $INFILE")
outfile=system("echo $OUTFILE")