t2-server 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,13 @@
1
1
  = Changes log for the T2 Ruby Gem
2
2
 
3
+ == Version 0.9.1
4
+
5
+ * Update unit test code for Ruby 1.9 compatibility.
6
+ * Major reductions in the time taken to instantiate a Run object.
7
+ * t2-server-info: Don't list runs by default.
8
+ * Move to persistent HTTP connections.
9
+ * SSL certificate store changes.
10
+
3
11
  == Version 0.9.0
4
12
 
5
13
  * t2-run-workflow: Add a switch to set the expiry date/time.
@@ -40,6 +40,17 @@ on your console output. Anything marked as deprecated will be removed in
40
40
  version 1.0.0 so you are advised to update your code at your earliest
41
41
  convenience.
42
42
 
43
+ == Compatibility with Ruby versions
44
+
45
+ This library is known to work with the following versions of Ruby:
46
+ * 1.8.7 *
47
+ * 1.9.2
48
+ * 1.9.3 *
49
+ * jruby 1.6.4 (in Ruby 1.8 mode)
50
+
51
+ Those marked with an asterisk (*) are supported and bugs found against them
52
+ will be fixed. Other versions may work but are not supported.
53
+
43
54
  == Usage
44
55
 
45
56
  There are two entry points for the T2Server API:
@@ -70,10 +81,12 @@ And can be set like this for a standard https connection:
70
81
 
71
82
  conn_params = ConnectionParameters.new
72
83
  conn_params[:verify_peer] = true
73
- conn_params[:ca_path] = "/etc/ssl/certs"
74
84
 
75
85
  This will ensure that the identity of the Taverna Server you are connecting to
76
86
  will be verified using the set of certificates in <tt>/etc/ssl/certs</tt>.
87
+ <tt>:ca_path</tt> can also be set to a list of paths if required. You do not
88
+ need to include your platform's default certificate paths as these are included
89
+ automatically.
77
90
 
78
91
  For convenience a number of standard sets of parameters have been defined. The
79
92
  above example is available as +DefaultConnectionParameters+. Others available
data/Rakefile CHANGED
@@ -66,6 +66,7 @@ Jeweler::Tasks.new do |s|
66
66
  s.add_development_dependency('nokogiri', '>= 1.5.0')
67
67
  s.add_development_dependency('rdoc', '>= 3.9.4')
68
68
  s.add_development_dependency('jeweler', '~> 1.8.3')
69
+ s.add_runtime_dependency('net-http-persistent', '~> 2.6')
69
70
  s.add_runtime_dependency('taverna-baclava', '~> 1.0.0')
70
71
  s.add_runtime_dependency('hirb', '>= 0.4.0')
71
72
  end
@@ -80,14 +81,14 @@ end
80
81
  # t.test_files = FileList['test/ts_t2server.rb']
81
82
  # t.verbose = true
82
83
  # end
83
- task :test, :server, :user1, :user2 do |t, args|
84
+ task :test, [:server, :user1, :user2] do |t, args|
84
85
  args.with_defaults(:server => "", :user1 => "", :user2 => "")
85
86
  RakeFileUtils.verbose(true) do
86
87
  server_arg = ""
87
88
  if args[:server] != ""
88
- server_arg = " -- #{args[:server]} #{args[:user1]} #{args[:user2]}"
89
+ server_arg = "#{args[:server]} #{args[:user1]} #{args[:user2]}"
89
90
  end
90
- ruby "-I\"lib:test\" -S testrb test/ts_t2server.rb" + server_arg
91
+ ruby "-I\"lib:test\" test/ts_t2server.rb " + server_arg
91
92
  end
92
93
  end
93
94
 
@@ -37,11 +37,17 @@ require 'hirb'
37
37
 
38
38
  include T2Server::CLI
39
39
 
40
+ # set up options
41
+ options = {}
40
42
  conn_params, creds = register_options("Usage: t2-server-info [options] " +
41
43
  "server-address") do |opt|
42
44
  opt.separator " Where server-address is the full URI of the server to"
43
45
  opt.separator " connect to, e.g.: http://example.com:8080/taverna"
44
46
  opt.separator " and [options] can be:"
47
+
48
+ opt.on("-l", "--list", "List details for the runs on this server.") do
49
+ options[:list] = true
50
+ end
45
51
  end
46
52
 
47
53
  # read and check server address and credentials
@@ -55,7 +61,7 @@ begin
55
61
  print " Run limit: #{server.run_limit(creds)}\n"
56
62
  runs = server.runs(creds)
57
63
  print "No. of runs: #{runs.length}\n"
58
- if runs.length > 0
64
+ if options[:list] && runs.length > 0
59
65
  puts (Hirb::Helpers::ObjectTable.render runs,
60
66
  :fields=>[:identifier, :status, :expiry],
61
67
  :headers=>{:identifier=>'Run ID', :status=>'Status',
@@ -34,9 +34,9 @@ require 'yaml'
34
34
  require 't2-server/util'
35
35
  require 't2-server/xml/xml'
36
36
  require 't2-server/exceptions'
37
- require 't2-server/credentials'
38
- require 't2-server/connection'
39
- require 't2-server/connection-parameters'
37
+ require 't2-server/net/credentials'
38
+ require 't2-server/net/connection'
39
+ require 't2-server/net/parameters'
40
40
  require 't2-server/port'
41
41
  require 't2-server/server'
42
42
  require 't2-server/run'
@@ -31,7 +31,7 @@
31
31
  # Author: Robert Haines
32
32
 
33
33
  require 'uri'
34
- require 'net/https'
34
+ require 'net/http/persistent'
35
35
 
36
36
  module T2Server
37
37
 
@@ -93,8 +93,8 @@ module T2Server
93
93
  @uri = uri
94
94
  @params = params || DefaultConnectionParameters.new
95
95
 
96
- # set up http connection
97
- @http = Net::HTTP.new(@uri.host, @uri.port)
96
+ # set up persistent http connection
97
+ @http = Net::HTTP::Persistent.new("Taverna_Server_Ruby_Client")
98
98
  end
99
99
 
100
100
  # :call-seq:
@@ -174,7 +174,8 @@ module T2Server
174
174
  get = Net::HTTP::Get.new(path)
175
175
  get["Accept"] = type
176
176
  get["Range"] = "bytes=#{range.min}-#{range.max}" unless range.nil?
177
- response = submit(get, nil, credentials)
177
+
178
+ response = submit(get, path, credentials)
178
179
 
179
180
  case response
180
181
  when Net::HTTPOK, Net::HTTPPartialContent
@@ -203,7 +204,9 @@ module T2Server
203
204
  def PUT(path, value, type, credentials)
204
205
  put = Net::HTTP::Put.new(path)
205
206
  put.content_type = type
206
- response = submit(put, value, credentials)
207
+ put.body = value
208
+
209
+ response = submit(put, path, credentials)
207
210
 
208
211
  case response
209
212
  when Net::HTTPOK
@@ -251,7 +254,8 @@ module T2Server
251
254
  def DELETE(path, credentials)
252
255
  run = path.split("/")[-1]
253
256
  delete = Net::HTTP::Delete.new(path)
254
- response = submit(delete, nil, credentials)
257
+
258
+ response = submit(delete, path, credentials)
255
259
 
256
260
  case response
257
261
  when Net::HTTPNoContent
@@ -275,7 +279,8 @@ module T2Server
275
279
  # of the headers returned.
276
280
  def OPTIONS(path, credentials)
277
281
  options = Net::HTTP::Options.new(path)
278
- response = submit(options, nil, credentials)
282
+
283
+ response = submit(options, path, credentials)
279
284
 
280
285
  case response
281
286
  when Net::HTTPOK
@@ -293,18 +298,23 @@ module T2Server
293
298
  def _POST(path, value, type, credentials)
294
299
  post = Net::HTTP::Post.new(path)
295
300
  post.content_type = type
296
- submit(post, value, credentials)
301
+ post.body = value
302
+
303
+ submit(post, path, credentials)
297
304
  end
298
305
 
299
306
  def path_leaf_from_uri(uri)
300
307
  URI.parse(uri).path.split('/')[-1]
301
308
  end
302
309
 
303
- def submit(request, value, credentials)
310
+ def submit(request, path, credentials)
311
+ full_uri = @uri.clone
312
+ full_uri.path = path
313
+
304
314
  credentials.authenticate(request) unless credentials.nil?
305
315
 
306
316
  begin
307
- @http.request(request, value)
317
+ @http.request(full_uri, request)
308
318
  rescue InternalHTTPError => e
309
319
  raise ConnectionError.new(e)
310
320
  end
@@ -326,16 +336,24 @@ module T2Server
326
336
  def initialize(uri, params = nil)
327
337
  super(uri, params)
328
338
 
329
- # Configure connection options using params
330
- @http.use_ssl = true
331
-
332
339
  # Peer verification
333
340
  if @params[:verify_peer]
334
341
  if @params[:ca_file]
335
342
  @http.ca_file = @params[:ca_file]
336
- else
337
- @http.ca_path = @params[:ca_path]
338
343
  end
344
+
345
+ if @params[:ca_path]
346
+ store = OpenSSL::X509::Store.new
347
+ store.set_default_paths
348
+ if @params[:ca_path].is_a? Array
349
+ @params[:ca_path].each { |path| store.add_path(path) }
350
+ else
351
+ store.add_path(@params[:ca_path])
352
+ end
353
+
354
+ @http.cert_store = store
355
+ end
356
+
339
357
  @http.verify_mode = OpenSSL::SSL::VERIFY_PEER
340
358
  else
341
359
  @http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -344,8 +362,9 @@ module T2Server
344
362
  # Client authentication
345
363
  if @params[:client_certificate]
346
364
  pem = File.read(@params[:client_certificate])
347
- @http.cert = OpenSSL::X509::Certificate.new(pem)
348
- @http.key = OpenSSL::PKey::RSA.new(pem, @params[:client_password])
365
+ @http.certificate = OpenSSL::X509::Certificate.new(pem)
366
+ @http.private_key = OpenSSL::PKey::RSA.new(pem,
367
+ @params[:client_password])
349
368
  end
350
369
  end
351
370
  end
@@ -82,7 +82,6 @@ module T2Server
82
82
  def initialize
83
83
  super
84
84
  self[:verify_peer] = true
85
- self[:ca_path] = "/etc/ssl/certs" # need to get good defaults for Win/OSX
86
85
  end
87
86
  end
88
87
 
@@ -58,9 +58,6 @@ module T2Server
58
58
  # The server instance that this run is hosted on.
59
59
  attr_reader :server
60
60
 
61
- # The owner (username) of this run
62
- attr_reader :owner
63
-
64
61
  # :stopdoc:
65
62
  XPaths = {
66
63
  # Run XPath queries
@@ -112,10 +109,11 @@ module T2Server
112
109
 
113
110
  @credentials = credentials
114
111
 
115
- run_desc = xml_document(@server.get_run_attribute(@identifier, "",
116
- "application/xml", @credentials))
117
- @owner = xpath_attr(run_desc, XPaths[:run_desc], "owner")
118
- @links = get_attributes(run_desc)
112
+ # The following three fields hold cached data about the run that is only
113
+ # downloaded the first time it is requested.
114
+ @run_doc = nil
115
+ @owner = nil
116
+ @links = nil
119
117
 
120
118
  # initialize ports lists to nil as an empty list means no inputs/outputs
121
119
  @input_ports = nil
@@ -176,6 +174,17 @@ module T2Server
176
174
  end
177
175
  # :startdoc:
178
176
 
177
+ # :call-seq:
178
+ # owner -> String
179
+ #
180
+ # Get the username of the owner of this run. The owner is the user who
181
+ # created the run on the server.
182
+ def owner
183
+ @owner = _get_run_owner if @owner.nil?
184
+
185
+ @owner
186
+ end
187
+
179
188
  # :call-seq:
180
189
  # delete
181
190
  #
@@ -187,7 +196,7 @@ module T2Server
187
196
  # :stopdoc:
188
197
  def inputs
189
198
  warn "[DEPRECATION] 'inputs' is deprecated and will be removed in 1.0."
190
- @links[:inputs]
199
+ links[:inputs]
191
200
  end
192
201
 
193
202
  def set_input(input, value)
@@ -273,7 +282,7 @@ module T2Server
273
282
  #
274
283
  # Return the expiry time of this run as an instance of class Time.
275
284
  def expiry
276
- Time.parse(@server.get_run_attribute(@identifier, @links[:expiry],
285
+ Time.parse(@server.get_run_attribute(@identifier, links[:expiry],
277
286
  "text/plain", @credentials))
278
287
  end
279
288
 
@@ -293,7 +302,7 @@ module T2Server
293
302
  # parse timezone offsets with a colon (eg +00:00)
294
303
  date_str = time.xmlschema(2)
295
304
  date_str = date_str[0..-4] + date_str[-2..-1]
296
- @server.set_run_attribute(@identifier, @links[:expiry], date_str,
305
+ @server.set_run_attribute(@identifier, links[:expiry], date_str,
297
306
  "text/plain", @credentials)
298
307
  end
299
308
 
@@ -303,7 +312,7 @@ module T2Server
303
312
  # Get the workflow that this run represents.
304
313
  def workflow
305
314
  if @workflow == ""
306
- @workflow = @server.get_run_attribute(@identifier, @links[:workflow],
315
+ @workflow = @server.get_run_attribute(@identifier, links[:workflow],
307
316
  "application/xml", @credentials)
308
317
  end
309
318
  @workflow
@@ -315,7 +324,7 @@ module T2Server
315
324
  # Get the status of this run. Status can be one of :initialized,
316
325
  # :running or :finished.
317
326
  def status
318
- text_to_state(@server.get_run_attribute(@identifier, @links[:status],
327
+ text_to_state(@server.get_run_attribute(@identifier, links[:status],
319
328
  "text/plain", @credentials))
320
329
  end
321
330
 
@@ -332,7 +341,7 @@ module T2Server
332
341
  # set all the inputs
333
342
  _check_and_set_inputs unless baclava_input?
334
343
 
335
- @server.set_run_attribute(@identifier, @links[:status],
344
+ @server.set_run_attribute(@identifier, links[:status],
336
345
  state_to_text(:running), "text/plain", @credentials)
337
346
  end
338
347
 
@@ -370,7 +379,7 @@ module T2Server
370
379
  #
371
380
  # Get the return code of the run. Zero indicates success.
372
381
  def exitcode
373
- @server.get_run_attribute(@identifier, @links[:exitcode], "text/plain",
382
+ @server.get_run_attribute(@identifier, links[:exitcode], "text/plain",
374
383
  @credentials).to_i
375
384
  end
376
385
 
@@ -379,7 +388,7 @@ module T2Server
379
388
  #
380
389
  # Get anything that the run printed to the standard out stream.
381
390
  def stdout
382
- @server.get_run_attribute(@identifier, @links[:stdout], "text/plain",
391
+ @server.get_run_attribute(@identifier, links[:stdout], "text/plain",
383
392
  @credentials)
384
393
  end
385
394
 
@@ -388,7 +397,7 @@ module T2Server
388
397
  #
389
398
  # Get anything that the run printed to the standard error stream.
390
399
  def stderr
391
- @server.get_run_attribute(@identifier, @links[:stderr], "text/plain",
400
+ @server.get_run_attribute(@identifier, links[:stderr], "text/plain",
392
401
  @credentials)
393
402
  end
394
403
 
@@ -404,10 +413,10 @@ module T2Server
404
413
  # end and add the rest of the path to the wdir link
405
414
  leaf = dir.split("/")[-1]
406
415
  path = dir[0...-(leaf.length + 1)]
407
- @server.create_dir(@identifier, "#{@links[:wdir]}/#{path}", leaf,
416
+ @server.create_dir(@identifier, "#{links[:wdir]}/#{path}", leaf,
408
417
  @credentials)
409
418
  else
410
- @server.create_dir(@identifier, @links[:wdir], dir, @credentials)
419
+ @server.create_dir(@identifier, links[:wdir], dir, @credentials)
411
420
  end
412
421
  end
413
422
 
@@ -423,7 +432,7 @@ module T2Server
423
432
  # The name of the file on the server is returned.
424
433
  def upload_file(filename, params={})
425
434
  location = params[:dir] || ""
426
- location = "#{@links[:wdir]}/#{location}"
435
+ location = "#{links[:wdir]}/#{location}"
427
436
  rename = params[:rename] || ""
428
437
  @server.upload_file(@identifier, filename, location, rename,
429
438
  @credentials)
@@ -436,7 +445,7 @@ module T2Server
436
445
  # remote directory to put this file in can also be specified, but if it is
437
446
  # it must first have been created by a call to Run#mkdir.
438
447
  def upload_data(data, remote_name, remote_directory = "")
439
- location = "#{@links[:wdir]}/#{remote_directory}"
448
+ location = "#{links[:wdir]}/#{remote_directory}"
440
449
  @server.upload_data(@identifier, data, remote_name, location,
441
450
  @credentials)
442
451
  end
@@ -461,7 +470,7 @@ module T2Server
461
470
  raise RunStateError.new(state, :initialized) if state != :initialized
462
471
 
463
472
  rename = upload_file(filename)
464
- result = @server.set_run_attribute(@identifier, @links[:baclava], rename,
473
+ result = @server.set_run_attribute(@identifier, links[:baclava], rename,
465
474
  "text/plain", @credentials)
466
475
 
467
476
  @baclava_in = true if result
@@ -493,7 +502,7 @@ module T2Server
493
502
  state = status
494
503
  raise RunStateError.new(state, :initialized) if state != :initialized
495
504
 
496
- @baclava_out = @server.set_run_attribute(@identifier, @links[:output],
505
+ @baclava_out = @server.set_run_attribute(@identifier, links[:output],
497
506
  BACLAVA_FILE, "text/plain", @credentials)
498
507
  end
499
508
 
@@ -533,7 +542,7 @@ module T2Server
533
542
 
534
543
  raise AccessForbiddenError.new("baclava output") if !@baclava_out
535
544
  @server.get_run_attribute(@identifier,
536
- "#{@links[:wdir]}/#{BACLAVA_FILE}", "*/*", @credentials)
545
+ "#{links[:wdir]}/#{BACLAVA_FILE}", "*/*", @credentials)
537
546
  end
538
547
 
539
548
  # :stopdoc:
@@ -553,7 +562,7 @@ module T2Server
553
562
  state = status
554
563
  raise RunStateError.new(state, :finished) if state != :finished
555
564
 
556
- @server.get_run_attribute(@identifier, "#{@links[:wdir]}/out",
565
+ @server.get_run_attribute(@identifier, "#{links[:wdir]}/out",
557
566
  "application/zip", @credentials)
558
567
  end
559
568
 
@@ -586,7 +595,7 @@ module T2Server
586
595
  #
587
596
  # Get the creation time of this run as an instance of class Time.
588
597
  def create_time
589
- Time.parse(@server.get_run_attribute(@identifier, @links[:createtime],
598
+ Time.parse(@server.get_run_attribute(@identifier, links[:createtime],
590
599
  "text/plain", @credentials))
591
600
  end
592
601
 
@@ -595,7 +604,7 @@ module T2Server
595
604
  #
596
605
  # Get the start time of this run as an instance of class Time.
597
606
  def start_time
598
- Time.parse(@server.get_run_attribute(@identifier, @links[:starttime],
607
+ Time.parse(@server.get_run_attribute(@identifier, links[:starttime],
599
608
  "text/plain", @credentials))
600
609
  end
601
610
 
@@ -604,7 +613,7 @@ module T2Server
604
613
  #
605
614
  # Get the finish time of this run as an instance of class Time.
606
615
  def finish_time
607
- Time.parse(@server.get_run_attribute(@identifier, @links[:finishtime],
616
+ Time.parse(@server.get_run_attribute(@identifier, links[:finishtime],
608
617
  "text/plain", @credentials))
609
618
  end
610
619
 
@@ -617,7 +626,7 @@ module T2Server
617
626
  # are. Sometimes it is useful to know if the user accessing the run is
618
627
  # actually the owner of it or not.
619
628
  def owner?
620
- @credentials.username == @owner
629
+ @credentials.username == owner
621
630
  end
622
631
 
623
632
  # :call-seq:
@@ -631,7 +640,7 @@ module T2Server
631
640
  return unless owner?
632
641
 
633
642
  value = XML::Fragments::PERM_UPDATE % [username, permission.to_s]
634
- @server.create_run_attribute(@identifier, @links[:sec_perms], value,
643
+ @server.create_run_attribute(@identifier, links[:sec_perms], value,
635
644
  "application/xml", @credentials)
636
645
  end
637
646
 
@@ -646,7 +655,7 @@ module T2Server
646
655
 
647
656
  perms = {}
648
657
  doc = xml_document(@server.get_run_attribute(@identifier,
649
- @links[:sec_perms], "application/xml", @credentials))
658
+ links[:sec_perms], "application/xml", @credentials))
650
659
 
651
660
  xpath_find(doc, XPaths[:sec_perm]).each do |p|
652
661
  user = xml_node_content(xpath_first(p, XPaths[:sec_uname]))
@@ -678,7 +687,7 @@ module T2Server
678
687
  def revoke_permission(username)
679
688
  return unless owner?
680
689
 
681
- path = "#{@links[:sec_perms]}/#{username}"
690
+ path = "#{links[:sec_perms]}/#{username}"
682
691
  @server.delete_run_attribute(@identifier, path, @credentials)
683
692
  end
684
693
 
@@ -702,10 +711,10 @@ module T2Server
702
711
  value = XML::Fragments::CREDENTIAL % cred
703
712
 
704
713
  if id.nil?
705
- @server.create_run_attribute(@identifier, @links[:sec_creds], value,
714
+ @server.create_run_attribute(@identifier, links[:sec_creds], value,
706
715
  "application/xml", @credentials)
707
716
  else
708
- path = "#{@links[:sec_creds]}/#{id}"
717
+ path = "#{links[:sec_creds]}/#{id}"
709
718
  @server.set_run_attribute(@identifier, path, value, "application/xml",
710
719
  @credentials)
711
720
  end
@@ -736,7 +745,7 @@ module T2Server
736
745
  type, password]
737
746
  value = XML::Fragments::CREDENTIAL % cred
738
747
 
739
- @server.create_run_attribute(@identifier, @links[:sec_creds], value,
748
+ @server.create_run_attribute(@identifier, links[:sec_creds], value,
740
749
  "application/xml", @credentials)
741
750
  end
742
751
 
@@ -751,7 +760,7 @@ module T2Server
751
760
 
752
761
  creds = {}
753
762
  doc = xml_document(@server.get_run_attribute(@identifier,
754
- @links[:sec_creds], "application/xml", @credentials))
763
+ links[:sec_creds], "application/xml", @credentials))
755
764
 
756
765
  xpath_find(doc, XPaths[:sec_cred]).each do |c|
757
766
  uri = xml_node_content(xpath_first(c, XPaths[:sec_suri]))
@@ -783,7 +792,7 @@ module T2Server
783
792
  def delete_credential(uri)
784
793
  return unless owner?
785
794
 
786
- path = "#{@links[:sec_creds]}/#{credentials[uri]}"
795
+ path = "#{links[:sec_creds]}/#{credentials[uri]}"
787
796
  @server.delete_run_attribute(@identifier, path, @credentials)
788
797
  end
789
798
 
@@ -796,7 +805,7 @@ module T2Server
796
805
  def delete_all_credentials
797
806
  return unless owner?
798
807
 
799
- @server.delete_run_attribute(@identifier, @links[:sec_creds],
808
+ @server.delete_run_attribute(@identifier, links[:sec_creds],
800
809
  @credentials)
801
810
  end
802
811
 
@@ -815,7 +824,7 @@ module T2Server
815
824
  contents = Base64.encode64(IO.read(filename))
816
825
 
817
826
  value = XML::Fragments::TRUST % [contents, type]
818
- @server.create_run_attribute(@identifier, @links[:sec_trusts], value,
827
+ @server.create_run_attribute(@identifier, links[:sec_trusts], value,
819
828
  "application/xml", @credentials)
820
829
  end
821
830
 
@@ -832,7 +841,7 @@ module T2Server
832
841
 
833
842
  t_ids = []
834
843
  doc = xml_document(@server.get_run_attribute(@identifier,
835
- @links[:sec_trusts], "application/xml", @credentials))
844
+ links[:sec_trusts], "application/xml", @credentials))
836
845
 
837
846
  xpath_find(doc, XPaths[:sec_trust]). each do |t|
838
847
  t_ids << xml_node_attribute(t, "href").split('/')[-1]
@@ -850,7 +859,7 @@ module T2Server
850
859
  def delete_trust(id)
851
860
  return unless owner?
852
861
 
853
- path = "#{@links[:sec_trusts]}/#{id}"
862
+ path = "#{links[:sec_trusts]}/#{id}"
854
863
  @server.delete_run_attribute(@identifier, path, @credentials)
855
864
  end
856
865
 
@@ -863,7 +872,7 @@ module T2Server
863
872
  def delete_all_trusts
864
873
  return unless owner?
865
874
 
866
- @server.delete_run_attribute(@identifier, @links[:sec_trusts],
875
+ @server.delete_run_attribute(@identifier, links[:sec_trusts],
867
876
  @credentials)
868
877
  end
869
878
 
@@ -872,13 +881,19 @@ module T2Server
872
881
  # items (leaves) as files. This method (not part of the public API)
873
882
  # downloads a file from the run's working directory.
874
883
  def download_output_data(path, range = nil)
875
- @server.download_run_file(@identifier, "#{@links[:wdir]}/out/#{path}",
884
+ @server.download_run_file(@identifier, "#{links[:wdir]}/out/#{path}",
876
885
  range, @credentials)
877
886
  end
878
887
  # :startdoc:
879
888
 
880
889
  private
881
890
 
891
+ def links
892
+ @links = _get_run_links if @links.nil?
893
+
894
+ @links
895
+ end
896
+
882
897
  # Check each input to see if it requires a list input and call the
883
898
  # requisite upload method for the entire set of inputs.
884
899
  def _check_and_set_inputs
@@ -908,13 +923,13 @@ module T2Server
908
923
  end
909
924
 
910
925
  xml_value = xml_text_node(port.file)
911
- path = "#{@links[:inputs]}/input/#{port.name}"
926
+ path = "#{links[:inputs]}/input/#{port.name}"
912
927
  @server.set_run_attribute(self, path,
913
928
  XML::Fragments::RUNINPUTFILE % xml_value, "application/xml",
914
929
  @credentials)
915
930
  else
916
931
  xml_value = xml_text_node(port.value)
917
- path = "#{@links[:inputs]}/input/#{port.name}"
932
+ path = "#{links[:inputs]}/input/#{port.name}"
918
933
  @server.set_run_attribute(self, path,
919
934
  XML::Fragments::RUNINPUTVALUE % xml_value, "application/xml",
920
935
  @credentials)
@@ -945,7 +960,7 @@ module T2Server
945
960
  # Create and upload the baclava data.
946
961
  baclava = Taverna::Baclava::Writer.write(data_map)
947
962
  upload_data(baclava, "in.baclava")
948
- @server.set_run_attribute(@identifier, @links[:baclava], "in.baclava",
963
+ @server.set_run_attribute(@identifier, links[:baclava], "in.baclava",
949
964
  "text/plain", @credentials)
950
965
  end
951
966
 
@@ -973,7 +988,7 @@ module T2Server
973
988
  def _ls_ports(dir="", top=true)
974
989
  dir = Util.strip_path_slashes(dir)
975
990
  dir_list = @server.get_run_attribute(@identifier,
976
- "#{@links[:wdir]}/#{dir}", "*/*", @credentials)
991
+ "#{links[:wdir]}/#{dir}", "*/*", @credentials)
977
992
 
978
993
  # compile a list of directory entries stripping the
979
994
  # directory name from the front of each filename
@@ -1013,10 +1028,10 @@ module T2Server
1013
1028
  if items.include? output
1014
1029
  if refs
1015
1030
  return "#{@server.uri}/rest/runs/#{@identifier}/" +
1016
- "#{@links[:wdir]}/out/#{output}"
1031
+ "#{links[:wdir]}/out/#{output}"
1017
1032
  else
1018
1033
  return @server.get_run_attribute(@identifier,
1019
- "#{@links[:wdir]}/out/#{output}", "application/octet-stream",
1034
+ "#{links[:wdir]}/out/#{output}", "application/octet-stream",
1020
1035
  @credentials)
1021
1036
  end
1022
1037
  end
@@ -1037,10 +1052,10 @@ module T2Server
1037
1052
  items.each do |item|
1038
1053
  if refs
1039
1054
  result << "#{@server.uri}/rest/runs/#{@identifier}/" +
1040
- "#{@links[:wdir]}/out/#{output}/#{item}"
1055
+ "#{links[:wdir]}/out/#{output}/#{item}"
1041
1056
  else
1042
1057
  result << @server.get_run_attribute(@identifier,
1043
- "#{@links[:wdir]}/out/#{output}/#{item}",
1058
+ "#{links[:wdir]}/out/#{output}/#{item}",
1044
1059
  "application/octet-stream", @credentials)
1045
1060
  end
1046
1061
  end
@@ -1050,7 +1065,7 @@ module T2Server
1050
1065
 
1051
1066
  def _get_input_port_info
1052
1067
  ports = {}
1053
- port_desc = @server.get_run_attribute(@identifier, @links[:inputexp],
1068
+ port_desc = @server.get_run_attribute(@identifier, links[:inputexp],
1054
1069
  "application/xml", @credentials)
1055
1070
 
1056
1071
  doc = xml_document(port_desc)
@@ -1065,7 +1080,7 @@ module T2Server
1065
1080
 
1066
1081
  def _get_output_port_info
1067
1082
  ports = {}
1068
- port_desc = @server.get_run_attribute(@identifier, @links[:output],
1083
+ port_desc = @server.get_run_attribute(@identifier, links[:output],
1069
1084
  "application/xml", @credentials)
1070
1085
 
1071
1086
  doc = xml_document(port_desc)
@@ -1078,7 +1093,24 @@ module T2Server
1078
1093
  ports
1079
1094
  end
1080
1095
 
1081
- def get_attributes(doc)
1096
+ def _get_run_description
1097
+ if @run_doc.nil?
1098
+ @run_doc = xml_document(@server.get_run_attribute(@identifier, "",
1099
+ "application/xml", @credentials))
1100
+ end
1101
+
1102
+ @run_doc
1103
+ end
1104
+
1105
+ def _get_run_owner
1106
+ doc = _get_run_description
1107
+
1108
+ xpath_attr(doc, XPaths[:run_desc], "owner")
1109
+ end
1110
+
1111
+ def _get_run_links
1112
+ doc = _get_run_description
1113
+
1082
1114
  # first parse out the basic stuff
1083
1115
  links = {}
1084
1116
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "t2-server"
8
- s.version = "0.9.0"
8
+ s.version = "0.9.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Robert Haines"]
12
- s.date = "2012-03-26"
12
+ s.date = "2012-04-30"
13
13
  s.description = "This gem provides access to the Taverna 2 Server REST interface from Ruby."
14
14
  s.email = ["rhaines@manchester.ac.uk"]
15
15
  s.executables = ["t2-delete-runs", "t2-run-workflow", "t2-server-info", "t2-get-output", "t2-server-admin"]
@@ -31,10 +31,10 @@ Gem::Specification.new do |s|
31
31
  "lib/t2-server-cli.rb",
32
32
  "lib/t2-server.rb",
33
33
  "lib/t2-server/admin.rb",
34
- "lib/t2-server/connection-parameters.rb",
35
- "lib/t2-server/connection.rb",
36
- "lib/t2-server/credentials.rb",
37
34
  "lib/t2-server/exceptions.rb",
35
+ "lib/t2-server/net/connection.rb",
36
+ "lib/t2-server/net/credentials.rb",
37
+ "lib/t2-server/net/parameters.rb",
38
38
  "lib/t2-server/port.rb",
39
39
  "lib/t2-server/run.rb",
40
40
  "lib/t2-server/server.rb",
@@ -44,6 +44,7 @@ Gem::Specification.new do |s|
44
44
  "lib/t2-server/xml/rexml.rb",
45
45
  "lib/t2-server/xml/xml.rb",
46
46
  "lib/t2server.rb",
47
+ "t2-server.gemspec",
47
48
  "test/tc_admin.rb",
48
49
  "test/tc_params.rb",
49
50
  "test/tc_perms.rb",
@@ -75,7 +76,7 @@ Gem::Specification.new do |s|
75
76
  s.homepage = "http://www.taverna.org.uk/"
76
77
  s.rdoc_options = ["-N", "--tab-width=2", "--main=README.rdoc"]
77
78
  s.require_paths = ["lib"]
78
- s.rubygems_version = "1.8.10"
79
+ s.rubygems_version = "1.8.21"
79
80
  s.summary = "Support for interacting with Taverna 2 Server."
80
81
  s.test_files = ["test/ts_t2server.rb"]
81
82
 
@@ -88,6 +89,7 @@ Gem::Specification.new do |s|
88
89
  s.add_development_dependency(%q<nokogiri>, [">= 1.5.0"])
89
90
  s.add_development_dependency(%q<rdoc>, [">= 3.9.4"])
90
91
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
92
+ s.add_runtime_dependency(%q<net-http-persistent>, ["~> 2.6"])
91
93
  s.add_runtime_dependency(%q<taverna-baclava>, ["~> 1.0.0"])
92
94
  s.add_runtime_dependency(%q<hirb>, [">= 0.4.0"])
93
95
  else
@@ -96,6 +98,7 @@ Gem::Specification.new do |s|
96
98
  s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
97
99
  s.add_dependency(%q<rdoc>, [">= 3.9.4"])
98
100
  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
101
+ s.add_dependency(%q<net-http-persistent>, ["~> 2.6"])
99
102
  s.add_dependency(%q<taverna-baclava>, ["~> 1.0.0"])
100
103
  s.add_dependency(%q<hirb>, [">= 0.4.0"])
101
104
  end
@@ -105,6 +108,7 @@ Gem::Specification.new do |s|
105
108
  s.add_dependency(%q<nokogiri>, [">= 1.5.0"])
106
109
  s.add_dependency(%q<rdoc>, [">= 3.9.4"])
107
110
  s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
111
+ s.add_dependency(%q<net-http-persistent>, ["~> 2.6"])
108
112
  s.add_dependency(%q<taverna-baclava>, ["~> 1.0.0"])
109
113
  s.add_dependency(%q<hirb>, [">= 0.4.0"])
110
114
  end
@@ -50,6 +50,9 @@ if ARGV.size != 0
50
50
 
51
51
  puts "Using server at: #{address}"
52
52
  puts " With user(s): #{user1} #{user2}" if user1
53
+
54
+ # Clear the commandline arguments so that we don't confuse runit.
55
+ ARGV.clear
53
56
  else
54
57
  # get a server address to test - 30 second timeout
55
58
  print "\nPlease supply a valid Taverna 2 Server address.\n\nNOTE that " +
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 9
4
- :patch: 0
4
+ :patch: 1
metadata CHANGED
@@ -1,151 +1,160 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: t2-server
3
- version: !ruby/object:Gem::Version
4
- hash: 59
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 0
10
- version: 0.9.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Robert Haines
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-04-10 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2012-04-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rake
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 63
29
- segments:
30
- - 0
31
- - 9
32
- - 2
20
+ - !ruby/object:Gem::Version
33
21
  version: 0.9.2
34
22
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: libxml-ruby
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 27
45
- segments:
46
- - 1
47
- - 1
48
- - 4
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.9.2
30
+ - !ruby/object:Gem::Dependency
31
+ name: libxml-ruby
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
49
37
  version: 1.1.4
50
38
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: nokogiri
54
39
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 3
61
- segments:
62
- - 1
63
- - 5
64
- - 0
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.1.4
46
+ - !ruby/object:Gem::Dependency
47
+ name: nokogiri
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
65
53
  version: 1.5.0
66
54
  type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: rdoc
70
55
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 43
77
- segments:
78
- - 3
79
- - 9
80
- - 4
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.5.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rdoc
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
81
69
  version: 3.9.4
82
70
  type: :development
83
- version_requirements: *id004
84
- - !ruby/object:Gem::Dependency
85
- name: jeweler
86
71
  prerelease: false
87
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.9.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
88
81
  none: false
89
- requirements:
82
+ requirements:
90
83
  - - ~>
91
- - !ruby/object:Gem::Version
92
- hash: 49
93
- segments:
94
- - 1
95
- - 8
96
- - 3
84
+ - !ruby/object:Gem::Version
97
85
  version: 1.8.3
98
86
  type: :development
99
- version_requirements: *id005
100
- - !ruby/object:Gem::Dependency
101
- name: taverna-baclava
102
87
  prerelease: false
103
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.3
94
+ - !ruby/object:Gem::Dependency
95
+ name: net-http-persistent
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '2.6'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '2.6'
110
+ - !ruby/object:Gem::Dependency
111
+ name: taverna-baclava
112
+ requirement: !ruby/object:Gem::Requirement
104
113
  none: false
105
- requirements:
114
+ requirements:
106
115
  - - ~>
107
- - !ruby/object:Gem::Version
108
- hash: 23
109
- segments:
110
- - 1
111
- - 0
112
- - 0
116
+ - !ruby/object:Gem::Version
113
117
  version: 1.0.0
114
118
  type: :runtime
115
- version_requirements: *id006
116
- - !ruby/object:Gem::Dependency
117
- name: hirb
118
119
  prerelease: false
119
- requirement: &id007 !ruby/object:Gem::Requirement
120
- none: false
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- hash: 15
125
- segments:
126
- - 0
127
- - 4
128
- - 0
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 1.0.0
126
+ - !ruby/object:Gem::Dependency
127
+ name: hirb
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
129
133
  version: 0.4.0
130
134
  type: :runtime
131
- version_requirements: *id007
132
- description: This gem provides access to the Taverna 2 Server REST interface from Ruby.
133
- email:
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: 0.4.0
142
+ description: This gem provides access to the Taverna 2 Server REST interface from
143
+ Ruby.
144
+ email:
134
145
  - rhaines@manchester.ac.uk
135
- executables:
146
+ executables:
136
147
  - t2-delete-runs
137
148
  - t2-run-workflow
138
149
  - t2-server-info
139
150
  - t2-get-output
140
151
  - t2-server-admin
141
152
  extensions: []
142
-
143
- extra_rdoc_files:
153
+ extra_rdoc_files:
144
154
  - CHANGES.rdoc
145
155
  - LICENCE.rdoc
146
156
  - README.rdoc
147
- files:
148
- - .rvmrc
157
+ files:
149
158
  - CHANGES.rdoc
150
159
  - LICENCE.rdoc
151
160
  - README.rdoc
@@ -158,10 +167,10 @@ files:
158
167
  - lib/t2-server-cli.rb
159
168
  - lib/t2-server.rb
160
169
  - lib/t2-server/admin.rb
161
- - lib/t2-server/connection-parameters.rb
162
- - lib/t2-server/connection.rb
163
- - lib/t2-server/credentials.rb
164
170
  - lib/t2-server/exceptions.rb
171
+ - lib/t2-server/net/connection.rb
172
+ - lib/t2-server/net/credentials.rb
173
+ - lib/t2-server/net/parameters.rb
165
174
  - lib/t2-server/port.rb
166
175
  - lib/t2-server/run.rb
167
176
  - lib/t2-server/server.rb
@@ -201,38 +210,30 @@ files:
201
210
  - version.yml
202
211
  homepage: http://www.taverna.org.uk/
203
212
  licenses: []
204
-
205
213
  post_install_message:
206
- rdoc_options:
214
+ rdoc_options:
207
215
  - -N
208
216
  - --tab-width=2
209
217
  - --main=README.rdoc
210
- require_paths:
218
+ require_paths:
211
219
  - lib
212
- required_ruby_version: !ruby/object:Gem::Requirement
220
+ required_ruby_version: !ruby/object:Gem::Requirement
213
221
  none: false
214
- requirements:
215
- - - ">="
216
- - !ruby/object:Gem::Version
217
- hash: 3
218
- segments:
219
- - 0
220
- version: "0"
221
- required_rubygems_version: !ruby/object:Gem::Requirement
222
+ requirements:
223
+ - - ! '>='
224
+ - !ruby/object:Gem::Version
225
+ version: '0'
226
+ required_rubygems_version: !ruby/object:Gem::Requirement
222
227
  none: false
223
- requirements:
224
- - - ">="
225
- - !ruby/object:Gem::Version
226
- hash: 3
227
- segments:
228
- - 0
229
- version: "0"
228
+ requirements:
229
+ - - ! '>='
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
230
232
  requirements: []
231
-
232
233
  rubyforge_project:
233
- rubygems_version: 1.8.10
234
+ rubygems_version: 1.8.21
234
235
  signing_key:
235
236
  specification_version: 3
236
237
  summary: Support for interacting with Taverna 2 Server.
237
- test_files:
238
+ test_files:
238
239
  - test/ts_t2server.rb
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use ruby-1.8.7@t2server --create