[ARVADOS] created: fccdb6c00289936de09e3f911e2a5805a7df3281

git at public.curoverse.com git at public.curoverse.com
Tue Jan 7 11:33:28 EST 2014


        at  fccdb6c00289936de09e3f911e2a5805a7df3281 (commit)


commit fccdb6c00289936de09e3f911e2a5805a7df3281
Author: Tim Pierce <twp at clinicalfuture.com>
Date:   Mon Jan 6 18:17:23 2014 -0500

    Adding `tag' command: initial commit.

diff --git a/sdk/cli/bin/arv b/sdk/cli/bin/arv
index 7ce2fbe..63dfa4f 100755
--- a/sdk/cli/bin/arv
+++ b/sdk/cli/bin/arv
@@ -10,6 +10,26 @@ if RUBY_VERSION < '1.9.3' then
   EOS
 end
 
+# read authentication data from ~/.arvados if present
+lineno = 0
+config_file = File.expand_path('~/.arvados')
+if File.exist? config_file then
+  File.open(config_file, 'r').each do |line|
+    lineno = lineno + 1
+    # skip comments
+    if line.match('^\s*#') then
+      next
+    end
+    var, val = line.split('=', 2)
+    # allow environment settings to override config files.
+    if var and val
+      ENV[var] ||= val
+    else
+      warn "#{config_file}: #{lineno}: could not parse `#{line}'"
+    end
+  end
+end
+
 case ARGV[0]
 when 'keep'
   ARGV.shift
@@ -40,6 +60,17 @@ when 'pipeline'
       "(see arv-run-pipeline-instance --help for details)\n"
   end
   abort
+when 'tag'
+  ARGV.shift
+  @sub = ARGV.shift
+  if ['add', 'remove'].index @sub then
+    exec `which arv-tag`.strip, *ARGV
+  else
+    $stderr.puts "Usage: \n" +
+      "#{$0} tag add tag1 [tag2 ...] --objects object_uuid1 [object_uuid2...]\n" +
+      "#{$0} tag remove tag1 [tag2 ...] --objects object_uuid1 [object_uuid2...]\n" +
+      "#{$0} tag remove --all\n"
+  end
 end
 
 ENV['ARVADOS_API_VERSION'] ||= 'v1'
diff --git a/sdk/cli/bin/arv-tag b/sdk/cli/bin/arv-tag
new file mode 100644
index 0000000..40dbb45
--- /dev/null
+++ b/sdk/cli/bin/arv-tag
@@ -0,0 +1,67 @@
+#! /usr/bin/env ruby
+
+# arv tag usage:
+#   arv tag add tag1 [tag2 ...] --objects obj_uuid1 [obj_uuid2 ...]
+#   arv tag remove tag1 [tag2 ...] --objects obj_uuid1 [obj_uuid2 ...]
+#   arv tag remove tag1 [tag2 ...] --all
+
+if RUBY_VERSION < '1.9.3' then
+  abort <<-EOS
+#{$0.gsub(/^\.\//,'')} requires Ruby version 1.9.3 or higher.
+  EOS
+end
+
+$arvados_api_version = ENV['ARVADOS_API_VERSION'] || 'v1'
+$arvados_api_host = ENV['ARVADOS_API_HOST'] or
+  abort "#{$0}: fatal: ARVADOS_API_HOST environment variable not set."
+$arvados_api_token = ENV['ARVADOS_API_TOKEN'] or
+  abort "#{$0}: fatal: ARVADOS_API_TOKEN environment variable not set."
+
+begin
+  require 'rubygems'
+  require 'google/api_client'
+  require 'json'
+  require 'pp'
+  require 'trollop'
+rescue LoadError
+  abort <<-EOS
+#{$0}: fatal: some runtime dependencies are missing.
+Try: gem install pp google-api-client json trollop
+  EOS
+end
+
+def debuglog(message, verbosity=1)
+  $stderr.puts "#{File.split($0).last} #{$$}: #{message}" if $debuglevel >= verbosity
+end
+
+module Kernel
+  def suppress_warnings
+    original_verbosity = $VERBOSE
+    $VERBOSE = nil
+    result = yield
+    $VERBOSE = original_verbosity
+    return result
+  end
+end
+
+if $arvados_api_host.match /local/
+  # You probably don't care about SSL certificate checks if you're
+  # testing with a dev server.
+  suppress_warnings { OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE }
+end
+
+class Google::APIClient
+  def discovery_document(api, version)
+    api = api.to_s
+    return @discovery_documents["#{api}:#{version}"] ||=
+      begin
+        response = self.execute!(
+                                 :http_method => :get,
+                                 :uri => self.discovery_uri(api, version),
+                                 :authenticated => false
+                                 )
+        response.body.class == String ? JSON.parse(response.body) : response.body
+      end
+  end
+end
+

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list