Browse Source

Implement file upload

develop
Jonathan Golder 4 years ago
parent
commit
206917ed6d
  1. 30
      euroexange/euroexange.py

30
euroexange/euroexange.py

@ -27,6 +27,7 @@ import subprocess
import email.utils
import pywikibot
import upload
import jogobot
@ -51,6 +52,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"
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" ) ]
@ -212,6 +214,8 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
self.call_gnuplot( job )
self.upload_file( job )
def call_gnuplot( self, job ):
"""
@ -229,6 +233,32 @@ class EuroExangeBot( pywikibot.bot.BaseBot ):
subprocess.call( cmd, cwd=self.wdir, env=plt_env )
def upload_file( self, job ):
"""
@param job: Job to work on
@type job: EuroExangeBotJob
"""
comment = type(self).upload_comment
filename = 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
targetSite = pywikibot.Site()
bot = upload.UploadRobot( filepath,
description=comment,
useFilename=filename,
keepFilename=keepFilename,
verifyDescription=verifyDescription,
ignoreWarning=ignoreWarning,
targetSite = targetSite
)
bot.upload_image(debug=True)
def main(*args):
"""

Loading…
Cancel
Save