Browse Source

First steps of job handling

develop
Jonathan Golder 4 years ago
parent
commit
d2aa47899a
  1. 36
      euroexange/euroexange.py

36
euroexange/euroexange.py

@ -28,6 +28,16 @@ import pywikibot
import jogobot
class EuroExangeBotJob():
"""
Used for EuroExangeBot job queue
"""
def __init__( self, **kwargs ):
self.image = kwargs['image']
class EuroExangeBot( pywikibot.bot.BaseBot ):
working_dir = os.path.dirname(os.path.realpath(__file__)) + "/../wdir"
@ -35,6 +45,8 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
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" ) ]
def __init__( self, genFactory, **kwargs ):
# Init working directory
@ -47,6 +59,9 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
# Make sure input data is uptodate
self.update_data()
for job in type(self).jobs:
self.treat_job(job)
pass
def init_wdir(self):
@ -160,6 +175,27 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
os.path.join(self.wdir, type(self).csv_file)),
path=self.wdir )
def treat_job( self, job ):
"""
Handles working on specific jobs
@param job: Job to work on
@type job: EuroExangeBotJob
"""
# Log job
jogobot.output( "Work on Job {}".format(job.image) )
# Get file page
filepage = pywikibot.page.FilePage(pywikibot.Site(), job.image)
# Stop if file not jet exists
if not filepage.exists():
jogobot.output( "Work on Job {}".format(job.image), "ERROR" )
raise pywikibot.NoPage( filepage )
def main(*args):
"""

Loading…
Cancel
Save