aspera-cli 4.10.0 → 4.11.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 (94) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/BUGS.md +20 -0
  4. data/CHANGELOG.md +509 -0
  5. data/CONTRIBUTING.md +118 -0
  6. data/README.md +621 -378
  7. data/bin/ascli +4 -4
  8. data/bin/asession +11 -11
  9. data/docs/test_env.conf +28 -19
  10. data/examples/aoc.rb +4 -4
  11. data/examples/dascli +11 -9
  12. data/examples/faspex4.rb +8 -8
  13. data/examples/node.rb +11 -11
  14. data/examples/server.rb +9 -9
  15. data/lib/aspera/aoc.rb +273 -266
  16. data/lib/aspera/ascmd.rb +56 -54
  17. data/lib/aspera/ats_api.rb +4 -4
  18. data/lib/aspera/cli/basic_auth_plugin.rb +15 -12
  19. data/lib/aspera/cli/extended_value.rb +5 -5
  20. data/lib/aspera/cli/formater.rb +64 -64
  21. data/lib/aspera/cli/listener/line_dump.rb +1 -1
  22. data/lib/aspera/cli/listener/logger.rb +1 -1
  23. data/lib/aspera/cli/listener/progress.rb +5 -6
  24. data/lib/aspera/cli/listener/progress_multi.rb +14 -19
  25. data/lib/aspera/cli/main.rb +66 -67
  26. data/lib/aspera/cli/manager.rb +110 -110
  27. data/lib/aspera/cli/plugin.rb +54 -37
  28. data/lib/aspera/cli/plugins/alee.rb +4 -4
  29. data/lib/aspera/cli/plugins/aoc.rb +308 -669
  30. data/lib/aspera/cli/plugins/ats.rb +44 -46
  31. data/lib/aspera/cli/plugins/bss.rb +10 -10
  32. data/lib/aspera/cli/plugins/config.rb +447 -344
  33. data/lib/aspera/cli/plugins/console.rb +12 -12
  34. data/lib/aspera/cli/plugins/cos.rb +18 -20
  35. data/lib/aspera/cli/plugins/faspex.rb +110 -112
  36. data/lib/aspera/cli/plugins/faspex5.rb +67 -46
  37. data/lib/aspera/cli/plugins/node.rb +364 -288
  38. data/lib/aspera/cli/plugins/orchestrator.rb +46 -46
  39. data/lib/aspera/cli/plugins/preview.rb +122 -114
  40. data/lib/aspera/cli/plugins/server.rb +137 -83
  41. data/lib/aspera/cli/plugins/shares.rb +30 -29
  42. data/lib/aspera/cli/plugins/sync.rb +13 -33
  43. data/lib/aspera/cli/transfer_agent.rb +57 -57
  44. data/lib/aspera/cli/version.rb +1 -1
  45. data/lib/aspera/colors.rb +3 -3
  46. data/lib/aspera/command_line_builder.rb +27 -27
  47. data/lib/aspera/cos_node.rb +22 -20
  48. data/lib/aspera/data_repository.rb +1 -1
  49. data/lib/aspera/environment.rb +30 -28
  50. data/lib/aspera/fasp/agent_base.rb +15 -15
  51. data/lib/aspera/fasp/agent_connect.rb +23 -21
  52. data/lib/aspera/fasp/agent_direct.rb +65 -67
  53. data/lib/aspera/fasp/agent_httpgw.rb +72 -68
  54. data/lib/aspera/fasp/agent_node.rb +23 -21
  55. data/lib/aspera/fasp/agent_trsdk.rb +20 -20
  56. data/lib/aspera/fasp/error.rb +3 -2
  57. data/lib/aspera/fasp/error_info.rb +11 -8
  58. data/lib/aspera/fasp/installation.rb +78 -78
  59. data/lib/aspera/fasp/listener.rb +1 -1
  60. data/lib/aspera/fasp/parameters.rb +75 -72
  61. data/lib/aspera/fasp/parameters.yaml +2 -2
  62. data/lib/aspera/fasp/resume_policy.rb +8 -8
  63. data/lib/aspera/fasp/transfer_spec.rb +35 -2
  64. data/lib/aspera/fasp/uri.rb +7 -7
  65. data/lib/aspera/faspex_gw.rb +7 -5
  66. data/lib/aspera/hash_ext.rb +3 -3
  67. data/lib/aspera/id_generator.rb +5 -5
  68. data/lib/aspera/keychain/encrypted_hash.rb +23 -28
  69. data/lib/aspera/keychain/macos_security.rb +21 -20
  70. data/lib/aspera/log.rb +7 -7
  71. data/lib/aspera/nagios.rb +19 -18
  72. data/lib/aspera/node.rb +209 -35
  73. data/lib/aspera/oauth.rb +37 -36
  74. data/lib/aspera/open_application.rb +19 -11
  75. data/lib/aspera/persistency_action_once.rb +4 -4
  76. data/lib/aspera/persistency_folder.rb +13 -13
  77. data/lib/aspera/preview/file_types.rb +8 -8
  78. data/lib/aspera/preview/generator.rb +67 -67
  79. data/lib/aspera/preview/utils.rb +27 -27
  80. data/lib/aspera/proxy_auto_config.js +41 -41
  81. data/lib/aspera/proxy_auto_config.rb +16 -16
  82. data/lib/aspera/rest.rb +56 -60
  83. data/lib/aspera/rest_call_error.rb +2 -1
  84. data/lib/aspera/rest_error_analyzer.rb +18 -17
  85. data/lib/aspera/rest_errors_aspera.rb +16 -16
  86. data/lib/aspera/secret_hider.rb +15 -13
  87. data/lib/aspera/ssh.rb +11 -10
  88. data/lib/aspera/sync.rb +158 -44
  89. data/lib/aspera/temp_file_manager.rb +2 -2
  90. data/lib/aspera/uri_reader.rb +4 -4
  91. data/lib/aspera/web_auth.rb +14 -13
  92. data.tar.gz.sig +0 -0
  93. metadata +8 -5
  94. metadata.gz.sig +0 -0
data/bin/ascli CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  require 'rubygems'
5
5
  require 'securerandom'
6
- GEM_ROOT=File.realpath(File.join(File.dirname(File.realpath(__FILE__)),'..'))
6
+ GEM_ROOT = File.realpath(File.join(File.dirname(File.realpath(__FILE__)), '..'))
7
7
  # coverage for tests
8
- if ENV.has_key?('ENABLE_COVERAGE')
8
+ if ENV.key?('ENABLE_COVERAGE')
9
9
  require 'simplecov'
10
10
  SimpleCov.root(GEM_ROOT)
11
11
  SimpleCov.enable_for_subprocesses if SimpleCov.respond_to?(:enable_for_subprocesses)
@@ -14,13 +14,13 @@ if ENV.has_key?('ENABLE_COVERAGE')
14
14
  SimpleCov.command_name(SecureRandom.uuid)
15
15
  SimpleCov.at_exit do
16
16
  original_file_descriptor = $stdout
17
- $stdout.reopen(File.join(GEM_ROOT,'simplecov.log'))
17
+ $stdout.reopen(File.join(GEM_ROOT, 'simplecov.log'))
18
18
  SimpleCov.result.format!
19
19
  $stdout.reopen(original_file_descriptor)
20
20
  end
21
21
  SimpleCov.start
22
22
  end
23
- $LOAD_PATH.unshift(File.join(GEM_ROOT,'lib'))
23
+ $LOAD_PATH.unshift(File.join(GEM_ROOT, 'lib'))
24
24
  require 'aspera/cli/main'
25
25
  require 'aspera/environment'
26
26
  Encoding.default_internal = Encoding::UTF_8
data/bin/asession CHANGED
@@ -13,9 +13,9 @@ TS_LOGLEVEL = 'EX_loglevel'
13
13
  # by default go to /tmp/username.filelist
14
14
  TS_TMP_FILELIST_FOLDER = 'EX_file_list_folder'
15
15
 
16
- SAMPLE_DEMO='"remote_host":"demo.asperasoft.com","remote_user":"asperaweb","ssh_port":33001,"remote_password":"demoaspera"'
17
- SAMPLE_DEMO2='"direction":"receive","destination_root":"./test.dir"'
18
- def assert_usage(assertion,errmsg)
16
+ SAMPLE_DEMO = '"remote_host":"demo.asperasoft.com","remote_user":"asperaweb","ssh_port":33001,"remote_password":"demoaspera"'
17
+ SAMPLE_DEMO2 = '"direction":"receive","destination_root":"./test.dir"'
18
+ def assert_usage(assertion, errmsg)
19
19
  return if assertion
20
20
  $stderr.puts('ERROR: '.red.blink + errmsg) if errmsg
21
21
  $stderr.puts('USAGE')
@@ -48,24 +48,24 @@ if ARGV.empty?
48
48
  parameter_source_err_msg = ' (JSON on stdin)'
49
49
  end
50
50
  # anyway expect only one argument: session information
51
- assert_usage(ARGV.length.eql?(1),'exactly one argument is expected')
52
- assert_usage(!['-h','--help'].include?(ARGV.first),nil)
51
+ assert_usage(ARGV.length.eql?(1), 'exactly one argument is expected')
52
+ assert_usage(!['-h', '--help'].include?(ARGV.first), nil)
53
53
  # parse transfer spec
54
54
  begin
55
55
  transfer_spec_arg = ARGV.pop
56
56
  transfer_spec = Aspera::Cli::ExtendedValue.instance.evaluate(transfer_spec_arg)
57
57
  rescue
58
- assert_usage(false,"Cannot extract transfer spec from: #{transfer_spec_arg}")
58
+ assert_usage(false, "Cannot extract transfer spec from: #{transfer_spec_arg}")
59
59
  end
60
60
  # ensure right type
61
- assert_usage(transfer_spec.is_a?(Hash),"the value must be a hash table#{parameter_source_err_msg}")
61
+ assert_usage(transfer_spec.is_a?(Hash), "the value must be a hash table#{parameter_source_err_msg}")
62
62
  # additional debug capability
63
- if transfer_spec.has_key?(TS_LOGLEVEL)
63
+ if transfer_spec.key?(TS_LOGLEVEL)
64
64
  Aspera::Log.instance.level = transfer_spec[TS_LOGLEVEL]
65
65
  transfer_spec.delete(TS_LOGLEVEL)
66
66
  end
67
67
  # possibly override temp folder
68
- if transfer_spec.has_key?(TS_TMP_FILELIST_FOLDER)
68
+ if transfer_spec.key?(TS_TMP_FILELIST_FOLDER)
69
69
  Aspera::Fasp::Parameters.file_list_folder = transfer_spec[TS_TMP_FILELIST_FOLDER]
70
70
  transfer_spec.delete(TS_TMP_FILELIST_FOLDER)
71
71
  end
@@ -77,10 +77,10 @@ client.add_listener(Aspera::Cli::Listener::LineDump.new)
77
77
  job_id = client.start_transfer(transfer_spec)
78
78
  # async commands
79
79
  Thread.new do
80
- begin
80
+ begin # rubocop:disable Style/RedundantBegin
81
81
  loop do
82
82
  data = JSON.parse($stdin.gets)
83
- client.send_command(job_id,0,data)
83
+ client.send_command(job_id, 0, data)
84
84
  end
85
85
  rescue
86
86
  Process.exit(1)
data/docs/test_env.conf CHANGED
@@ -3,11 +3,11 @@ config:
3
3
  version: 4.0.0
4
4
  default:
5
5
  config: cli_default
6
- aoc: tst_aoc1
6
+ aoc: tst_aoc_jwt
7
7
  faspex: tst_faspex
8
- faspex5: tst_faspex5
8
+ faspex5: tst_faspex5_jwt
9
9
  shares: tst_shares
10
- node: tst_node
10
+ node: tst_node_simple
11
11
  server: tst_server
12
12
  orchestrator: tst_orch
13
13
  console: tst_console
@@ -18,7 +18,6 @@ default:
18
18
  cli_default:
19
19
  interactive: your value here
20
20
  smtp: your value here
21
- secrets: your value here
22
21
  local_user:
23
22
  ssh_keys: your value here
24
23
  smtp_config:
@@ -30,11 +29,17 @@ smtp_config:
30
29
  from_name: your value here
31
30
  username: your value here
32
31
  password: your value here
33
- tst_aoc1:
32
+ tst_aoc_jwt:
34
33
  url: your value here
35
34
  username: your value here
36
35
  auth: your value here
37
36
  private_key: your value here
37
+ tst_aoc_web:
38
+ url: your value here
39
+ auth: your value here
40
+ redirect_uri: your value here
41
+ client_id: your value here
42
+ client_secret: your value here
38
43
  tst_faspex:
39
44
  url: your value here
40
45
  username: your value here
@@ -43,10 +48,6 @@ tst_faspex:
43
48
  tst_hstsfaspex_ssh:
44
49
  url: your value here
45
50
  username: your value here
46
- tst_node_faspex:
47
- url: your value here
48
- username: your value here
49
- password: your value here
50
51
  tst_faspex5_boot:
51
52
  url: your value here
52
53
  auth: your value here
@@ -57,8 +58,7 @@ tst_faspex5_web:
57
58
  auth: your value here
58
59
  redirect_uri: your value here
59
60
  client_id: your value here
60
- client_secret: your value here
61
- tst_faspex5:
61
+ tst_faspex5_jwt:
62
62
  url: your value here
63
63
  auth: your value here
64
64
  client_id: your value here
@@ -73,11 +73,23 @@ tst_shares_1:
73
73
  url: your value here
74
74
  username: your value here
75
75
  password: your value here
76
- tst_node:
76
+ tst_node_simple:
77
77
  url: your value here
78
78
  username: your value here
79
79
  password: your value here
80
- node_srv:
80
+ tst_node_ak:
81
+ url: your value here
82
+ username: your value here
83
+ password: your value here
84
+ tst_node_faspex:
85
+ url: your value here
86
+ username: your value here
87
+ password: your value here
88
+ tst_node_admak:
89
+ url: your value here
90
+ username: your value here
91
+ password: your value here
92
+ tst_node_preview:
81
93
  url: your value here
82
94
  username: your value here
83
95
  password: your value here
@@ -108,10 +120,6 @@ tst_ak_preview:
108
120
  username: your value here
109
121
  password: your value here
110
122
  mimemagic: your value here
111
- tst_node_preview:
112
- url: your value here
113
- username: your value here
114
- password: your value here
115
123
  tst_cos:
116
124
  apikey: your value here
117
125
  crn: your value here
@@ -120,6 +128,8 @@ tst_cos:
120
128
  sync:
121
129
  local_path: your value here
122
130
  remote_path: your value here
131
+ nowss:
132
+ ts: your value here
123
133
  misc:
124
134
  upload_folder: your value here
125
135
  syncuser: your value here
@@ -152,6 +162,7 @@ misc:
152
162
  aoc_shbx_meta: your value here
153
163
  aoc_ak_name: your value here
154
164
  aoc_ak_secret: your value here
165
+ aoc_test_folder: your value here
155
166
  icos_bucket_key: your value here
156
167
  icos_bucket_secret: your value here
157
168
  icos_bucket_name: your value here
@@ -165,5 +176,3 @@ misc:
165
176
  aoc_user_email: your value here
166
177
  aoc_workspace2: your value here
167
178
  http_gw_fqdn_port: your value here
168
- tst_secrets:
169
- eudemo-sedemo: your value here
data/examples/aoc.rb CHANGED
@@ -7,9 +7,9 @@ require 'aspera/log'
7
7
  Aspera::Log.instance.level = :debug
8
8
 
9
9
  if !ARGV.length.eql?(3)
10
- Aspera::Log.log.error("wrong number of args: #{ARGV.length}")
11
- Aspera::Log.log.error("Usage: #{$PROGRAM_NAME} <aoc URL> <aoc username> <aoc private key content>")
12
- Aspera::Log.log.error("Example: #{$PROGRAM_NAME} https://myorg.ibmaspera.com john@example.com $(cat /home/john/my_key.pem)")
10
+ Aspera::Log.log.error{"wrong number of args: #{ARGV.length}"}
11
+ Aspera::Log.log.error{"Usage: #{$PROGRAM_NAME} <aoc URL> <aoc username> <aoc private key content>"}
12
+ Aspera::Log.log.error{"Example: #{$PROGRAM_NAME} https://myorg.ibmaspera.com john@example.com $(cat /home/john/my_key.pem)"}
13
13
  Process.exit(1)
14
14
  end
15
15
 
@@ -27,4 +27,4 @@ aocapi = Aspera::AoC.new(
27
27
 
28
28
  self_user_data = aocapi.read('self')
29
29
 
30
- Aspera::Log.dump('self',self_user_data)
30
+ Aspera::Log.dump('self', self_user_data)
data/examples/dascli CHANGED
@@ -1,18 +1,18 @@
1
1
  #!/usr/bin/env bash
2
2
  # set env var image to specify another docker image
3
- # set env var version to specify another image version
4
- # set env var docker_args to add options to docker run
5
3
  : ${image:=martinlaurent/ascli}
6
- # by default take latest version
4
+ # set env var version to specify another image version (default: latest version)
7
5
  : ${version:=latest}
8
- : ${docker:=docker}
6
+ # set env var imgtag to specify a specific image/version
9
7
  : ${imgtag=$image:$version}
10
- # transform var into array
8
+ # set env var `docker` to podman, to use podman
9
+ : ${docker:=docker}
10
+ # set env var docker_args to add options to docker run (transform var into array)
11
11
  add_dock_args=( $docker_args )
12
- # same location as in Dockerfile: main config folder for ascli in container
13
- ascli_home_container=/home/cliuser/.aspera/ascli
14
- # set default location for config folder on host if necessary
12
+ # set env var ASCLI_HOME to set the config folder on host
15
13
  : ${ASCLI_HOME:=$HOME/.aspera/ascli}
14
+ # main config folder for ascli in container (same value as in `Dockerfile`)
15
+ ascli_home_container=/home/cliuser/.aspera/ascli
16
16
  if test ! -d $ASCLI_HOME;then
17
17
  echo "creating foder: $ASCLI_HOME"
18
18
  # create it if necessary to allow mounting the volume in container
@@ -22,7 +22,9 @@ exec $docker run \
22
22
  --rm \
23
23
  --tty \
24
24
  --interactive \
25
+ --user root \
26
+ --env ASCLI_HOME=$ascli_home_container \
25
27
  --volume "$ASCLI_HOME:$ascli_home_container" \
26
28
  "${add_dock_args[@]}" \
27
29
  $imgtag \
28
- ascli "$@"
30
+ "$@"
data/examples/faspex4.rb CHANGED
@@ -20,9 +20,9 @@ Aspera::Log.instance.level = :debug
20
20
  Aspera::Fasp::Installation.instance.folder = tmpdir
21
21
 
22
22
  if !ARGV.length.eql?(3)
23
- Aspera::Log.log.error("Wrong number of args: #{ARGV.length}")
24
- Aspera::Log.log.error("Usage: #{$PROGRAM_NAME} <faspex URL> <faspex username> <faspex password>")
25
- Aspera::Log.log.error("Example: #{$PROGRAM_NAME} https://faspex.com/aspera/faspex john p@sSw0rd")
23
+ Aspera::Log.log.error{"Wrong number of args: #{ARGV.length}"}
24
+ Aspera::Log.log.error{"Usage: #{$PROGRAM_NAME} <faspex URL> <faspex username> <faspex password>"}
25
+ Aspera::Log.log.error{"Example: #{$PROGRAM_NAME} https://faspex.com/aspera/faspex john p@sSw0rd"}
26
26
  Process.exit(1)
27
27
  end
28
28
 
@@ -52,7 +52,7 @@ api_v3.read('me')
52
52
  #---------------
53
53
 
54
54
  # create a sample file to send
55
- file_to_send = File.join(tmpdir,'myfile.bin')
55
+ file_to_send = File.join(tmpdir, 'myfile.bin')
56
56
  File.write(file_to_send, 'sample data')
57
57
  # package creation parameters
58
58
  package_create_params = {'delivery' => {
@@ -60,7 +60,7 @@ package_create_params = {'delivery' => {
60
60
  'recipients' => ['aspera.user1@gmail.com'],
61
61
  'sources' => [{'paths' => [file_to_send]}]
62
62
  }}
63
- pkg_created = api_v3.create('send',package_create_params)[:data]
63
+ pkg_created = api_v3.create('send', package_create_params)[:data]
64
64
  # get transfer specification (normally: only one)
65
65
  transfer_spec = pkg_created['xfer_sessions'].first
66
66
  # set paths of files to send
@@ -69,12 +69,12 @@ transfer_spec['paths'] = [{'source' => file_to_send}]
69
69
  transfer_client = Aspera::Fasp::AgentDirect.new({quiet: true})
70
70
  # start transfer (asynchronous)
71
71
  job_id = transfer_client.start_transfer(transfer_spec)
72
- Aspera::Log.dump('job_id',job_id)
72
+ Aspera::Log.dump('job_id', job_id)
73
73
  # wait for all transfer completion (for the example)
74
74
  result = transfer_client.wait_for_transfers_completion
75
75
  # notify of any transfer error
76
76
  result.reject{|i|i.eql?(:success)}.each do |e|
77
- Aspera::Log.log.error("A transfer error occurred: #{e.message}")
77
+ Aspera::Log.log.error{"A transfer error occurred: #{e.message}"}
78
78
  end
79
79
 
80
80
  # 3: Faspex 4 API v4
@@ -91,4 +91,4 @@ api_v4 = Aspera::Rest.new({
91
91
  }})
92
92
 
93
93
  # Use it. Note that Faspex 4 API v4 is totally different from Faspex 4 v3 APIs, see ref on line 2
94
- Aspera::Log.dump('users',api_v4.read('users')[:data])
94
+ Aspera::Log.dump('users', api_v4.read('users')[:data])
data/examples/node.rb CHANGED
@@ -15,7 +15,7 @@ require 'tmpdir'
15
15
 
16
16
  tmpdir = ENV['tmp'] || Dir.tmpdir || '.'
17
17
 
18
- raise 'Usage: PASSWORD=<password> $0 https://<address>:<port> <node user>' unless ARGV.length.eql?(2) && ENV.has_key?('PASSWORD')
18
+ raise 'Usage: PASSWORD=<password> $0 https://<address>:<port> <node user>' unless ARGV.length.eql?(2) && ENV.key?('PASSWORD')
19
19
 
20
20
  # example : https://node_asperaweb@eudemo.asperademo.com:9092
21
21
  node_uri = URI.parse(ARGV.shift)
@@ -34,10 +34,10 @@ Aspera::RestErrorsAspera.register_handlers
34
34
  # some required files are generated here (keys, certs)
35
35
  Aspera::Fasp::Installation.instance.folder = tmpdir
36
36
  # set path to your copy of ascp binary (else, let the system find)
37
- Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.has_key?('ascp')
37
+ Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.key?('ascp')
38
38
  # another way is to detect installed products and use one of them
39
- #Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
40
- #Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
39
+ # Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
40
+ # Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
41
41
  # or install:
42
42
  #
43
43
 
@@ -45,10 +45,10 @@ Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.has_key?('asc
45
45
  transfer_agent = Aspera::Fasp::AgentDirect.new
46
46
 
47
47
  # Note that it would also be possible to start transfers using other agents
48
- #require 'aspera/fasp/connect'
49
- #transfer_agent=Aspera::Fasp::Connect.new
50
- #require 'aspera/fasp/node'
51
- #transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
48
+ # require 'aspera/fasp/connect'
49
+ # transfer_agent=Aspera::Fasp::Connect.new
50
+ # require 'aspera/fasp/node'
51
+ # transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
52
52
 
53
53
  ##############################################################
54
54
  # Optional : register an event listener
@@ -57,7 +57,7 @@ transfer_agent = Aspera::Fasp::AgentDirect.new
57
57
  class MyListener < Aspera::Fasp::Listener
58
58
  # this is the callback called during transfers, here we only display the received information
59
59
  # but it could be used to get detailed error information, check "type" field is "ERROR"
60
- def event_enhanced(data);$stdout.puts(JSON.generate(data));$stdout.flush;end
60
+ def event_enhanced(data); $stdout.puts(JSON.generate(data)); $stdout.flush; end # rubocop:disable Style/Semicolon
61
61
  end
62
62
 
63
63
  # register the sample listener to display events
@@ -78,9 +78,9 @@ node_api = Aspera::Rest.new({
78
78
  sources = ["#{tmpdir}/sample_file.txt"]
79
79
  destination = '/Upload'
80
80
  # create sample file(s)
81
- sources.each{|p|File.write(p,'Hello World!')}
81
+ sources.each{|p|File.write(p, 'Hello World!')}
82
82
  # request transfer authorization to node for a single transfer (This is a node api v3 call)
83
- send_result = node_api.create('files/upload_setup',{ transfer_requests: [{ transfer_request: { paths: [{ destination: destination }] } }] })[:data]
83
+ send_result = node_api.create('files/upload_setup', { transfer_requests: [{ transfer_request: { paths: [{ destination: destination }] } }] })[:data]
84
84
  # we normally have only one transfer spec in list, so just get the first transfer_spec
85
85
  transfer_spec = send_result['transfer_specs'].first['transfer_spec']
86
86
  # add list of files to upload
data/examples/server.rb CHANGED
@@ -15,7 +15,7 @@ require 'tmpdir'
15
15
 
16
16
  tmpdir = ENV['tmp'] || Dir.tmpdir || '.'
17
17
 
18
- raise 'Usage: PASSWORD=<password> $0 ssh://<address>:<port> <transfer user>' unless ARGV.length.eql?(2) && ENV.has_key?('PASSWORD')
18
+ raise 'Usage: PASSWORD=<password> $0 ssh://<address>:<port> <transfer user>' unless ARGV.length.eql?(2) && ENV.key?('PASSWORD')
19
19
 
20
20
  # example : ssh://asperaweb@eudemo.asperademo.com:33001
21
21
  server_uri = URI.parse(ARGV.shift)
@@ -34,10 +34,10 @@ Aspera::RestErrorsAspera.register_handlers
34
34
  # some required files are generated here (keys, certs)
35
35
  Aspera::Fasp::Installation.instance.folder = tmpdir
36
36
  # set path to your copy of ascp binary (else, let the system find)
37
- Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.has_key?('ascp')
37
+ Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.key?('ascp')
38
38
  # another way is to detect installed products and use one of them
39
- #Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
40
- #Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
39
+ # Aspera::Fasp::Installation.instance.installed_products.each{|p|puts("found: #{p[:name]}")}
40
+ # Aspera::Fasp::Installation.instance.use_ascp_from_product('Aspera Connect')
41
41
  # or install:
42
42
  #
43
43
 
@@ -45,10 +45,10 @@ Aspera::Fasp::Installation.instance.ascp_path = ENV['ascp'] if ENV.has_key?('asc
45
45
  transfer_agent = Aspera::Fasp::AgentDirect.new
46
46
 
47
47
  # Note that it would also be possible to start transfers using other agents
48
- #require 'aspera/fasp/connect'
49
- #transfer_agent=Aspera::Fasp::Connect.new
50
- #require 'aspera/fasp/node'
51
- #transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
48
+ # require 'aspera/fasp/connect'
49
+ # transfer_agent=Aspera::Fasp::Connect.new
50
+ # require 'aspera/fasp/node'
51
+ # transfer_agent=Aspera::Fasp::Node.new(Aspera::Rest.new(...))
52
52
 
53
53
  ##############################################################
54
54
  # Optional : register an event listener
@@ -57,7 +57,7 @@ transfer_agent = Aspera::Fasp::AgentDirect.new
57
57
  class MyListener < Aspera::Fasp::Listener
58
58
  # this is the callback called during transfers, here we only display the received information
59
59
  # but it could be used to get detailed error information, check "type" field is "ERROR"
60
- def event_enhanced(data);$stdout.puts(JSON.generate(data));$stdout.flush;end
60
+ def event_enhanced(data); $stdout.puts(JSON.generate(data)); $stdout.flush; end # rubocop:disable Style/Semicolon
61
61
  end
62
62
 
63
63
  # register the sample listener to display events