aspera-cli 4.21.1 → 4.22.0

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.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/BUGS.md +1 -1
  4. data/CHANGELOG.md +52 -22
  5. data/CONTRIBUTING.md +69 -148
  6. data/README.md +929 -668
  7. data/bin/ascli +5 -14
  8. data/bin/asession +1 -3
  9. data/examples/get_proto_file.rb +4 -3
  10. data/examples/proxy.pac +20 -20
  11. data/lib/aspera/agent/base.rb +11 -5
  12. data/lib/aspera/agent/connect.rb +30 -28
  13. data/lib/aspera/agent/{alpha.rb → desktop.rb} +35 -31
  14. data/lib/aspera/agent/direct.rb +141 -121
  15. data/lib/aspera/agent/httpgw.rb +22 -26
  16. data/lib/aspera/agent/node.rb +14 -11
  17. data/lib/aspera/agent/transferd.rb +30 -19
  18. data/lib/aspera/api/alee.rb +1 -1
  19. data/lib/aspera/api/aoc.rb +6 -6
  20. data/lib/aspera/api/cos_node.rb +2 -2
  21. data/lib/aspera/api/httpgw.rb +7 -3
  22. data/lib/aspera/api/node.rb +10 -8
  23. data/lib/aspera/ascmd.rb +3 -3
  24. data/lib/aspera/ascp/installation.rb +53 -72
  25. data/lib/aspera/ascp/management.rb +1 -1
  26. data/lib/aspera/assert.rb +11 -2
  27. data/lib/aspera/cli/error.rb +2 -2
  28. data/lib/aspera/cli/extended_value.rb +46 -21
  29. data/lib/aspera/cli/formatter.rb +55 -48
  30. data/lib/aspera/cli/hints.rb +1 -1
  31. data/lib/aspera/cli/info.rb +1 -0
  32. data/lib/aspera/cli/main.rb +192 -170
  33. data/lib/aspera/cli/manager.rb +18 -18
  34. data/lib/aspera/cli/plugin.rb +23 -20
  35. data/lib/aspera/cli/plugin_factory.rb +1 -1
  36. data/lib/aspera/cli/plugins/alee.rb +1 -1
  37. data/lib/aspera/cli/plugins/aoc.rb +247 -159
  38. data/lib/aspera/cli/plugins/ats.rb +19 -17
  39. data/lib/aspera/cli/plugins/config.rb +76 -113
  40. data/lib/aspera/cli/plugins/console.rb +5 -3
  41. data/lib/aspera/cli/plugins/faspex.rb +39 -35
  42. data/lib/aspera/cli/plugins/faspex5.rb +111 -84
  43. data/lib/aspera/cli/plugins/faspio.rb +13 -1
  44. data/lib/aspera/cli/plugins/httpgw.rb +13 -1
  45. data/lib/aspera/cli/plugins/node.rb +312 -182
  46. data/lib/aspera/cli/plugins/orchestrator.rb +34 -40
  47. data/lib/aspera/cli/plugins/preview.rb +3 -3
  48. data/lib/aspera/cli/plugins/server.rb +6 -6
  49. data/lib/aspera/cli/plugins/shares.rb +5 -5
  50. data/lib/aspera/cli/sync_actions.rb +19 -18
  51. data/lib/aspera/cli/transfer_agent.rb +5 -5
  52. data/lib/aspera/cli/transfer_progress.rb +2 -2
  53. data/lib/aspera/cli/version.rb +1 -1
  54. data/lib/aspera/command_line_builder.rb +116 -95
  55. data/lib/aspera/coverage.rb +8 -5
  56. data/lib/aspera/environment.rb +26 -17
  57. data/lib/aspera/faspex_gw.rb +14 -14
  58. data/lib/aspera/faspex_postproc.rb +10 -11
  59. data/lib/aspera/hash_ext.rb +4 -14
  60. data/lib/aspera/json_rpc.rb +1 -1
  61. data/lib/aspera/keychain/encrypted_hash.rb +47 -34
  62. data/lib/aspera/keychain/factory.rb +41 -0
  63. data/lib/aspera/keychain/hashicorp_vault.rb +71 -0
  64. data/lib/aspera/keychain/macos_security.rb +19 -11
  65. data/lib/aspera/log.rb +28 -34
  66. data/lib/aspera/nagios.rb +6 -6
  67. data/lib/aspera/node_simulator.rb +8 -8
  68. data/lib/aspera/oauth/base.rb +14 -7
  69. data/lib/aspera/oauth/factory.rb +5 -6
  70. data/lib/aspera/oauth/url_json.rb +6 -6
  71. data/lib/aspera/persistency_action_once.rb +6 -4
  72. data/lib/aspera/persistency_folder.rb +2 -2
  73. data/lib/aspera/preview/generator.rb +13 -10
  74. data/lib/aspera/preview/options.rb +16 -16
  75. data/lib/aspera/preview/terminal.rb +4 -4
  76. data/lib/aspera/preview/utils.rb +15 -17
  77. data/lib/aspera/products/connect.rb +35 -1
  78. data/lib/aspera/products/{alpha.rb → desktop.rb} +3 -3
  79. data/lib/aspera/products/transferd.rb +9 -2
  80. data/lib/aspera/proxy_auto_config.rb +2 -2
  81. data/lib/aspera/rest.rb +56 -47
  82. data/lib/aspera/rest_errors_aspera.rb +1 -1
  83. data/lib/aspera/secret_hider.rb +12 -5
  84. data/lib/aspera/ssh.rb +4 -4
  85. data/lib/aspera/temp_file_manager.rb +5 -4
  86. data/lib/aspera/transfer/convert.rb +29 -0
  87. data/lib/aspera/transfer/error_info.rb +66 -66
  88. data/lib/aspera/transfer/parameters.rb +13 -68
  89. data/lib/aspera/transfer/spec.rb +5 -6
  90. data/lib/aspera/transfer/spec.schema.yaml +753 -0
  91. data/lib/aspera/transfer/spec_doc.rb +62 -0
  92. data/lib/aspera/transfer/sync.rb +23 -72
  93. data/lib/aspera/transfer/sync_instance.schema.yaml +13 -0
  94. data/lib/aspera/transfer/sync_session.schema.yaml +79 -0
  95. data/lib/aspera/transfer/uri.rb +6 -6
  96. data/lib/aspera/uri_reader.rb +18 -1
  97. data/lib/aspera/web_auth.rb +1 -1
  98. data/lib/aspera/web_server_simple.rb +53 -44
  99. data.tar.gz.sig +0 -0
  100. metadata +28 -165
  101. metadata.gz.sig +0 -0
  102. data/examples/build_exec +0 -74
  103. data/examples/build_exec_rubyc +0 -40
  104. data/examples/build_package.sh +0 -28
  105. data/lib/aspera/transfer/spec.yaml +0 -718
data/bin/ascli CHANGED
@@ -9,17 +9,8 @@ Encoding.default_internal = Encoding::UTF_8
9
9
  Encoding.default_external = Encoding::UTF_8
10
10
  $VERBOSE = old_verbose
11
11
 
12
- begin
13
- gem_lib_folder = File.join(File.dirname(File.dirname(File.realpath(__FILE__))), 'lib')
14
- Kernel.load(File.join(gem_lib_folder, 'aspera/coverage.rb'))
15
- begin
16
- require 'aspera/cli/main'
17
- rescue LoadError
18
- # if in development, add path toward gem
19
- $LOAD_PATH.unshift(gem_lib_folder)
20
- require 'aspera/cli/main'
21
- end
22
- require 'aspera/environment'
23
- Aspera::Environment.fix_home
24
- Aspera::Cli::Main.new(ARGV).process_command_line
25
- end
12
+ require 'aspera/coverage'
13
+ require 'aspera/environment'
14
+ require 'aspera/cli/main'
15
+ Aspera::Environment.fix_home
16
+ Aspera::Cli::Main.new(ARGV).process_command_line
data/bin/asession CHANGED
@@ -1,9 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- gem_lib_folder = File.join(File.dirname(File.dirname(File.realpath(__FILE__))), 'lib')
5
- Kernel.load(File.join(gem_lib_folder, 'aspera/coverage.rb'))
6
- $LOAD_PATH.unshift(gem_lib_folder)
4
+ require 'aspera/coverage'
7
5
  require 'aspera/agent/direct'
8
6
  require 'aspera/cli/extended_value'
9
7
  require 'aspera/products/transferd'
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # Retrieve `transfer.proto` from the web
5
- $LOAD_PATH.unshift(File.join(File.dirname(File.dirname(File.realpath(__FILE__))), 'lib'))
6
4
  require 'aspera/ascp/installation'
7
- Aspera::Ascp::Installation.instance.install_sdk(folder: ARGV.first, backup: false, with_exe: false) {|name| '/' if name.end_with?('transferd.proto')}
5
+ require 'aspera/cli/transfer_progress'
6
+ Aspera::RestParameters.instance.progress_bar = Aspera::Cli::TransferProgress.new
7
+ # Retrieve `transfer.proto` from the web
8
+ Aspera::Ascp::Installation.instance.install_sdk(folder: ARGV.first, backup: false, with_exe: false){ |name| name.end_with?('.proto') ? '/' : nil}
data/examples/proxy.pac CHANGED
@@ -11,20 +11,20 @@ function FindProxyForURL(url, host) {
11
11
 
12
12
  /* Don't proxy local domains */
13
13
  if (dnsDomainIs(host, ".example1.com") || (host == "example1.com")
14
- || dnsDomainIs(host, ".example2.com") || (host == "example2.com")
15
- || dnsDomainIs(host, ".example3.com") || (host == "example3.com")) {
14
+ || dnsDomainIs(host, ".example2.com") || (host == "example2.com")
15
+ || dnsDomainIs(host, ".example3.com") || (host == "example3.com")) {
16
16
  return 'DIRECT';
17
17
  }
18
18
 
19
19
  /* Don't proxy Windows Update */
20
20
  if ((host == "download.microsoft.com")
21
- || (host == "ntservicepack.microsoft.com")
22
- || (host == "cdm.microsoft.com") || (host == "wustat.windows.com")
23
- || (host == "windowsupdate.microsoft.com")
24
- || (dnsDomainIs(host, ".windowsupdate.microsoft.com"))
25
- || (host == "update.microsoft.com")
26
- || (dnsDomainIs(host, ".update.microsoft.com"))
27
- || (dnsDomainIs(host, ".windowsupdate.com"))) {
21
+ || (host == "ntservicepack.microsoft.com")
22
+ || (host == "cdm.microsoft.com") || (host == "wustat.windows.com")
23
+ || (host == "windowsupdate.microsoft.com")
24
+ || (dnsDomainIs(host, ".windowsupdate.microsoft.com"))
25
+ || (host == "update.microsoft.com")
26
+ || (dnsDomainIs(host, ".update.microsoft.com"))
27
+ || (dnsDomainIs(host, ".windowsupdate.com"))) {
28
28
  return 'DIRECT';
29
29
  }
30
30
 
@@ -33,22 +33,22 @@ function FindProxyForURL(url, host) {
33
33
 
34
34
  /* Don't proxy private addresses (RFC 3330) */
35
35
  if (isInNet(hostIP, '0.0.0.0', '255.0.0.0')
36
- || isInNet(hostIP, '10.0.0.0', '255.0.0.0')
37
- || isInNet(hostIP, '127.0.0.0', '255.0.0.0')
38
- || isInNet(hostIP, '169.254.0.0', '255.255.0.0')
39
- || isInNet(hostIP, '172.16.0.0', '255.240.0.0')
40
- || isInNet(hostIP, '192.0.2.0', '255.255.255.0')
41
- || isInNet(hostIP, '192.88.99.0', '255.255.255.0')
42
- || isInNet(hostIP, '192.168.0.0', '255.255.0.0')
43
- || isInNet(hostIP, '198.18.0.0', '255.254.0.0')
44
- || isInNet(hostIP, '224.0.0.0', '240.0.0.0')
45
- || isInNet(hostIP, '240.0.0.0', '240.0.0.0')) {
36
+ || isInNet(hostIP, '10.0.0.0', '255.0.0.0')
37
+ || isInNet(hostIP, '127.0.0.0', '255.0.0.0')
38
+ || isInNet(hostIP, '169.254.0.0', '255.255.0.0')
39
+ || isInNet(hostIP, '172.16.0.0', '255.240.0.0')
40
+ || isInNet(hostIP, '192.0.2.0', '255.255.255.0')
41
+ || isInNet(hostIP, '192.88.99.0', '255.255.255.0')
42
+ || isInNet(hostIP, '192.168.0.0', '255.255.0.0')
43
+ || isInNet(hostIP, '198.18.0.0', '255.254.0.0')
44
+ || isInNet(hostIP, '224.0.0.0', '240.0.0.0')
45
+ || isInNet(hostIP, '240.0.0.0', '240.0.0.0')) {
46
46
  return 'DIRECT';
47
47
  }
48
48
  }
49
49
 
50
50
  if (url.substring(0, 5) == 'http:' || url.substring(0, 6) == 'https:'
51
- || url.substring(0, 4) == 'ftp:') {
51
+ || url.substring(0, 4) == 'ftp:') {
52
52
  return 'PROXY proxy.example.com:8080';
53
53
  }
54
54
 
@@ -7,6 +7,7 @@ module Aspera
7
7
  # Base class for transfer agents
8
8
  class Base
9
9
  RUBY_EXT = '.rb'
10
+ private_constant :RUBY_EXT
10
11
  class << self
11
12
  def factory_create(agent, options)
12
13
  # Aspera.assert_values(agent, agent_list)
@@ -15,11 +16,12 @@ module Aspera
15
16
  end
16
17
 
17
18
  # discover available agents
19
+ # @return [Array] list of symbols of agents
18
20
  def agent_list
19
21
  base_class = File.basename(__FILE__)
20
22
  Dir.entries(File.dirname(File.expand_path(__FILE__))).select do |file|
21
23
  file.end_with?(RUBY_EXT) && !file.eql?(base_class)
22
- end.map{|file|file[0..(-1 - RUBY_EXT.length)].to_sym}
24
+ end.map{ |file| file[0..(-1 - RUBY_EXT.length)].to_sym}
23
25
  end
24
26
  end
25
27
 
@@ -29,16 +31,20 @@ module Aspera
29
31
  statuses = wait_for_transfers_completion
30
32
  @progress&.reset
31
33
  Aspera.assert_type(statuses, Array)
32
- Aspera.assert(statuses.none?{|i|!i.eql?(:success) && !i.is_a?(StandardError)}){"bad statuses content: #{statuses}"}
34
+ Aspera.assert(statuses.none?{ |i| !i.eql?(:success) && !i.is_a?(StandardError)}){"bad statuses content: #{statuses}"}
33
35
  return statuses
34
36
  end
35
37
 
36
38
  private
37
39
 
40
+ Aspera.require_method!(:start_transfer)
41
+ Aspera.require_method!(:wait_for_transfers_completion)
42
+ # method `shutdown` is optional
43
+ def shutdown
44
+ nil
45
+ end
46
+
38
47
  def initialize(progress: nil)
39
- # method `shutdown` is optional
40
- Aspera.assert(respond_to?(:start_transfer))
41
- Aspera.assert(respond_to?(:wait_for_transfers_completion))
42
48
  @progress = progress
43
49
  end
44
50
 
@@ -17,6 +17,7 @@ module Aspera
17
17
  private_constant :CONNECT_START_URIS, :SLEEP_SEC_BETWEEN_RETRY
18
18
  def initialize(**base_options)
19
19
  super
20
+ @transfer_id = nil
20
21
  @connect_settings = {
21
22
  'app_id' => SecureRandom.uuid
22
23
  }
@@ -46,21 +47,7 @@ module Aspera
46
47
  end
47
48
  end
48
49
 
49
- # @return the file path of local connect where API's URI can be read
50
- def connect_api_url
51
- connect_locations = Products::Other.find(Products::Connect.locations).first
52
- raise "Product: #{name} not found, please install." if connect_locations.nil?
53
- folder = File.join(connect_locations[:run_root], 'var', 'run')
54
- ['', 's'].each do |ext|
55
- uri_file = File.join(folder, "http#{ext}.uri")
56
- Log.log.debug{"checking connect port file: #{uri_file}"}
57
- if File.exist?(uri_file)
58
- return File.open(uri_file, &:gets).strip
59
- end
60
- end
61
- raise "no connect uri file found in #{folder}"
62
- end
63
-
50
+ # :reek:UnusedParameters token_regenerator
64
51
  def start_transfer(transfer_spec, token_regenerator: nil)
65
52
  if transfer_spec['direction'] == 'send'
66
53
  Log.log.warn{"Connect requires upload selection using GUI, ignoring #{transfer_spec['paths']}".red}
@@ -71,15 +58,14 @@ module Aspera
71
58
  'suggestedName' => '',
72
59
  'allowMultipleSelection' => true,
73
60
  'allowedFileTypes' => ''})
74
- transfer_spec['paths'] = selection['dataTransfer']['files'].map { |i| {'source' => i['name']}}
61
+ transfer_spec['paths'] = selection['dataTransfer']['files'].map{ |i| {'source' => i['name']}}
75
62
  end
76
- @request_id = SecureRandom.uuid
77
63
  # if there is a token, we ask connect client to use well known ssh private keys
78
64
  # instead of asking password
79
65
  transfer_spec['authentication'] = 'token' if transfer_spec.key?('token')
80
66
  connect_transfer_args = {
81
67
  'aspera_connect_settings' => @connect_settings.merge({
82
- 'request_id' => @request_id,
68
+ 'request_id' => SecureRandom.uuid,
83
69
  'allow_dialogs' => true
84
70
  }),
85
71
  'transfer_specs' => [{
@@ -87,17 +73,16 @@ module Aspera
87
73
  }]}
88
74
  # asynchronous anyway
89
75
  res = @connect_api.create('transfers/start', connect_transfer_args)
90
- @xfer_id = res['transfer_specs'].first['transfer_spec']['tags'][Transfer::Spec::TAG_RESERVED]['xfer_id']
76
+ @transfer_id = res['transfer_specs'].first['transfer_spec']['tags'][Transfer::Spec::TAG_RESERVED]['xfer_id']
91
77
  end
92
78
 
93
79
  def wait_for_transfers_completion
94
80
  connect_activity_args = {'aspera_connect_settings' => @connect_settings}
95
81
  started = false
96
82
  pre_calc = false
97
- session_id = @xfer_id
98
83
  begin
99
84
  loop do
100
- tr_info = @connect_api.create("transfers/info/#{@xfer_id}", connect_activity_args)
85
+ tr_info = @connect_api.create("transfers/info/#{@transfer_id}", connect_activity_args)
101
86
  Log.log.trace1{Log.dump(:tr_info, tr_info)}
102
87
  if tr_info['transfer_info'].is_a?(Hash)
103
88
  transfer = tr_info['transfer_info']
@@ -111,26 +96,26 @@ module Aspera
111
96
  notify_progress(:pre_start, session_id: nil, info: transfer['status'])
112
97
  when 'running'
113
98
  if !started
114
- notify_progress(:session_start, session_id: session_id)
99
+ notify_progress(:session_start, session_id: @transfer_id)
115
100
  started = true
116
101
  end
117
102
  if !pre_calc && (transfer['bytes_expected'] != 0)
118
- notify_progress(:session_size, session_id: session_id, info: transfer['bytes_expected'])
103
+ notify_progress(:session_size, session_id: @transfer_id, info: transfer['bytes_expected'])
119
104
  pre_calc = true
120
105
  else
121
- notify_progress(:transfer, session_id: session_id, info: transfer['bytes_written'])
106
+ notify_progress(:transfer, session_id: @transfer_id, info: transfer['bytes_written'])
122
107
  end
123
108
  when 'completed'
124
- notify_progress(:end, session_id: session_id)
109
+ notify_progress(:end, session_id: @transfer_id)
125
110
  break
126
111
  when 'failed'
127
- notify_progress(:end, session_id: session_id)
112
+ notify_progress(:end, session_id: @transfer_id)
128
113
  raise Transfer::Error, transfer['error_desc']
129
114
  when 'cancelled'
130
- notify_progress(:end, session_id: session_id)
115
+ notify_progress(:end, session_id: @transfer_id)
131
116
  raise Transfer::Error, 'Transfer cancelled by user'
132
117
  else
133
- notify_progress(:end, session_id: session_id)
118
+ notify_progress(:end, session_id: @transfer_id)
134
119
  raise Transfer::Error, "unknown status: #{transfer['status']}: #{transfer['error_desc']}"
135
120
  end
136
121
  end
@@ -141,6 +126,23 @@ module Aspera
141
126
  end
142
127
  return [:success]
143
128
  end
129
+
130
+ private
131
+
132
+ # @return the file path of local connect where API's URI can be read
133
+ def connect_api_url
134
+ connect_locations = Products::Other.find(Products::Connect.locations).first
135
+ raise "Product: #{name} not found, please install." if connect_locations.nil?
136
+ folder = File.join(connect_locations[:run_root], 'var', 'run')
137
+ ['', 's'].each do |ext|
138
+ uri_file = File.join(folder, "http#{ext}.uri")
139
+ Log.log.debug{"checking connect port file: #{uri_file}"}
140
+ if File.exist?(uri_file)
141
+ return File.open(uri_file, &:gets).strip
142
+ end
143
+ end
144
+ raise "no connect uri file found in #{folder}"
145
+ end
144
146
  end
145
147
  end
146
148
  end
@@ -4,13 +4,13 @@ require 'aspera/agent/base'
4
4
  require 'aspera/rest'
5
5
  require 'aspera/environment'
6
6
  require 'aspera/json_rpc'
7
- require 'aspera/products/alpha'
7
+ require 'aspera/products/desktop'
8
8
  require 'securerandom'
9
9
 
10
10
  module Aspera
11
11
  module Agent
12
- # Aspera Desktop Alpha Client
13
- class Alpha < Base
12
+ # Client: Aspera for Desktop
13
+ class Desktop < Base
14
14
  # try twice the main init url in sequence
15
15
  START_URIS = ['aspera://', 'aspera://', 'aspera://']
16
16
  # delay between each try to start the app
@@ -19,7 +19,7 @@ module Aspera
19
19
 
20
20
  def initialize(**base_options)
21
21
  @application_id = SecureRandom.uuid
22
- @xfer_id = nil
22
+ @transfer_id = nil
23
23
  super
24
24
  raise 'Using client requires a graphical environment' if !Environment.default_gui_mode.eql?(:graphical)
25
25
  method_index = 0
@@ -33,39 +33,25 @@ module Aspera
33
33
  rescue Errno::ECONNREFUSED => e
34
34
  start_url = START_URIS[method_index]
35
35
  method_index += 1
36
- raise StandardError, "Unable to start #{Products::Alpha::APP_NAME} #{method_index} times" if start_url.nil?
37
- Log.log.warn{"#{Products::Alpha::APP_NAME} is not started (#{e}). Trying to start it ##{method_index}..."}
36
+ raise StandardError, "Unable to start #{Products::Desktop::APP_NAME} #{method_index} times" if start_url.nil?
37
+ Log.log.warn{"#{Products::Desktop::APP_NAME} is not started (#{e}). Trying to start it ##{method_index}..."}
38
38
  if !Environment.open_uri_graphical(start_url)
39
39
  Environment.open_uri_graphical('https://www.ibm.com/aspera/connect/')
40
- raise StandardError, "#{Products::Alpha::APP_NAME} is not installed"
40
+ raise StandardError, "#{Products::Desktop::APP_NAME} is not installed"
41
41
  end
42
42
  sleep(SLEEP_SEC_BETWEEN_RETRY)
43
43
  retry
44
44
  end
45
45
  end
46
46
 
47
- def aspera_client_api_url
48
- log_file = Products::Alpha.log_file
49
- url = 'http://127.0.0.1:33024'
50
- File.open(log_file, 'r') do |file|
51
- file.each_line do |line|
52
- line = line.chomp
53
- if (m = line.match(/JSON-RPC server listening on (.*)/))
54
- url = "http://#{m[1]}"
55
- end
56
- end
57
- end
58
- # raise StandardError, "Unable to find the JSON-RPC server URL in #{log_file}" if url.nil?
59
- return url
60
- end
61
-
47
+ # :reek:UnusedParameters token_regenerator
62
48
  def start_transfer(transfer_spec, token_regenerator: nil)
63
49
  @request_id = SecureRandom.uuid
64
50
  # if there is a token, we ask the client app to use well known ssh private keys
65
51
  # instead of asking password
66
52
  transfer_spec['authentication'] = 'token' if transfer_spec.key?('token')
67
53
  result = @client_app_api.start_transfer(app_id: @application_id, desktop_spec: {}, transfer_spec: transfer_spec)
68
- @xfer_id = result['uuid']
54
+ @transfer_id = result['uuid']
69
55
  end
70
56
 
71
57
  def wait_for_transfers_completion
@@ -73,32 +59,32 @@ module Aspera
73
59
  pre_calc = false
74
60
  begin
75
61
  loop do
76
- transfer = @client_app_api.get_transfer(app_id: @application_id, transfer_id: @xfer_id)
62
+ transfer = @client_app_api.get_transfer(app_id: @application_id, transfer_id: @transfer_id)
77
63
  case transfer['status']
78
64
  when 'initiating', 'queued'
79
65
  notify_progress(:pre_start, session_id: nil, info: transfer['status'])
80
66
  when 'running'
81
67
  if !started
82
- notify_progress(:session_start, session_id: @xfer_id)
68
+ notify_progress(:session_start, session_id: @transfer_id)
83
69
  started = true
84
70
  end
85
71
  if !pre_calc && (transfer['bytes_expected'] != 0)
86
- notify_progress(:session_size, session_id: @xfer_id, info: transfer['bytes_expected'])
72
+ notify_progress(:session_size, session_id: @transfer_id, info: transfer['bytes_expected'])
87
73
  pre_calc = true
88
74
  else
89
- notify_progress(:transfer, session_id: @xfer_id, info: transfer['bytes_written'])
75
+ notify_progress(:transfer, session_id: @transfer_id, info: transfer['bytes_written'])
90
76
  end
91
77
  when 'completed'
92
- notify_progress(:end, session_id: @xfer_id)
78
+ notify_progress(:end, session_id: @transfer_id)
93
79
  break
94
80
  when 'failed'
95
- notify_progress(:end, session_id: @xfer_id)
81
+ notify_progress(:end, session_id: @transfer_id)
96
82
  raise Transfer::Error, transfer['error_desc']
97
83
  when 'cancelled'
98
- notify_progress(:end, session_id: @xfer_id)
84
+ notify_progress(:end, session_id: @transfer_id)
99
85
  raise Transfer::Error, 'Transfer cancelled by user'
100
86
  else
101
- notify_progress(:end, session_id: @xfer_id)
87
+ notify_progress(:end, session_id: @transfer_id)
102
88
  raise Transfer::Error, "unknown status: #{transfer['status']}: #{transfer['error_desc']}"
103
89
  end
104
90
  sleep(1)
@@ -108,6 +94,24 @@ module Aspera
108
94
  end
109
95
  return [:success]
110
96
  end
97
+
98
+ private
99
+
100
+ # @return [String] the url where transferd is listening
101
+ def aspera_client_api_url
102
+ log_file = Products::Desktop.log_file
103
+ url = 'http://127.0.0.1:33024'
104
+ File.open(log_file, 'r') do |file|
105
+ file.each_line do |line|
106
+ line = line.chomp
107
+ if (m = line.match(/JSON-RPC server listening on (.*)/))
108
+ url = "http://#{m[1]}"
109
+ end
110
+ end
111
+ end
112
+ # raise StandardError, "Unable to find the JSON-RPC server URL in #{log_file}" if url.nil?
113
+ return url
114
+ end
111
115
  end
112
116
  end
113
117
  end