[SCM] ci-tooling packaging branch, master, updated. aa21a41e9ec9a3c7a20a57dd4347c4788e00e653
Harald Sitter
apachelogger-guest at moszumanska.debian.org
Mon Dec 7 09:07:04 UTC 2015
Gitweb-URL: http://git.debian.org/?p=pkg-kde/ci-tooling.git;a=commitdiff;h=df82820
The following commit has been merged in the master branch:
commit df82820e0bd5538f435b4385e18a0720c0c4d6d8
Author: Harald Sitter <sitter at kde.org>
Date: Mon Dec 7 09:44:01 2015 +0100
fix numerous style violations in lp.rb
---
lib/lp.rb | 93 +++++++++++++++++++++++++++++++++------------------------------
1 file changed, 49 insertions(+), 44 deletions(-)
diff --git a/lib/lp.rb b/lib/lp.rb
index 82de52b..818822d 100644
--- a/lib/lp.rb
+++ b/lib/lp.rb
@@ -54,10 +54,10 @@ module Launchpad
def self.token
# FIXME: @token is now unused
consumer_options = {
- :signature_method => 'PLAINTEXT',
- :request_token_path => '/+request-token',
- :authorize_path => '/+authorize-token',
- :access_token_path => '/+access-token',
+ signature_method: 'PLAINTEXT',
+ request_token_path: '/+request-token',
+ authorize_path: '/+authorize-token',
+ access_token_path: '/+access-token'
}
token_hash = {}
@@ -70,7 +70,8 @@ module Launchpad
return nil
end
- consumer_options = consumer_options.merge(scheme: :header, site: 'https://api.launchpad.net')
+ site_options = { scheme: :header, site: 'https://api.launchpad.net' }
+ consumer_options = consumer_options.merge(site_options)
consumer = OAuth::Consumer.new('kubuntu-ci', '', consumer_options)
access_token = OAuth::AccessToken.from_hash(consumer, token_hash)
@token = access_token
@@ -82,10 +83,10 @@ module Launchpad
# @return [OAuth::AccessToken]
def self.authenticate
consumer_options = {
- :signature_method => 'PLAINTEXT',
- :request_token_path => '/+request-token',
- :authorize_path => '/+authorize-token',
- :access_token_path => '/+access-token',
+ signature_method: 'PLAINTEXT',
+ request_token_path: '/+request-token',
+ authorize_path: '/+authorize-token',
+ access_token_path: '/+access-token'
}
# Fun story, during auth for some reason launchpad needs the flags in the
@@ -97,7 +98,8 @@ module Launchpad
if File.exist?(conf)
token_hash = JSON.parse(File.read(conf), symbolize_names: true)
else
- consumer_options = consumer_options.merge(scheme: :header, site: 'https://api.launchpad.net')
+ site_options = { scheme: :header, site: 'https://api.launchpad.net' }
+ consumer_options = consumer_options.merge(site_options)
consumer = OAuth::Consumer.new('kubuntu-ci', '', consumer_options)
request_token = consumer.get_request_token(oauth_callback: '')
puts request_token.authorize_url(oauth_callback: '')
@@ -112,9 +114,9 @@ module Launchpad
File.write(conf, JSON.fast_generate(token_hash))
end
+ site_options = { scheme: :header, site: 'https://api.launchpad.net' }
consumer = OAuth::Consumer.new('kubuntu-ci', '',
- consumer_options.merge(scheme: :header,
- site: 'https://api.launchpad.net'))
+ consumer_options.merge(site_options))
access_token = OAuth::AccessToken.from_hash(consumer, token_hash)
@token = access_token
@token
@@ -126,31 +128,29 @@ module Launchpad
# @return [String] body of response
def self.get(uri)
token = Launchpad.token
- # @mutex.synchronize do
- if token
- # Token internally URIfies again without checking if it already has
- # a URI, so simply give it a string...
- Retry.retry_it(times: 2, sleep: 8) do
- response = token.get(uri.to_s)
- unless response.is_a? Net::HTTPSuccess
- fail Net::HTTPRetriableError.new(response.body, response)
- end
- return response.body
+ if token
+ # Token internally URIfies again without checking if it already has
+ # a URI, so simply give it a string...
+ Retry.retry_it(times: 2, sleep: 8) do
+ response = token.get(uri.to_s)
+ unless response.is_a? Net::HTTPSuccess
+ fail Net::HTTPRetriableError.new(response.body, response)
end
+ return response.body
end
+ end
- # Set cache control.
- # Launchpad employs server-side caching, which is nice but for our purposes
- # 90% of the time we need current data, otherwise we wouldn't be polling
- # on a schedule.
- d = nil
- Net::HTTP.start(uri.hostname,
- uri.port,
- use_ssl: (uri.scheme == 'https')) do |http|
- d = http.request_get(uri, 'Cache-Control' => 'max-age=0').body
- end
- d
- # end
+ # Set cache control.
+ # Launchpad employs server-side caching, which is nice but for our purposes
+ # 90% of the time we need current data, otherwise we wouldn't be polling
+ # on a schedule.
+ d = nil
+ Net::HTTP.start(uri.hostname,
+ uri.port,
+ use_ssl: (uri.scheme == 'https')) do |http|
+ d = http.request_get(uri, 'Cache-Control' => 'max-age=0').body
+ end
+ d
end
# HTTP POST. Only possible after {authenticate} was used to get a token!
@@ -158,13 +158,15 @@ module Launchpad
# @return [String] body of response
def self.post(uri)
token = Launchpad.token
- fail 'Launchpad.authenticate must be called before any post' unless token
- # Posting always requires a token.
- Retry.retry_it(times: 2, sleep: 8) do
- response = token.post(uri.path, uri.query)
- fail Net::HTTPRetriableError.new(response.body, response) unless response.is_a? Net::HTTPSuccess
- return response.body
+ fail 'Launchpad.authenticate must be called before any post' unless token
+ # Posting always requires a token.
+ Retry.retry_it(times: 2, sleep: 8) do
+ response = token.post(uri.path, uri.query)
+ unless response.is_a? Net::HTTPSuccess
+ fail Net::HTTPRetriableError.new(response.body, response)
end
+ return response.body
+ end
end
# Unlike launchpadlib we strive for minimal overhead by minimal validation.
@@ -178,8 +180,7 @@ module Launchpad
# accessor.
class Rubber < OpenStruct
# @!visibility private
- def method_missing(name, *args, &block)
-# puts "++++++++++++++ method missing! #{name}"
+ def method_missing(name, *args, &_block)
# Pointer to different URL reflecting a different object.
if self["#{name}_link"]
data = Launchpad.get(URI(send("#{name}_link")))
@@ -204,8 +205,12 @@ module Launchpad
params = args[0]
params ||= {}
params['ws.op'] = name.to_s.chomp('!')
- params.each do | key, value |
- next unless value['self_link'] rescue next
+ params.each do |key, value|
+ begin
+ next unless value['self_link']
+ rescue
+ next
+ end
params[key] = value['self_link']
end
--
ci-tooling packaging
More information about the pkg-kde-commits
mailing list