First steps of job handling
This commit is contained in:
@@ -28,6 +28,16 @@ import pywikibot
|
|||||||
import jogobot
|
import jogobot
|
||||||
|
|
||||||
|
|
||||||
|
class EuroExangeBotJob():
|
||||||
|
"""
|
||||||
|
Used for EuroExangeBot job queue
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__( self, **kwargs ):
|
||||||
|
|
||||||
|
self.image = kwargs['image']
|
||||||
|
|
||||||
|
|
||||||
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"
|
||||||
@@ -35,6 +45,8 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
|
|||||||
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" ) ]
|
||||||
|
|
||||||
def __init__( self, genFactory, **kwargs ):
|
def __init__( self, genFactory, **kwargs ):
|
||||||
|
|
||||||
# Init working directory
|
# Init working directory
|
||||||
@@ -47,6 +59,9 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
|
|||||||
# Make sure input data is uptodate
|
# Make sure input data is uptodate
|
||||||
self.update_data()
|
self.update_data()
|
||||||
|
|
||||||
|
for job in type(self).jobs:
|
||||||
|
self.treat_job(job)
|
||||||
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def init_wdir(self):
|
def init_wdir(self):
|
||||||
@@ -160,6 +175,27 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
|
|||||||
os.path.join(self.wdir, type(self).csv_file)),
|
os.path.join(self.wdir, type(self).csv_file)),
|
||||||
path=self.wdir )
|
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):
|
def main(*args):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user