[BrowserTest] Client logins only once to upload all screenshots

Change-Id: Ic242d8b2f35ced23809d4454a44f28f260bb3eb7
This commit is contained in:
Vikas S Yaligar 2014-07-22 19:15:56 +05:30 committed by Zfilipin
parent 265de12b2d
commit ca6816be63

View file

@ -18,23 +18,23 @@ def license(language_code, file_name)
[[Category:VisualEditor-#{language_code}]]"
end
def upload_image file_path
def upload_image file_path, client
language_code = ENV['LANGUAGE_SCREENSHOT_CODE']
file_name = File.basename(file_path, "")
file_license = license(language_code, file_name)
require 'mediawiki_api'
client = MediawikiApi::Client.new ENV["MEDIAWIKI_API_UPLOAD_URL"]
client.log_in ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]
client.upload_image(file_name, file_path, file_license, true)
sleep 5 # Restriction in bot speed: https://commons.wikimedia.org/wiki/Commons:Bots#Bot_speed
end
def upload_images
screenshot_directory = ENV["LANGUAGE_SCREENSHOT_PATH"] || "./screenshots"
require 'mediawiki_api'
client = MediawikiApi::Client.new ENV["MEDIAWIKI_API_UPLOAD_URL"]
client.log_in ENV["MEDIAWIKI_USER"], ENV["MEDIAWIKI_PASSWORD"]
Dir["#{screenshot_directory}/*.png"].each do |file_path|
puts "Uploading #{file_path}"
upload_image file_path
upload_image file_path, client
end
end