Implement basic gnuplot call

This commit is contained in:
2018-09-21 17:57:39 +02:00
parent d2aa47899a
commit ad325a0afe

View File

@@ -22,6 +22,8 @@ import urllib.request
import shutil import shutil
import datetime import datetime
import zipfile import zipfile
import shlex
import subprocess
import pywikibot import pywikibot
@@ -36,16 +38,20 @@ class EuroExangeBotJob():
def __init__( self, **kwargs ): def __init__( self, **kwargs ):
self.image = kwargs['image'] self.image = kwargs['image']
self.script = kwargs['script']
class EuroExangeBot( pywikibot.bot.BaseBot ): class EuroExangeBot( pywikibot.bot.BaseBot ):
working_dir = os.path.dirname(os.path.realpath(__file__)) + "/../wdir" 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" data_source = "http://www.ecb.int/stats/eurofxref/eurofxref-hist.zip"
zip_file = "eurofxref-hist.zip" zip_file = "eurofxref-hist.zip"
csv_file = "eurofxref-hist.csv" 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 ): def __init__( self, genFactory, **kwargs ):
@@ -194,7 +200,20 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
jogobot.output( "Work on Job {}".format(job.image), "ERROR" ) jogobot.output( "Work on Job {}".format(job.image), "ERROR" )
raise pywikibot.NoPage( filepage ) 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): def main(*args):