Browse Source

Implement basic gnuplot call

develop
Jonathan Golder 4 years ago
parent
commit
ad325a0afe
  1. 21
      euroexange/euroexange.py

21
euroexange/euroexange.py

@ -22,6 +22,8 @@ import urllib.request
import shutil
import datetime
import zipfile
import shlex
import subprocess
import pywikibot
@ -36,16 +38,20 @@ class EuroExangeBotJob():
def __init__( self, **kwargs ):
self.image = kwargs['image']
self.script = kwargs['script']
class EuroExangeBot( pywikibot.bot.BaseBot ):
working_dir = os.path.dirname(os.path.realpath(__file__)) + "/../wdir"
gnuplot_script_dir = os.path.dirname(os.path.realpath(__file__)) + \
"/../gnuplot_scripts"
gnuplot = "/usr/bin/gnuplot"
data_source = "http://www.ecb.int/stats/eurofxref/eurofxref-hist.zip"
zip_file = "eurofxref-hist.zip"
csv_file = "eurofxref-hist.csv"
jobs = [ EuroExangeBotJob( image="TEST_Euro_exchange_rate_to_TRY_-_Turkish_Currency_and_Debt_Crisis_2018.svg" ) ]
jobs = [ EuroExangeBotJob( image="TEST_Euro_exchange_rate_to_TRY_-_Turkish_Currency_and_Debt_Crisis_2018.svg", script="Euro_exchange_rate_to_TRY_-_Turkish_Currency_and_Debt_Crisis_2018" ) ]
def __init__( self, genFactory, **kwargs ):
@ -194,7 +200,20 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
jogobot.output( "Work on Job {}".format(job.image), "ERROR" )
raise pywikibot.NoPage( filepage )
self.call_gnuplot( job )
def call_gnuplot( self, job ):
"""
@param job: Job to work on
@type job: EuroExangeBotJob
"""
cmd = shlex.split ( type(self).gnuplot + " " + os.path.realpath(
os.path.join( type(self).gnuplot_script_dir,
job.script + ".plt" ) ) )
subprocess.call( cmd, cwd=self.wdir )
def main(*args):

Loading…
Cancel
Save