arvados-cli 0.1.20140620110538 → 0.1.20140623091138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/arv +330 -144
- data/bin/arv-run-pipeline-instance +3 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80d7e95b8e15773381fcc4a5aa27bc0ab95ec956
|
4
|
+
data.tar.gz: e9f5f1bc71bcab04f424748c512ab47e9bcc5e14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e518d49c4f69805654e8db45dbc9fb12a9c9340d8b11d9ffa082c880bec7e85254dd9cf940416dbe51642d5ac996398aebd97e135bd79951ff55f81b3475f1a0
|
7
|
+
data.tar.gz: 3ad86619afcd25ee9cecdf6936f46eca39b73d6c6e48baec9841e31ad2a3329fd3410426a6ab619aa2a2111ed68be0d78128298a9984c149a500c9c401cb7448
|
data/bin/arv
CHANGED
@@ -12,75 +12,6 @@ if RUBY_VERSION < '1.9.3' then
|
|
12
12
|
EOS
|
13
13
|
end
|
14
14
|
|
15
|
-
# read authentication data from arvados configuration file if present
|
16
|
-
lineno = 0
|
17
|
-
config_file = File.expand_path('~/.config/arvados/settings.conf')
|
18
|
-
if File.exist? config_file then
|
19
|
-
File.open(config_file, 'r').each do |line|
|
20
|
-
lineno = lineno + 1
|
21
|
-
# skip comments
|
22
|
-
if line.match('^\s*#') then
|
23
|
-
next
|
24
|
-
end
|
25
|
-
var, val = line.chomp.split('=', 2)
|
26
|
-
# allow environment settings to override config files.
|
27
|
-
if var and val
|
28
|
-
ENV[var] ||= val
|
29
|
-
else
|
30
|
-
warn "#{config_file}: #{lineno}: could not parse `#{line}'"
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
case ARGV[0]
|
36
|
-
when 'keep'
|
37
|
-
ARGV.shift
|
38
|
-
@sub = ARGV.shift
|
39
|
-
if ['get', 'put', 'ls', 'normalize'].index @sub then
|
40
|
-
# Native Arvados
|
41
|
-
exec `which arv-#{@sub}`.strip, *ARGV
|
42
|
-
elsif ['less', 'check'].index @sub then
|
43
|
-
# wh* shims
|
44
|
-
exec `which wh#{@sub}`.strip, *ARGV
|
45
|
-
elsif @sub == 'docker'
|
46
|
-
exec `which arv-keepdocker`.strip, *ARGV
|
47
|
-
else
|
48
|
-
puts "Usage: \n" +
|
49
|
-
"#{$0} keep ls\n" +
|
50
|
-
"#{$0} keep get\n" +
|
51
|
-
"#{$0} keep put\n" +
|
52
|
-
"#{$0} keep less\n" +
|
53
|
-
"#{$0} keep check\n" +
|
54
|
-
"#{$0} keep docker\n"
|
55
|
-
end
|
56
|
-
abort
|
57
|
-
when 'pipeline'
|
58
|
-
ARGV.shift
|
59
|
-
@sub = ARGV.shift
|
60
|
-
if ['run'].index @sub then
|
61
|
-
exec `which arv-run-pipeline-instance`.strip, *ARGV
|
62
|
-
else
|
63
|
-
puts "Usage: \n" +
|
64
|
-
"#{$0} pipeline run [...]\n" +
|
65
|
-
"(see arv-run-pipeline-instance --help for details)\n"
|
66
|
-
end
|
67
|
-
abort
|
68
|
-
when 'tag'
|
69
|
-
ARGV.shift
|
70
|
-
exec `which arv-tag`.strip, *ARGV
|
71
|
-
when 'ws'
|
72
|
-
ARGV.shift
|
73
|
-
exec `which arv-ws`.strip, *ARGV
|
74
|
-
end
|
75
|
-
|
76
|
-
ENV['ARVADOS_API_VERSION'] ||= 'v1'
|
77
|
-
|
78
|
-
if not ENV.include?('ARVADOS_API_HOST') or not ENV.include?('ARVADOS_API_TOKEN') then
|
79
|
-
abort <<-EOS
|
80
|
-
ARVADOS_API_HOST and ARVADOS_API_TOKEN need to be defined as environment variables.
|
81
|
-
EOS
|
82
|
-
end
|
83
|
-
|
84
15
|
begin
|
85
16
|
require 'curb'
|
86
17
|
require 'rubygems'
|
@@ -97,11 +28,13 @@ rescue LoadError
|
|
97
28
|
|
98
29
|
Please install all required gems:
|
99
30
|
|
100
|
-
gem install activesupport andand curb google-api-client json oj trollop
|
31
|
+
gem install activesupport andand curb google-api-client json oj trollop yaml
|
101
32
|
|
102
33
|
EOS
|
103
34
|
end
|
104
35
|
|
36
|
+
# Search for 'ENTRY POINT' to see where things get going
|
37
|
+
|
105
38
|
ActiveSupport::Inflector.inflections do |inflect|
|
106
39
|
inflect.irregular 'specimen', 'specimens'
|
107
40
|
inflect.irregular 'human', 'humans'
|
@@ -117,11 +50,6 @@ module Kernel
|
|
117
50
|
end
|
118
51
|
end
|
119
52
|
|
120
|
-
# do this if you're testing with a dev server and you don't care about SSL certificate checks:
|
121
|
-
if ENV['ARVADOS_API_HOST_INSECURE']
|
122
|
-
suppress_warnings { OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE }
|
123
|
-
end
|
124
|
-
|
125
53
|
class Google::APIClient
|
126
54
|
def discovery_document(api, version)
|
127
55
|
api = api.to_s
|
@@ -154,21 +82,229 @@ class ArvadosClient < Google::APIClient
|
|
154
82
|
end
|
155
83
|
end
|
156
84
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
85
|
+
def init_config
|
86
|
+
# read authentication data from arvados configuration file if present
|
87
|
+
lineno = 0
|
88
|
+
config_file = File.expand_path('~/.config/arvados/settings.conf')
|
89
|
+
if File.exist? config_file then
|
90
|
+
File.open(config_file, 'r').each do |line|
|
91
|
+
lineno = lineno + 1
|
92
|
+
# skip comments
|
93
|
+
if line.match('^\s*#') then
|
94
|
+
next
|
95
|
+
end
|
96
|
+
var, val = line.chomp.split('=', 2)
|
97
|
+
# allow environment settings to override config files.
|
98
|
+
if var and val
|
99
|
+
ENV[var] ||= val
|
100
|
+
else
|
101
|
+
warn "#{config_file}: #{lineno}: could not parse `#{line}'"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
subcommands = %w(keep pipeline tag ws edit)
|
108
|
+
|
109
|
+
def check_subcommands client, arvados, subcommand, global_opts, remaining_opts
|
110
|
+
case subcommand
|
111
|
+
when 'keep'
|
112
|
+
@sub = remaining_opts.shift
|
113
|
+
if ['get', 'put', 'ls', 'normalize'].index @sub then
|
114
|
+
# Native Arvados
|
115
|
+
exec `which arv-#{@sub}`.strip, *remaining_opts
|
116
|
+
elsif ['less', 'check'].index @sub then
|
117
|
+
# wh* shims
|
118
|
+
exec `which wh#{@sub}`.strip, *remaining_opts
|
119
|
+
elsif @sub == 'docker'
|
120
|
+
exec `which arv-keepdocker`.strip, *remaining_opts
|
121
|
+
else
|
122
|
+
puts "Usage: arv keep [method] [--parameters]\n"
|
123
|
+
puts "Use 'arv keep [method] --help' to get more information about specific methods.\n\n"
|
124
|
+
puts "Available methods: ls, get, put, less, check, docker"
|
125
|
+
end
|
126
|
+
abort
|
127
|
+
when 'pipeline'
|
128
|
+
sub = remaining_opts.shift
|
129
|
+
if sub == 'run'
|
130
|
+
exec `which arv-run-pipeline-instance`.strip, *remaining_opts
|
131
|
+
else
|
132
|
+
puts "Usage: arv pipeline [method] [--parameters]\n"
|
133
|
+
puts "Use 'arv pipeline [method] --help' to get more information about specific methods.\n\n"
|
134
|
+
puts "Available methods: run"
|
135
|
+
end
|
136
|
+
abort
|
137
|
+
when 'tag'
|
138
|
+
exec `which arv-tag`.strip, *remaining_opts
|
139
|
+
when 'ws'
|
140
|
+
exec `which arv-ws`.strip, *remaining_opts
|
141
|
+
when 'edit'
|
142
|
+
arv_edit client, arvados, global_opts, remaining_opts
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def arv_edit client, arvados, global_opts, remaining_opts
|
147
|
+
n = remaining_opts.shift
|
148
|
+
if n.nil? or n == "-h" or n == "--help"
|
149
|
+
puts head_banner
|
150
|
+
puts "Usage: arv edit [uuid] [fields...]\n\n"
|
151
|
+
puts "Fetch the specified Arvados object, select the specified fields, \n"
|
152
|
+
puts "open an interactive text editor on a text representation (json or\n"
|
153
|
+
puts "yaml, use --format) and then update the object. Will use 'nano'\n"
|
154
|
+
puts "by default, customize with the EDITOR or VISUAL environment variable.\n"
|
155
|
+
exit 255
|
156
|
+
end
|
157
|
+
|
158
|
+
if not $stdout.tty?
|
159
|
+
puts "Not connected to a TTY, cannot run interactive editor."
|
160
|
+
exit 1
|
161
|
+
end
|
162
|
+
|
163
|
+
# determine controller
|
164
|
+
|
165
|
+
m = /([a-z0-9]{5})-([a-z0-9]{5})-([a-z0-9]{15})/.match n
|
166
|
+
if !m
|
167
|
+
if /^[a-f0-9]{32}/.match n
|
168
|
+
abort "Arvados collections are not editable."
|
169
|
+
else
|
170
|
+
abort "#{n} does not appear to be an Arvados uuid"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
rsc = nil
|
175
|
+
arvados.discovery_document["resources"].each do |k,v|
|
176
|
+
klass = k.singularize.camelize
|
177
|
+
dig = Digest::MD5.hexdigest(klass).to_i(16).to_s(36)[-5..-1]
|
178
|
+
if dig == m[2]
|
179
|
+
rsc = k
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
if rsc.nil?
|
184
|
+
abort "Could not determine resource type #{m[2]}"
|
185
|
+
end
|
186
|
+
|
187
|
+
api_method = 'arvados.' + rsc + '.get'
|
188
|
+
|
189
|
+
result = client.execute(:api_method => eval(api_method),
|
190
|
+
:parameters => {"uuid" => n},
|
191
|
+
:authenticated => false,
|
192
|
+
:headers => {
|
193
|
+
authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN']
|
194
|
+
})
|
195
|
+
begin
|
196
|
+
results = JSON.parse result.body
|
197
|
+
rescue JSON::ParserError => e
|
198
|
+
abort "Failed to parse server response:\n" + e.to_s
|
199
|
+
end
|
200
|
+
|
201
|
+
if remaining_opts.length > 0
|
202
|
+
results.select! { |k, v| remaining_opts.include? k }
|
203
|
+
end
|
204
|
+
|
205
|
+
content = ""
|
206
|
+
|
207
|
+
case global_opts[:format]
|
208
|
+
when 'json'
|
209
|
+
content = Oj.dump(results, :indent => 1)
|
210
|
+
when 'yaml'
|
211
|
+
content = results.to_yaml
|
212
|
+
end
|
213
|
+
|
214
|
+
require 'tempfile'
|
215
|
+
|
216
|
+
tmp = Tempfile.new([n, "." + global_opts[:format]])
|
217
|
+
tmp.write(content)
|
218
|
+
tmp.close
|
219
|
+
|
220
|
+
need_edit = true
|
221
|
+
|
222
|
+
while need_edit
|
223
|
+
pid = Process::fork
|
224
|
+
if pid.nil?
|
225
|
+
editor ||= ENV["VISUAL"]
|
226
|
+
editor ||= ENV["EDITOR"]
|
227
|
+
editor ||= "nano"
|
228
|
+
exec editor, tmp.path
|
229
|
+
else
|
230
|
+
Process.wait pid
|
231
|
+
end
|
232
|
+
|
233
|
+
if $?.exitstatus == 0
|
234
|
+
tmp.open
|
235
|
+
newcontent = tmp.read()
|
236
|
+
|
237
|
+
newobj = {}
|
238
|
+
begin
|
239
|
+
case global_opts[:format]
|
240
|
+
when 'json'
|
241
|
+
newobj = Oj.load(newcontent)
|
242
|
+
when 'yaml'
|
243
|
+
newobj = YAML.load(newcontent)
|
244
|
+
end
|
245
|
+
need_edit = false
|
246
|
+
rescue Exception => e
|
247
|
+
puts "Parse error! " + e.to_s
|
248
|
+
n = 1
|
249
|
+
newcontent.each_line do |line|
|
250
|
+
puts "#{n.to_s.rjust 4} #{line}"
|
251
|
+
n += 1
|
252
|
+
end
|
253
|
+
puts "\nTry again (y/n)? "
|
254
|
+
yn = $stdin.read 1
|
255
|
+
if yn == 'n' or yn == 'N'
|
256
|
+
exit 1
|
257
|
+
end
|
258
|
+
end
|
259
|
+
else
|
260
|
+
puts "Editor exited with status #{$?.exitstatus}"
|
261
|
+
exit $?.exitstatus
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
tmp.close(true)
|
266
|
+
|
267
|
+
if newobj != results
|
268
|
+
api_method = 'arvados.' + rsc + '.update'
|
269
|
+
dumped = Oj.dump(newobj)
|
270
|
+
result = client.execute(:api_method => eval(api_method),
|
271
|
+
:parameters => {"uuid" => n, rsc.singularize => dumped},
|
272
|
+
:authenticated => false,
|
273
|
+
:headers => {
|
274
|
+
authorization: 'OAuth2 '+ENV['ARVADOS_API_TOKEN']
|
275
|
+
})
|
276
|
+
|
277
|
+
begin
|
278
|
+
results = JSON.parse result.body
|
279
|
+
rescue JSON::ParserError => e
|
280
|
+
abort "Failed to parse server response:\n" + e.to_s
|
281
|
+
end
|
282
|
+
|
283
|
+
if result.response.status != 200
|
284
|
+
puts "Update failed. Server responded #{result.response.status}: #{results['errors']} "
|
285
|
+
puts "Update body was:"
|
286
|
+
puts dumped
|
287
|
+
end
|
288
|
+
else
|
289
|
+
puts "Object is unchanged, did not update."
|
290
|
+
end
|
291
|
+
|
292
|
+
exit 0
|
163
293
|
end
|
164
294
|
|
165
295
|
def to_boolean(s)
|
166
296
|
!!(s =~ /^(true|t|yes|y|1)$/i)
|
167
297
|
end
|
168
298
|
|
299
|
+
def head_banner
|
300
|
+
"Arvados command line client\n"
|
301
|
+
end
|
302
|
+
|
169
303
|
def help_methods(discovery_document, resource, method=nil)
|
170
|
-
banner =
|
171
|
-
banner += "
|
304
|
+
banner = head_banner
|
305
|
+
banner += "Usage: arv #{resource} [method] [--parameters]\n"
|
306
|
+
banner += "Use 'arv #{resource} [method] --help' to get more information about specific methods.\n\n"
|
307
|
+
banner += "The #{resource} resource supports the following methods:"
|
172
308
|
banner += "\n\n"
|
173
309
|
discovery_document["resources"][resource.pluralize]["methods"].
|
174
310
|
each do |k,v|
|
@@ -182,28 +318,15 @@ def help_methods(discovery_document, resource, method=nil)
|
|
182
318
|
banner += "\n"
|
183
319
|
STDERR.puts banner
|
184
320
|
|
185
|
-
if not method.nil? and method != '--help' then
|
186
|
-
|
187
|
-
"for resource #{resource.inspect}"
|
321
|
+
if not method.nil? and method != '--help' and method != '-h' then
|
322
|
+
abort "Unknown method #{method.inspect} " +
|
323
|
+
"for resource #{resource.inspect}"
|
188
324
|
end
|
189
325
|
exit 255
|
190
326
|
end
|
191
327
|
|
192
|
-
def help_resources(discovery_document, resource)
|
193
|
-
|
194
|
-
banner += "This Arvados instance supports the following resource types:"
|
195
|
-
banner += "\n\n"
|
196
|
-
discovery_document["resources"].each do |k,v|
|
197
|
-
description = ''
|
198
|
-
resource_info = discovery_document["schemas"][k.singularize.capitalize]
|
199
|
-
if resource_info and resource_info.include?('description')
|
200
|
-
# add only the first line of the discovery doc description
|
201
|
-
description = ' ' + resource_info["description"].split("\n").first.chomp
|
202
|
-
end
|
203
|
-
banner += " #{sprintf("%30s",k.singularize)}#{description}\n"
|
204
|
-
end
|
205
|
-
banner += "\n"
|
206
|
-
STDERR.puts banner
|
328
|
+
def help_resources(option_parser, discovery_document, resource)
|
329
|
+
option_parser.educate
|
207
330
|
|
208
331
|
if not resource.nil? and resource != '--help' then
|
209
332
|
Trollop::die "Unknown resource type #{resource.inspect}"
|
@@ -211,15 +334,21 @@ def help_resources(discovery_document, resource)
|
|
211
334
|
exit 255
|
212
335
|
end
|
213
336
|
|
214
|
-
def parse_arguments(discovery_document)
|
337
|
+
def parse_arguments(discovery_document, subcommands)
|
215
338
|
resource_types = Array.new()
|
216
339
|
discovery_document["resources"].each do |k,v|
|
217
340
|
resource_types << k.singularize
|
218
341
|
end
|
219
342
|
|
220
|
-
|
343
|
+
resource_types += subcommands
|
344
|
+
|
345
|
+
option_parser = Trollop::Parser.new do
|
221
346
|
version __FILE__
|
222
|
-
banner
|
347
|
+
banner head_banner
|
348
|
+
banner "Usage: arv [--flags] subcommand|resource [method] [--parameters]"
|
349
|
+
banner ""
|
350
|
+
banner "Available flags:"
|
351
|
+
|
223
352
|
opt :dry_run, "Don't actually do anything", :short => "-n"
|
224
353
|
opt :verbose, "Print some things on stderr"
|
225
354
|
opt :format,
|
@@ -227,11 +356,26 @@ def parse_arguments(discovery_document)
|
|
227
356
|
:type => :string,
|
228
357
|
:default => 'json'
|
229
358
|
opt :short, "Return only UUIDs (equivalent to --format=uuid)"
|
230
|
-
|
359
|
+
|
360
|
+
banner ""
|
361
|
+
banner "Use 'arv subcommand|resource --help' to get more information about a particular command or resource."
|
362
|
+
banner ""
|
363
|
+
banner "Available subcommands: #{subcommands.join(', ')}"
|
364
|
+
banner ""
|
365
|
+
|
366
|
+
banner "Available resources: #{discovery_document['resources'].keys.map { |k| k.singularize }.join(', ')}"
|
367
|
+
|
368
|
+
banner ""
|
369
|
+
banner "Additional options:"
|
370
|
+
|
231
371
|
conflicts :short, :format
|
232
372
|
stop_on resource_types
|
233
373
|
end
|
234
374
|
|
375
|
+
global_opts = Trollop::with_standard_exception_handling option_parser do
|
376
|
+
o = option_parser.parse ARGV
|
377
|
+
end
|
378
|
+
|
235
379
|
unless %w(json yaml uuid).include?(global_opts[:format])
|
236
380
|
$stderr.puts "#{$0}: --format must be one of json, yaml or uuid."
|
237
381
|
$stderr.puts "Use #{$0} --help for more information."
|
@@ -243,59 +387,101 @@ def parse_arguments(discovery_document)
|
|
243
387
|
end
|
244
388
|
|
245
389
|
resource = ARGV.shift
|
246
|
-
if global_opts[:resources] or not resource_types.include?(resource)
|
247
|
-
help_resources(discovery_document, resource)
|
248
|
-
end
|
249
390
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
391
|
+
if not subcommands.include? resource
|
392
|
+
if not resource_types.include?(resource)
|
393
|
+
puts "Resource or subcommand '#{resource}' is not recognized.\n\n"
|
394
|
+
help_resources(option_parser, discovery_document, resource)
|
395
|
+
end
|
255
396
|
|
256
|
-
|
397
|
+
method = ARGV.shift
|
398
|
+
if not (discovery_document["resources"][resource.pluralize]["methods"].
|
399
|
+
include?(method))
|
400
|
+
help_methods(discovery_document, resource, method)
|
401
|
+
end
|
402
|
+
|
403
|
+
discovered_params = discovery_document\
|
257
404
|
["resources"][resource.pluralize]\
|
258
405
|
["methods"][method]["parameters"]
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
406
|
+
method_opts = Trollop::options do
|
407
|
+
banner head_banner
|
408
|
+
banner "Usage: arv #{resource} #{method} [--parameters]"
|
409
|
+
banner ""
|
410
|
+
banner "This method supports the following parameters:"
|
411
|
+
banner ""
|
412
|
+
discovered_params.each do |k,v|
|
413
|
+
opts = Hash.new()
|
414
|
+
opts[:type] = v["type"].to_sym if v.include?("type")
|
415
|
+
if [:datetime, :text, :object, :array].index opts[:type]
|
416
|
+
opts[:type] = :string # else trollop bork
|
417
|
+
end
|
418
|
+
opts[:default] = v["default"] if v.include?("default")
|
419
|
+
opts[:default] = v["default"].to_i if opts[:type] == :integer
|
420
|
+
opts[:default] = to_boolean(v["default"]) if opts[:type] == :boolean
|
421
|
+
opts[:required] = true if v.include?("required") and v["required"]
|
422
|
+
description = ''
|
423
|
+
description = ' ' + v["description"] if v.include?("description")
|
424
|
+
opt k.to_sym, description, opts
|
265
425
|
end
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
if body_object["required"] == false
|
278
|
-
is_required = false
|
426
|
+
|
427
|
+
body_object = discovery_document["resources"][resource.pluralize]["methods"][method]["request"]
|
428
|
+
if body_object and discovered_params[resource].nil?
|
429
|
+
is_required = true
|
430
|
+
if body_object["required"] == false
|
431
|
+
is_required = false
|
432
|
+
end
|
433
|
+
opt resource.to_sym, "#{resource} (request body)", {
|
434
|
+
required: is_required,
|
435
|
+
type: :string
|
436
|
+
}
|
279
437
|
end
|
280
|
-
opt resource.to_sym, "#{resource} (request body)", {
|
281
|
-
required: is_required,
|
282
|
-
type: :string
|
283
|
-
}
|
284
438
|
end
|
285
|
-
end
|
286
439
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
440
|
+
discovered_params.each do |k,v|
|
441
|
+
k = k.to_sym
|
442
|
+
if ['object', 'array'].index(v["type"]) and method_opts.has_key? k
|
443
|
+
if method_opts[k].andand.match /^\//
|
444
|
+
method_opts[k] = File.open method_opts[k], 'rb' do |f| f.read end
|
445
|
+
end
|
292
446
|
end
|
293
447
|
end
|
294
448
|
end
|
449
|
+
|
295
450
|
return resource, method, method_opts, global_opts, ARGV
|
296
451
|
end
|
297
452
|
|
298
|
-
|
453
|
+
#
|
454
|
+
# ENTRY POINT
|
455
|
+
#
|
456
|
+
|
457
|
+
init_config
|
458
|
+
|
459
|
+
ENV['ARVADOS_API_VERSION'] ||= 'v1'
|
460
|
+
|
461
|
+
if not ENV.include?('ARVADOS_API_HOST') or not ENV.include?('ARVADOS_API_TOKEN') then
|
462
|
+
abort <<-EOS
|
463
|
+
ARVADOS_API_HOST and ARVADOS_API_TOKEN need to be defined as environment variables.
|
464
|
+
EOS
|
465
|
+
end
|
466
|
+
|
467
|
+
# do this if you're testing with a dev server and you don't care about SSL certificate checks:
|
468
|
+
if ENV['ARVADOS_API_HOST_INSECURE']
|
469
|
+
suppress_warnings { OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE }
|
470
|
+
end
|
471
|
+
|
472
|
+
begin
|
473
|
+
client = ArvadosClient.new(:host => ENV['ARVADOS_API_HOST'], :application_name => 'arvados-cli', :application_version => '1.0')
|
474
|
+
arvados = client.discovered_api('arvados', ENV['ARVADOS_API_VERSION'])
|
475
|
+
rescue Exception => e
|
476
|
+
puts "Failed to connect to Arvados API server: #{e}"
|
477
|
+
exit 1
|
478
|
+
end
|
479
|
+
|
480
|
+
# Parse arguments here
|
481
|
+
resource_schema, method, method_opts, global_opts, remaining_opts = parse_arguments(arvados.discovery_document, subcommands)
|
482
|
+
|
483
|
+
check_subcommands client, arvados, resource_schema, global_opts, remaining_opts
|
484
|
+
|
299
485
|
controller = resource_schema.pluralize
|
300
486
|
|
301
487
|
api_method = 'arvados.' + controller + '.' + method
|
@@ -187,7 +187,9 @@ if $options[:instance]
|
|
187
187
|
abort "#{$0}: syntax error: --instance cannot be combined with --template or --submit."
|
188
188
|
end
|
189
189
|
elsif not $options[:template]
|
190
|
-
|
190
|
+
puts "error: you must supply a --template or --instance."
|
191
|
+
p.educate
|
192
|
+
abort
|
191
193
|
end
|
192
194
|
|
193
195
|
if $options[:run_here] == $options[:submit]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arvados-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20140623091138
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arvados Authors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: arvados
|
@@ -146,7 +146,7 @@ dependencies:
|
|
146
146
|
- - "~>"
|
147
147
|
- !ruby/object:Gem::Version
|
148
148
|
version: '0.8'
|
149
|
-
description: This is the Arvados SDK CLI gem, git revision
|
149
|
+
description: This is the Arvados SDK CLI gem, git revision cdd94fae8d40ad6dcee3de5d36de2d89921fd12d
|
150
150
|
email: gem-dev@curoverse.com
|
151
151
|
executables:
|
152
152
|
- arv
|