6 Commits
Author SHA1 Message Date
golderweb 638d2b6a3d Do not raise Exception when image not exists
Just output a warning and go on with further jobs
2018-09-27 08:41:53 +02:00
golderweb 1d41e206c0 Fix deprecated calls to UploadRobot 2018-09-27 08:23:26 +02:00
golderweb a0377e1f80 Fix typo in upload comment 2018-09-26 16:00:03 +02:00
golderweb f4296d8410 Set upload warnings which can be ignored
We always upload existing images, so do not complain about this.
For testing purposes, also duplicates are normal
2018-09-25 16:59:50 +02:00
golderweb f28fad2edb Fix old var name 2018-09-25 16:59:19 +02:00
golderweb 5cf5c5a597 fix Pywikibot does not import specialbots by default 2018-09-25 16:32:25 +02:00
+11 -8
View File
@@ -29,6 +29,7 @@ import hashlib
import json
import pywikibot
import pywikibot.specialbots
import jogobot
@@ -60,7 +61,7 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
data_source = "http://www.ecb.int/stats/eurofxref/eurofxref-hist.zip"
zip_file = "eurofxref-hist.zip"
csv_file = "eurofxref-hist.csv"
upload_comment = "Bot: ([[User:Jogobot/Euroexange|euroexange]]) update chart"
upload_comment = "Bot: ([[User:JogoBot/Euroexange|euroexange]]) update chart"
def __init__( self, genFactory, **kwargs ):
@@ -237,11 +238,13 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
self.current_job.filepage = pywikibot.page.FilePage(
pywikibot.Site(), job.image)
# Stop if file not jet exists
# Skip if file not yet exists
if not self.current_job.filepage.exists():
jogobot.output( "Work on Job {}".format( self.current_job.image),
"ERROR" )
raise pywikibot.NoPage( filepage )
jogobot.output( "Image {} does not exists on wiki, job skipped!".
format( self.current_job.image), "WARNING" )
return
#~ raise pywikibot.NoPage( self.current_job.filepage )
# Check if update is necessary
if self.image_update_needed():
@@ -329,10 +332,10 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
comment = type(self).upload_comment
filename = job.image
filepath = os.path.join(self.wdir, job.image)
filepath = [ os.path.join(self.wdir, job.image) ]
keepFilename = True #set to True to skip double-checking/editing destination filename
verifyDescription = True #set to False to skip double-checking/editing description => change to bot-mode
ignoreWarning=False #set to True to skip warnings, Upload even if another file would be overwritten or another mistake would be risked
ignoreWarning = [ "exists", "duplicate", ] #set to True to skip warnings, Upload even if another file would be overwritten or another mistake would be risked
targetSite = pywikibot.Site()
bot = pywikibot.specialbots.UploadRobot(
@@ -345,7 +348,7 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
targetSite = targetSite
)
bot.upload_image(debug=True)
bot.run()
def main(*args):
"""