[ARVADOS] updated: 343892aa0ef79cf607abbfd85a04a612990022e1

git at public.curoverse.com git at public.curoverse.com
Wed Jan 15 14:38:05 EST 2014


Summary of changes:
 .../app/controllers/collections_controller.rb      |    6 +-
 .../app/controllers/sessions_controller.rb         |    2 +-
 .../app/controllers/user_agreements_controller.rb  |    2 +-
 apps/workbench/app/helpers/application_helper.rb   |   21 +++--
 apps/workbench/app/models/arvados_base.rb          |    6 ++
 apps/workbench/app/models/node.rb                  |    3 +
 apps/workbench/app/models/user.rb                  |    4 +
 apps/workbench/app/models/virtual_machine.rb       |    3 +
 .../app/views/application/_index.html.erb          |   13 ++-
 .../app/views/user_agreements/index.html.erb       |   67 ++++++---------
 apps/workbench/app/views/users/_tables.html.erb    |   10 ++-
 .../config/environments/development.rb.example     |    2 +
 .../config/environments/production.rb.example      |    2 +
 apps/workbench/config/environments/test.rb.example |    2 +
 sdk/cli/bin/arv                                    |    2 +-
 sdk/cli/test/test_arv-tag.rb                       |   89 ++++---------------
 .../api/app/controllers/application_controller.rb  |   26 +++++-
 .../arvados/v1/collections_controller.rb           |   59 ++++++++++---
 .../controllers/arvados/v1/schema_controller.rb    |    4 +-
 .../arvados/v1/user_agreements_controller.rb       |    4 +
 services/api/app/models/arvados_model.rb           |    8 ++
 21 files changed, 184 insertions(+), 151 deletions(-)

       via  343892aa0ef79cf607abbfd85a04a612990022e1 (commit)
       via  db01005ac9398a2ff04655205eb64fd269260198 (commit)
       via  dcae8f7fbdc19e57599552c8e59a6f006eacdaf3 (commit)
       via  e00c117bc666cf55c8b2916995255ca424fb8286 (commit)
       via  48ad0eec0c9e63af1bef0ee83f3b885a4deadfe2 (commit)
       via  b1ba4904bc4ee727d8d1b3b90345612c60d4068d (commit)
       via  b88ef1f92a3140a9be37ed09c72175eee87fe071 (commit)
       via  55777101504449fd7784511f304870c3706bed60 (commit)
       via  a19ca95f031bf285cbb4db6d8d8bd1c216e3cfe3 (commit)
       via  c3c2786ca6301e2617ae922562e11e71aca968fd (commit)
       via  77d9504c4a5328ce47535e8c6692cb718add1a20 (commit)
       via  ac5d05f71b5907ad65ba06ae840935c9389315b0 (commit)
       via  60cb933e17126bee490c86e100a28c96323f54f2 (commit)
       via  463e996ae5276dc41deca98cb444c802e6f5e251 (commit)
       via  84f0a30a119355cd7deff1630a82d3d4c9a6d5ee (commit)
       via  5225a4deab9bf526d4e178cb5220f790b3d33e67 (commit)
       via  e049bc7067a800c2852ffaf82c9b530cef5b9f19 (commit)
       via  92d1022d103b58ddad0427736a776a27f198667e (commit)
       via  904989797f0e70dad2d4a2da8ed05693ad1619bd (commit)
       via  ccd618998410873f09444c1fb121e3f9decddc8a (commit)
      from  16f43bd3117ab352d3d64882898716ade5b0163c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 343892aa0ef79cf607abbfd85a04a612990022e1
Merge: db01005 16f43bd
Author: Tim Pierce <twp at curoverse.com>
Date:   Wed Jan 15 14:37:45 2014 -0500

    Merge branch '1510-arv-tag-unit-tests' of git.clinicalfuture.com:arvados into 1510-arv-tag-unit-tests
    
    Conflicts:
    	sdk/cli/test/test_arv-tag.rb


commit db01005ac9398a2ff04655205eb64fd269260198
Author: Tim Pierce <twp at curoverse.com>
Date:   Wed Jan 15 14:33:28 2014 -0500

    Clean up tests with "assert_tag" method, remove non-working test. Fixes #1510.

diff --git a/sdk/cli/test/test_arv-tag.rb b/sdk/cli/test/test_arv-tag.rb
index 247ac40..c095de5 100644
--- a/sdk/cli/test/test_arv-tag.rb
+++ b/sdk/cli/test/test_arv-tag.rb
@@ -19,6 +19,7 @@ class TestArvTag < Minitest::Test
 
   # Test adding and removing a single tag on a single object.
   def test_single_tag_single_obj
+    # Add a single tag.
     tag_uuid, err = capture_subprocess_io do
       assert arv_tag 'add', 'test_tag1', '--object', 'uuid1'
     end
@@ -29,23 +30,22 @@ class TestArvTag < Minitest::Test
     end
 
     assert_empty err
-    tag = JSON.parse out
-    assert_equal 'test_tag1', tag['name']
-    assert_equal 'tag',       tag['link_class']
-    assert_equal 'uuid1',     tag['head_uuid']
+    link = JSON.parse out
+    assert_tag link, 'test_tag1', 'uuid1'
 
+    # Remove the tag.
     out, err = capture_subprocess_io do
       assert arv_tag '-h', 'remove', 'test_tag1', '--object', 'uuid1'
     end
 
     assert_empty err
-    tag = JSON.parse out
-    assert_equal 'test_tag1', tag[0]['name']
-    assert_equal 'tag',       tag[0]['link_class']
-    assert_equal 'uuid1',     tag[0]['head_uuid']
+    links = JSON.parse out
+    assert_equal 1, links.length
+    assert_tag links[0], 'test_tag1', 'uuid1'
 
+    # Verify that the link no longer exists.
     out, err = capture_subprocess_io do
-      assert_equal false, arv('-h', 'link', 'show', '--uuid', tag[0]['uuid'])
+      assert_equal false, arv('-h', 'link', 'show', '--uuid', links[0]['uuid'])
     end
 
     assert_equal "Error: Path not found\n", err
@@ -68,15 +68,10 @@ class TestArvTag < Minitest::Test
     assert_empty err
     json_out = JSON.parse out
     links = json_out['items'].sort { |a,b| a['head_uuid'] <=> b['head_uuid'] }
-    assert_equal 'test_tag1', links[0]['name']
-    assert_equal 'tag',       links[0]['link_class']
-    assert_equal 'uuid1',     links[0]['head_uuid']
-    assert_equal 'test_tag1', links[1]['name']
-    assert_equal 'tag',       links[1]['link_class']
-    assert_equal 'uuid2',     links[1]['head_uuid']
-    assert_equal 'test_tag1', links[2]['name']
-    assert_equal 'tag',       links[2]['link_class']
-    assert_equal 'uuid3',     links[2]['head_uuid']
+    assert_equal 3, links.length
+    assert_tag links[0], 'test_tag1', 'uuid1'
+    assert_tag links[1], 'test_tag1', 'uuid2'
+    assert_tag links[2], 'test_tag1', 'uuid3'
 
     out, err = capture_subprocess_io do
       assert arv_tag('remove', 'test_tag1',
@@ -94,58 +89,6 @@ class TestArvTag < Minitest::Test
     assert_empty out
   end
 
-  # Test adding and removing multiple tags with multiple objects.
-  def test_multi_tag_multi_objects
-    out, err = capture_subprocess_io do
-      assert arv_tag('add', 'test_tag1', 'test_tag2', 'test_tag3',
-                     '--object', 'uuid1',
-                     '--object', 'uuid2',
-                     '--object', 'uuid3')
-    end
-
-    out, err = capture_subprocess_io do
-      assert arv '-h', 'link', 'list', '--where', '{"link_class":"tag"}'
-    end
-
-    assert_empty err
-    json_out = JSON.parse out
-    links = json_out['items'].sort { |a,b|
-      a['name'] <=> b['name'] or
-      a['head_uuid'] <=> b['head_uuid']
-    }
-
-    assert_equal 'test_tag1', links[0]['name']
-    assert_equal 'tag',       links[0]['link_class']
-    assert_equal 'uuid1',     links[0]['head_uuid']
-    assert_equal 'test_tag1', links[1]['name']
-    assert_equal 'tag',       links[1]['link_class']
-    assert_equal 'uuid2',     links[1]['head_uuid']
-    assert_equal 'test_tag1', links[2]['name']
-    assert_equal 'tag',       links[2]['link_class']
-    assert_equal 'uuid3',     links[2]['head_uuid']
-
-    assert_equal 'test_tag2', links[3]['name']
-    assert_equal 'tag',       links[3]['link_class']
-    assert_equal 'uuid1',     links[3]['head_uuid']
-    assert_equal 'test_tag2', links[4]['name']
-    assert_equal 'tag',       links[4]['link_class']
-    assert_equal 'uuid2',     links[4]['head_uuid']
-    assert_equal 'test_tag2', links[5]['name']
-    assert_equal 'tag',       links[5]['link_class']
-    assert_equal 'uuid3',     links[5]['head_uuid']
-
-    assert_equal 'test_tag3', links[6]['name']
-    assert_equal 'tag',       links[6]['link_class']
-    assert_equal 'uuid1',     links[6]['head_uuid']
-    assert_equal 'test_tag3', links[7]['name']
-    assert_equal 'tag',       links[7]['link_class']
-    assert_equal 'uuid2',     links[7]['head_uuid']
-    assert_equal 'test_tag3', links[8]['name']
-    assert_equal 'tag',       links[8]['link_class']
-    assert_equal 'uuid3',     links[8]['head_uuid']
-
-  end
-
   protected
   def arv_tag(*args)
     system ['./bin/arv-tag', 'arv-tag'], *args
@@ -154,4 +97,10 @@ class TestArvTag < Minitest::Test
   def arv(*args)
     system ['./bin/arv', 'arv'], *args
   end
+
+  def assert_tag(link, name, head_uuid)
+    assert_equal 'tag',     link['link_class']
+    assert_equal name,      link['name']
+    assert_equal head_uuid, link['head_uuid']
+  end
 end

commit dcae8f7fbdc19e57599552c8e59a6f006eacdaf3
Author: Tim Pierce <twp at curoverse.com>
Date:   Tue Jan 14 17:23:34 2014 -0500

    Adding arv-tag unit tests.
    
    Also:
    Fix return value for deleting multiple links.
    Clean up arv-put unit test code.

diff --git a/sdk/cli/bin/arv-tag b/sdk/cli/bin/arv-tag
index ca12cb1..9ce3f3d 100755
--- a/sdk/cli/bin/arv-tag
+++ b/sdk/cli/bin/arv-tag
@@ -81,11 +81,7 @@ def tag_remove(tag, obj_uuids=nil)
     $stderr.puts "no tags found to remove"
   end
 
-  return {
-    'kind' => 'arvados#linkList',
-    'items_available' => results.length,
-    'items' => results,
-  }
+  return results
 end
 
 if RUBY_VERSION < '1.9.3' then
@@ -191,6 +187,11 @@ $arvados = $client.discovered_api('arvados', $arvados_api_version)
 
 results = []
 cmd = ARGV.shift
+
+if ARGV.empty?
+  usage
+end
+
 case cmd
 when 'add'
   ARGV.each do |tag|
@@ -201,9 +202,9 @@ when 'add'
 when 'remove'
   ARGV.each do |tag|
     if $options[:all] then
-      results.push(tag_remove(tag))
+      results.concat tag_remove(tag)
     else
-      results.push(tag_remove(tag, $options[:object]))
+      results.concat tag_remove(tag, $options[:object])
     end
   end
 else
@@ -218,10 +219,7 @@ elsif global_opts[:json] then
   puts Oj.dump(results)
 else
   results.each do |r|
-    next if r == nil
-    if r["items"] and r["kind"].match /list$/i
-      r['items'].each do |i| puts i['uuid'] end
-    elsif r['uuid'].nil?
+    if r['uuid'].nil?
       abort("Response did not include a uuid:\n" +
             Oj.dump(r, :indent => 1) +
             "\n")
diff --git a/sdk/cli/test/test_arv-put.rb b/sdk/cli/test/test_arv-put.rb
index 53f05de..27809aa 100644
--- a/sdk/cli/test/test_arv-put.rb
+++ b/sdk/cli/test/test_arv-put.rb
@@ -14,11 +14,10 @@ class TestArvPut < Minitest::Test
 
   def test_help
     out, err = capture_subprocess_io do
-      assert_equal(true, arv_put('-h'),
-                   'arv-put -h exits zero')
+      assert arv_put('-h'), 'arv-put -h exits zero'
     end
     $stderr.write err
-    assert_equal '', err
+    assert_empty err
     assert_match /^usage:/, out
   end
 
@@ -30,7 +29,7 @@ class TestArvPut < Minitest::Test
         w << 'foo'
       end
       w.close
-      assert_equal true, arv_put('--raw', {in: r})
+      assert arv_put('--raw', {in: r})
       r.close
       Process.waitpid wpid
     end
@@ -41,7 +40,7 @@ class TestArvPut < Minitest::Test
 
   def test_raw_file
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--raw', './tmp/foo')
+      assert arv_put('--raw', './tmp/foo')
     end
     $stderr.write err
     assert_match '', err
@@ -50,7 +49,7 @@ class TestArvPut < Minitest::Test
 
   def test_raw_empty_file
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--raw', './tmp/empty_file')
+      assert arv_put('--raw', './tmp/empty_file')
     end
     $stderr.write err
     assert_match '', err
@@ -63,7 +62,7 @@ class TestArvPut < Minitest::Test
                    'arv-put --filename refuses directory')
     end
     assert_match /^usage:.*error:/m, err
-    assert_equal '', out
+    assert_empty out
   end
 
   def test_filename_arg_with_multiple_files
@@ -74,12 +73,12 @@ class TestArvPut < Minitest::Test
                    'arv-put --filename refuses directory')
     end
     assert_match /^usage:.*error:/m, err
-    assert_equal '', out
+    assert_empty out
   end
 
   def test_filename_arg_with_empty_file
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--filename', 'foo', './tmp/empty_file')
+      assert arv_put('--filename', 'foo', './tmp/empty_file')
     end
     $stderr.write err
     assert_match '', err
@@ -88,7 +87,7 @@ class TestArvPut < Minitest::Test
 
   def test_as_stream
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--as-stream', './tmp/foo')
+      assert arv_put('--as-stream', './tmp/foo')
     end
     $stderr.write err
     assert_match '', err
@@ -97,7 +96,7 @@ class TestArvPut < Minitest::Test
 
   def test_progress
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--manifest', '--progress', './tmp/foo')
+      assert arv_put('--manifest', '--progress', './tmp/foo')
     end
     assert_match /%/, err
     assert_equal foo_manifest_locator+"\n", out
@@ -105,7 +104,7 @@ class TestArvPut < Minitest::Test
 
   def test_batch_progress
     out, err = capture_subprocess_io do
-      assert_equal true, arv_put('--manifest', '--batch-progress', './tmp/foo')
+      assert arv_put('--manifest', '--batch-progress', './tmp/foo')
     end
     assert_match /: 0 written 3 total/, err
     assert_match /: 3 written 3 total/, err
@@ -119,7 +118,7 @@ class TestArvPut < Minitest::Test
                    'arv-put --progress --batch-progress is contradictory')
     end
     assert_match /^usage:.*error:/m, err
-    assert_equal '', out
+    assert_empty out
   end
 
   def test_read_from_implicit_stdin
@@ -138,7 +137,7 @@ class TestArvPut < Minitest::Test
         w << 'foo'
       end
       w.close
-      assert_equal true, arv_put('--filename', 'foo', specify_stdin_as,
+      assert arv_put('--filename', 'foo', specify_stdin_as,
                                  { in: r })
       r.close
       Process.waitpid wpid
@@ -169,7 +168,7 @@ class TestArvPut < Minitest::Test
       w.close
       args = []
       args.push specify_stdin_as if specify_stdin_as
-      assert_equal true, arv_put(*args, { in: r })
+      assert arv_put(*args, { in: r })
       r.close
       Process.waitpid wpid
     end
diff --git a/sdk/cli/test/test_arv-tag.rb b/sdk/cli/test/test_arv-tag.rb
new file mode 100644
index 0000000..247ac40
--- /dev/null
+++ b/sdk/cli/test/test_arv-tag.rb
@@ -0,0 +1,157 @@
+require 'minitest/autorun'
+require 'digest/md5'
+require 'json'
+
+def assert_failure *args
+  assert_equal false, *args
+end
+
+class TestArvTag < Minitest::Test
+
+  def test_no_args
+    # arv-tag exits with failure if run with no args
+    out, err = capture_subprocess_io do
+      assert_equal false, arv_tag
+    end
+    assert_empty out
+    assert_match /^usage:/i, err
+  end
+
+  # Test adding and removing a single tag on a single object.
+  def test_single_tag_single_obj
+    tag_uuid, err = capture_subprocess_io do
+      assert arv_tag 'add', 'test_tag1', '--object', 'uuid1'
+    end
+    assert_empty err
+
+    out, err = capture_subprocess_io do
+      assert arv '-h', 'link', 'show', '--uuid', tag_uuid.rstrip
+    end
+
+    assert_empty err
+    tag = JSON.parse out
+    assert_equal 'test_tag1', tag['name']
+    assert_equal 'tag',       tag['link_class']
+    assert_equal 'uuid1',     tag['head_uuid']
+
+    out, err = capture_subprocess_io do
+      assert arv_tag '-h', 'remove', 'test_tag1', '--object', 'uuid1'
+    end
+
+    assert_empty err
+    tag = JSON.parse out
+    assert_equal 'test_tag1', tag[0]['name']
+    assert_equal 'tag',       tag[0]['link_class']
+    assert_equal 'uuid1',     tag[0]['head_uuid']
+
+    out, err = capture_subprocess_io do
+      assert_equal false, arv('-h', 'link', 'show', '--uuid', tag[0]['uuid'])
+    end
+
+    assert_equal "Error: Path not found\n", err
+  end
+
+  # Test adding and removing a single tag with multiple objects.
+  def test_single_tag_multi_objects
+    out, err = capture_subprocess_io do
+      assert arv_tag('add', 'test_tag1',
+                     '--object', 'uuid1',
+                     '--object', 'uuid2',
+                     '--object', 'uuid3')
+    end
+    assert_empty err
+
+    out, err = capture_subprocess_io do
+      assert arv '-h', 'link', 'list', '--where', '{"link_class":"tag","name":"test_tag1"}'
+    end
+
+    assert_empty err
+    json_out = JSON.parse out
+    links = json_out['items'].sort { |a,b| a['head_uuid'] <=> b['head_uuid'] }
+    assert_equal 'test_tag1', links[0]['name']
+    assert_equal 'tag',       links[0]['link_class']
+    assert_equal 'uuid1',     links[0]['head_uuid']
+    assert_equal 'test_tag1', links[1]['name']
+    assert_equal 'tag',       links[1]['link_class']
+    assert_equal 'uuid2',     links[1]['head_uuid']
+    assert_equal 'test_tag1', links[2]['name']
+    assert_equal 'tag',       links[2]['link_class']
+    assert_equal 'uuid3',     links[2]['head_uuid']
+
+    out, err = capture_subprocess_io do
+      assert arv_tag('remove', 'test_tag1',
+                     '--object', 'uuid1',
+                     '--object', 'uuid2',
+                     '--object', 'uuid3')
+    end
+    assert_empty err
+
+    out, err = capture_subprocess_io do
+      assert arv 'link', 'list', '--where', '{"link_class":"tag","name":"test_tag1"}'
+    end
+
+    assert_empty err
+    assert_empty out
+  end
+
+  # Test adding and removing multiple tags with multiple objects.
+  def test_multi_tag_multi_objects
+    out, err = capture_subprocess_io do
+      assert arv_tag('add', 'test_tag1', 'test_tag2', 'test_tag3',
+                     '--object', 'uuid1',
+                     '--object', 'uuid2',
+                     '--object', 'uuid3')
+    end
+
+    out, err = capture_subprocess_io do
+      assert arv '-h', 'link', 'list', '--where', '{"link_class":"tag"}'
+    end
+
+    assert_empty err
+    json_out = JSON.parse out
+    links = json_out['items'].sort { |a,b|
+      a['name'] <=> b['name'] or
+      a['head_uuid'] <=> b['head_uuid']
+    }
+
+    assert_equal 'test_tag1', links[0]['name']
+    assert_equal 'tag',       links[0]['link_class']
+    assert_equal 'uuid1',     links[0]['head_uuid']
+    assert_equal 'test_tag1', links[1]['name']
+    assert_equal 'tag',       links[1]['link_class']
+    assert_equal 'uuid2',     links[1]['head_uuid']
+    assert_equal 'test_tag1', links[2]['name']
+    assert_equal 'tag',       links[2]['link_class']
+    assert_equal 'uuid3',     links[2]['head_uuid']
+
+    assert_equal 'test_tag2', links[3]['name']
+    assert_equal 'tag',       links[3]['link_class']
+    assert_equal 'uuid1',     links[3]['head_uuid']
+    assert_equal 'test_tag2', links[4]['name']
+    assert_equal 'tag',       links[4]['link_class']
+    assert_equal 'uuid2',     links[4]['head_uuid']
+    assert_equal 'test_tag2', links[5]['name']
+    assert_equal 'tag',       links[5]['link_class']
+    assert_equal 'uuid3',     links[5]['head_uuid']
+
+    assert_equal 'test_tag3', links[6]['name']
+    assert_equal 'tag',       links[6]['link_class']
+    assert_equal 'uuid1',     links[6]['head_uuid']
+    assert_equal 'test_tag3', links[7]['name']
+    assert_equal 'tag',       links[7]['link_class']
+    assert_equal 'uuid2',     links[7]['head_uuid']
+    assert_equal 'test_tag3', links[8]['name']
+    assert_equal 'tag',       links[8]['link_class']
+    assert_equal 'uuid3',     links[8]['head_uuid']
+
+  end
+
+  protected
+  def arv_tag(*args)
+    system ['./bin/arv-tag', 'arv-tag'], *args
+  end
+
+  def arv(*args)
+    system ['./bin/arv', 'arv'], *args
+  end
+end

commit e00c117bc666cf55c8b2916995255ca424fb8286
Author: Tim Pierce <twp at curoverse.com>
Date:   Fri Jan 10 18:37:00 2014 -0500

    Command-line clients use $HOME/.config/arvados for config settings.

diff --git a/sdk/cli/bin/arv b/sdk/cli/bin/arv
index 4db95c8..96353c6 100755
--- a/sdk/cli/bin/arv
+++ b/sdk/cli/bin/arv
@@ -10,9 +10,9 @@ if RUBY_VERSION < '1.9.3' then
   EOS
 end
 
-# read authentication data from ~/.arvados if present
+# read authentication data from ~/.config/arvados if present
 lineno = 0
-config_file = File.expand_path('~/.arvados')
+config_file = File.expand_path('~/.config/arvados')
 if File.exist? config_file then
   File.open(config_file, 'r').each do |line|
     lineno = lineno + 1
diff --git a/sdk/python/arvados/__init__.py b/sdk/python/arvados/__init__.py
index a7b3b32..ca91963 100644
--- a/sdk/python/arvados/__init__.py
+++ b/sdk/python/arvados/__init__.py
@@ -21,7 +21,24 @@ import threading
 import apiclient
 import apiclient.discovery
 
-if 'ARVADOS_DEBUG' in os.environ:
+# Arvados configuration settings are taken from $HOME/.config/arvados.
+# Environment variables override settings in the config file.
+#
+class ArvadosConfig(dict):
+    def __init__(self, config_file):
+        dict.__init__(self)
+        with open(config_file, "r") as f:
+            for config_line in f:
+                var, val = config_line.rstrip().split('=', 2)
+                self[var] = val
+        for var in os.environ:
+            if var.startswith('ARVADOS_'):
+                self[var] = os.environ[var]
+
+
+config = ArvadosConfig(os.environ['HOME'] + '/.config/arvados')
+
+if 'ARVADOS_DEBUG' in config:
     logging.basicConfig(level=logging.DEBUG)
 
 EMPTY_BLOCK_LOCATOR = 'd41d8cd98f00b204e9800998ecf8427e+0'
@@ -45,10 +62,11 @@ class errors:
 class CredentialsFromEnv(object):
     @staticmethod
     def http_request(self, uri, **kwargs):
+        global config
         from httplib import BadStatusLine
         if 'headers' not in kwargs:
             kwargs['headers'] = {}
-        kwargs['headers']['Authorization'] = 'OAuth2 %s' % os.environ['ARVADOS_API_TOKEN']
+        kwargs['headers']['Authorization'] = 'OAuth2 %s' % config.get('ARVADOS_API_TOKEN', 'ARVADOS_API_TOKEN_not_set')
         try:
             return self.orig_http_request(uri, **kwargs)
         except BadStatusLine:
@@ -111,7 +129,7 @@ def _cast_objects_too(value, schema_type):
 apiclient.discovery._cast = _cast_objects_too
 
 def api(version=None):
-    global services
+    global services, config
     if not services.get(version):
         apiVersion = version
         if not version:
@@ -119,10 +137,10 @@ def api(version=None):
             logging.info("Using default API version. " +
                          "Call arvados.api('%s') instead." %
                          apiVersion)
-        if 'ARVADOS_API_HOST' not in os.environ:
+        if 'ARVADOS_API_HOST' not in config:
             raise Exception("ARVADOS_API_HOST is not set. Aborting.")
         url = ('https://%s/discovery/v1/apis/{api}/{apiVersion}/rest' %
-               os.environ['ARVADOS_API_HOST'])
+               config['ARVADOS_API_HOST'])
         credentials = CredentialsFromEnv()
 
         # Use system's CA certificates (if we find them) instead of httplib2's
@@ -133,7 +151,7 @@ def api(version=None):
         http = httplib2.Http(ca_certs=ca_certs)
         http = credentials.authorize(http)
         if re.match(r'(?i)^(true|1|yes)$',
-                    os.environ.get('ARVADOS_API_HOST_INSECURE', '')):
+                    config.get('ARVADOS_API_HOST_INSECURE', 'no')):
             http.disable_ssl_certificate_validation=True
         services[version] = apiclient.discovery.build(
             'arvados', apiVersion, http=http, discoveryServiceUrl=url)
@@ -924,6 +942,7 @@ class KeepClient(object):
             super(KeepClient.KeepWriterThread, self).__init__()
             self.args = kwargs
         def run(self):
+            global config
             with self.args['thread_limiter'] as limiter:
                 if not limiter.shall_i_proceed():
                     # My turn arrived, but the job has been done without
@@ -935,7 +954,7 @@ class KeepClient(object):
                                self.args['service_root']))
                 h = httplib2.Http()
                 url = self.args['service_root'] + self.args['data_hash']
-                api_token = os.environ['ARVADOS_API_TOKEN']
+                api_token = config['ARVADOS_API_TOKEN']
                 headers = {'Authorization': "OAuth2 %s" % api_token}
                 try:
                     resp, content = h.request(url.encode('utf-8'), 'PUT',
@@ -995,6 +1014,7 @@ class KeepClient(object):
         return pseq
 
     def get(self, locator):
+        global config
         if re.search(r',', locator):
             return ''.join(self.get(x) for x in locator.split(','))
         if 'KEEP_LOCAL_STORE' in os.environ:
@@ -1003,7 +1023,7 @@ class KeepClient(object):
         for service_root in self.shuffled_service_roots(expect_hash):
             h = httplib2.Http()
             url = service_root + expect_hash
-            api_token = os.environ['ARVADOS_API_TOKEN']
+            api_token = config['ARVADOS_API_TOKEN']
             headers = {'Authorization': "OAuth2 %s" % api_token,
                        'Accept': 'application/octet-stream'}
             try:

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list