aspera-cli 4.9.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 (95) 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 +1241 -916
  7. data/bin/ascli +4 -4
  8. data/bin/asession +11 -11
  9. data/docs/test_env.conf +32 -21
  10. data/examples/aoc.rb +4 -4
  11. data/examples/dascli +16 -9
  12. data/examples/faspex4.rb +8 -8
  13. data/examples/node.rb +12 -12
  14. data/examples/server.rb +10 -10
  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/info.rb +2 -2
  22. data/lib/aspera/cli/listener/line_dump.rb +1 -1
  23. data/lib/aspera/cli/listener/logger.rb +1 -1
  24. data/lib/aspera/cli/listener/progress.rb +5 -6
  25. data/lib/aspera/cli/listener/progress_multi.rb +14 -19
  26. data/lib/aspera/cli/main.rb +66 -67
  27. data/lib/aspera/cli/manager.rb +112 -110
  28. data/lib/aspera/cli/plugin.rb +57 -36
  29. data/lib/aspera/cli/plugins/alee.rb +4 -4
  30. data/lib/aspera/cli/plugins/aoc.rb +309 -670
  31. data/lib/aspera/cli/plugins/ats.rb +44 -46
  32. data/lib/aspera/cli/plugins/bss.rb +10 -10
  33. data/lib/aspera/cli/plugins/config.rb +497 -378
  34. data/lib/aspera/cli/plugins/console.rb +12 -12
  35. data/lib/aspera/cli/plugins/cos.rb +18 -20
  36. data/lib/aspera/cli/plugins/faspex.rb +112 -114
  37. data/lib/aspera/cli/plugins/faspex5.rb +71 -46
  38. data/lib/aspera/cli/plugins/node.rb +379 -283
  39. data/lib/aspera/cli/plugins/orchestrator.rb +46 -46
  40. data/lib/aspera/cli/plugins/preview.rb +122 -114
  41. data/lib/aspera/cli/plugins/server.rb +137 -83
  42. data/lib/aspera/cli/plugins/shares.rb +30 -29
  43. data/lib/aspera/cli/plugins/sync.rb +13 -33
  44. data/lib/aspera/cli/transfer_agent.rb +60 -59
  45. data/lib/aspera/cli/version.rb +1 -1
  46. data/lib/aspera/colors.rb +3 -3
  47. data/lib/aspera/command_line_builder.rb +27 -27
  48. data/lib/aspera/cos_node.rb +22 -20
  49. data/lib/aspera/data_repository.rb +1 -1
  50. data/lib/aspera/environment.rb +35 -15
  51. data/lib/aspera/fasp/agent_base.rb +15 -15
  52. data/lib/aspera/fasp/agent_connect.rb +23 -21
  53. data/lib/aspera/fasp/agent_direct.rb +66 -64
  54. data/lib/aspera/fasp/agent_httpgw.rb +141 -78
  55. data/lib/aspera/fasp/agent_node.rb +23 -21
  56. data/lib/aspera/fasp/agent_trsdk.rb +20 -20
  57. data/lib/aspera/fasp/error.rb +3 -2
  58. data/lib/aspera/fasp/error_info.rb +11 -8
  59. data/lib/aspera/fasp/installation.rb +79 -79
  60. data/lib/aspera/fasp/listener.rb +1 -1
  61. data/lib/aspera/fasp/parameters.rb +86 -71
  62. data/lib/aspera/fasp/parameters.yaml +7 -4
  63. data/lib/aspera/fasp/resume_policy.rb +8 -8
  64. data/lib/aspera/fasp/transfer_spec.rb +35 -2
  65. data/lib/aspera/fasp/uri.rb +7 -7
  66. data/lib/aspera/faspex_gw.rb +7 -5
  67. data/lib/aspera/hash_ext.rb +3 -3
  68. data/lib/aspera/id_generator.rb +5 -5
  69. data/lib/aspera/keychain/encrypted_hash.rb +38 -105
  70. data/lib/aspera/keychain/macos_security.rb +128 -57
  71. data/lib/aspera/log.rb +7 -7
  72. data/lib/aspera/nagios.rb +19 -18
  73. data/lib/aspera/node.rb +209 -35
  74. data/lib/aspera/oauth.rb +37 -36
  75. data/lib/aspera/open_application.rb +19 -11
  76. data/lib/aspera/persistency_action_once.rb +4 -4
  77. data/lib/aspera/persistency_folder.rb +16 -15
  78. data/lib/aspera/preview/file_types.rb +8 -8
  79. data/lib/aspera/preview/generator.rb +67 -67
  80. data/lib/aspera/preview/utils.rb +27 -27
  81. data/lib/aspera/proxy_auto_config.js +41 -41
  82. data/lib/aspera/proxy_auto_config.rb +21 -14
  83. data/lib/aspera/rest.rb +72 -67
  84. data/lib/aspera/rest_call_error.rb +2 -1
  85. data/lib/aspera/rest_error_analyzer.rb +18 -17
  86. data/lib/aspera/rest_errors_aspera.rb +16 -16
  87. data/lib/aspera/secret_hider.rb +15 -13
  88. data/lib/aspera/ssh.rb +11 -10
  89. data/lib/aspera/sync.rb +158 -44
  90. data/lib/aspera/temp_file_manager.rb +2 -2
  91. data/lib/aspera/uri_reader.rb +4 -4
  92. data/lib/aspera/web_auth.rb +14 -13
  93. data.tar.gz.sig +0 -0
  94. metadata +11 -36
  95. metadata.gz.sig +0 -0
@@ -2,27 +2,26 @@
2
2
 
3
3
  require 'aspera/fasp/listener'
4
4
  require 'ruby-progressbar'
5
+ require 'aspera/environment'
5
6
 
6
7
  module Aspera
7
8
  module Cli
8
9
  module Listener
9
10
  # a listener to FASP event that displays a progress bar
10
- class Progress < Fasp::Listener
11
+ class Progress < Aspera::Fasp::Listener
11
12
  def initialize
12
13
  super
13
14
  @progress = nil
14
15
  @cumulative = 0
15
16
  end
16
17
 
17
- BYTE_PER_MEGABIT = (1024 * 1024) / 8
18
-
19
18
  def event_struct(data)
20
19
  case data['Type']
21
20
  when 'NOTIFICATION'
22
- if data.has_key?('PreTransferBytes')
21
+ if data.key?('PreTransferBytes')
23
22
  @progress = ProgressBar.create(
24
23
  format: '%a %B %p%% %r Mbps %e',
25
- rate_scale: lambda{|rate|rate / BYTE_PER_MEGABIT},
24
+ rate_scale: lambda{|rate|rate / Environment::BYTES_PER_MEBIBIT},
26
25
  title: 'progress',
27
26
  total: data['PreTransferBytes'].to_i)
28
27
  end
@@ -33,7 +32,7 @@ module Aspera
33
32
  if @progress.nil?
34
33
  puts '.'
35
34
  else
36
- @progress.progress = data.has_key?('Bytescont') ? @cumulative + data['Bytescont'].to_i : data['TransferBytes'].to_i
35
+ @progress.progress = data.key?('Bytescont') ? @cumulative + data['Bytescont'].to_i : data['TransferBytes'].to_i
37
36
  end
38
37
  when 'DONE'
39
38
  if @progress.nil?
@@ -2,13 +2,14 @@
2
2
 
3
3
  require 'aspera/fasp/listener'
4
4
  require 'aspera/fasp/agent_base'
5
+ require 'aspera/environment'
5
6
  require 'ruby-progressbar'
6
7
 
7
8
  module Aspera
8
9
  module Cli
9
10
  module Listener
10
11
  # a listener to FASP event that displays a progress bar
11
- class ProgressMulti < Fasp::Listener
12
+ class ProgressMulti < Aspera::Fasp::Listener
12
13
  def initialize
13
14
  super
14
15
  @progress_bar = nil
@@ -20,34 +21,28 @@ module Aspera
20
21
  @sessions = {}
21
22
  end
22
23
 
23
- BYTE_PER_MEGABIT = 1024 * 1024 / 8
24
-
25
24
  def update_total
26
- begin
27
- @progress_bar.total = @sessions.values.inject(0){|m,s|m += s[:job_size].to_i;m;}
28
- rescue StandardError
29
- nil
30
- end
25
+ @progress_bar.total = @sessions.values.inject(0){|m, s|m + s[:job_size].to_i}
26
+ rescue StandardError
27
+ nil
31
28
  end
32
29
 
33
30
  def update_progress
34
- begin
35
- @progress_bar.progress = @sessions.values.inject(0){|m,s|m += s[:current].to_i;m;}
36
- rescue StandardError
37
- nil
38
- end
31
+ @progress_bar.progress = @sessions.values.inject(0){|m, s|m + s[:current].to_i}
32
+ rescue StandardError
33
+ nil
39
34
  end
40
35
 
41
36
  def event_enhanced(data)
42
37
  if @progress_bar.nil?
43
38
  @progress_bar = ProgressBar.create(
44
39
  format: '%t %a %B %p%% %r Mbps %e',
45
- rate_scale: lambda{|rate|rate / BYTE_PER_MEGABIT},
40
+ rate_scale: lambda{|rate|rate / Environment::BYTES_PER_MEBIBIT},
46
41
  title: '',
47
42
  total: nil)
48
43
  end
49
- if !data.has_key?(Fasp::AgentBase::LISTENER_SESSION_ID_S)
50
- Log.log.error("Internal error: no #{Fasp::AgentBase::LISTENER_SESSION_ID_S} in event: #{data}")
44
+ if !data.key?(Fasp::AgentBase::LISTENER_SESSION_ID_S)
45
+ Log.log.error{"Internal error: no #{Fasp::AgentBase::LISTENER_SESSION_ID_S} in event: #{data}"}
51
46
  return
52
47
  end
53
48
  newtitle = @sessions.length < 2 ? '' : "multi=#{@sessions.length}"
@@ -61,7 +56,7 @@ module Aspera
61
56
  when 'INIT' # connection to ascp (get id)
62
57
  when 'SESSION' # session information
63
58
  when 'NOTIFICATION' # sent from remote
64
- if data.has_key?('pre_transfer_bytes')
59
+ if data.key?('pre_transfer_bytes')
65
60
  session[:job_size] = data['pre_transfer_bytes']
66
61
  update_total
67
62
  end
@@ -69,7 +64,7 @@ module Aspera
69
64
  if @progress_bar.total.nil?
70
65
  @progress_bar.increment
71
66
  else
72
- session[:current] = data.has_key?('bytescont') ? session[:cumulative] + data['bytescont'].to_i : data['transfer_bytes'].to_i
67
+ session[:current] = data.key?('bytescont') ? session[:cumulative] + data['bytescont'].to_i : data['transfer_bytes'].to_i
73
68
  update_progress
74
69
  end
75
70
  when 'STOP'
@@ -80,7 +75,7 @@ module Aspera
80
75
  update_progress
81
76
  update_total
82
77
  else
83
- Log.log.debug("ignore: #{data['type']}")
78
+ Log.log.debug{"ignore: #{data['type']}"}
84
79
  end
85
80
  end
86
81
  end
@@ -25,7 +25,7 @@ module Aspera
25
25
  # prefix to display error messages in user messages (terminal)
26
26
  ERROR_FLASH = 'ERROR:'.bg_red.gray.blink.freeze
27
27
  WARNING_FLASH = 'WARNING:'.bg_red.gray.blink.freeze
28
- private_constant :ERROR_FLASH,:WARNING_FLASH
28
+ private_constant :ERROR_FLASH, :WARNING_FLASH
29
29
 
30
30
  # store transfer result using this key and use result_transfer_multiple
31
31
  STATUS_FIELD = 'status'
@@ -66,7 +66,7 @@ module Aspera
66
66
  item[STATUS_FIELD] = item[STATUS_FIELD].map(&:to_s).join(',')
67
67
  end
68
68
  raise global_status unless global_status.eql?(:success)
69
- return {type: :object_list,data: status_table}
69
+ return {type: :object_list, data: status_table}
70
70
  end
71
71
  end
72
72
 
@@ -85,9 +85,9 @@ module Aspera
85
85
  # @param http [Net::HTTP] the newly created http session object
86
86
  def http_parameters=(http)
87
87
  if @option_insecure
88
- url=http.inspect.gsub(/^[^ ]* /,'https://').gsub(/ [^ ]*$/,'')
88
+ url = http.inspect.gsub(/^[^ ]* /, 'https://').gsub(/ [^ ]*$/, '')
89
89
  if !@ssl_warned_urls.include?(url)
90
- @plugin_env[:formater].display_message(:error,"#{WARNING_FLASH} ignoring certificate for: #{url}. Only for tests, do not use in production.")
90
+ @plugin_env[:formater].display_message(:error, "#{WARNING_FLASH} ignoring certificate for: #{url}. Do not use unsafe certificates in production.")
91
91
  @ssl_warned_urls.push(url)
92
92
  end
93
93
  http.verify_mode = SELF_SIGNED_CERT
@@ -95,14 +95,14 @@ module Aspera
95
95
  http.set_debug_output($stdout) if @option_rest_debug
96
96
  raise 'http_options expects Hash' unless @option_http_options.is_a?(Hash)
97
97
 
98
- @option_http_options.each do |k,v|
98
+ @option_http_options.each do |k, v|
99
99
  method = "#{k}=".to_sym
100
100
  # check if accessor is a method of Net::HTTP
101
101
  # continue_timeout= read_timeout= write_timeout=
102
102
  if http.respond_to?(method)
103
- http.send(method,v)
103
+ http.send(method, v)
104
104
  else
105
- Log.log.error("no such attribute: #{k}")
105
+ Log.log.error{"no such attribute: #{k}"}
106
106
  end
107
107
  end
108
108
  end
@@ -113,7 +113,7 @@ module Aspera
113
113
  early_debug_setup(argv)
114
114
  # compare $0 with expected name
115
115
  current_prog_name = File.basename($PROGRAM_NAME)
116
- @plugin_env[:formater].display_message(:error,"#{'WARNING'.bg_red.blink.gray} Please use '#{PROGRAM_NAME}' instead of '#{current_prog_name}'") \
116
+ @plugin_env[:formater].display_message(:error, "#{'WARNING'.bg_red.blink.gray} Please use '#{PROGRAM_NAME}' instead of '#{current_prog_name}'") \
117
117
  unless current_prog_name.eql?(PROGRAM_NAME)
118
118
  @option_help = false
119
119
  @bash_completion = false
@@ -122,11 +122,11 @@ module Aspera
122
122
  @option_rest_debug = false
123
123
  @option_cache_tokens = true
124
124
  @option_http_options = {}
125
- @ssl_warned_urls=[]
125
+ @ssl_warned_urls = []
126
126
  # environment provided to plugin for various capabilities
127
127
  @plugin_env = {}
128
128
  # give command line arguments to option manager
129
- @plugin_env[:options] = @opt_mgr = Manager.new(PROGRAM_NAME,argv: argv)
129
+ @plugin_env[:options] = @opt_mgr = Manager.new(PROGRAM_NAME, argv: argv)
130
130
  # formatter adds options
131
131
  @plugin_env[:formater] = Formater.new(@plugin_env[:options])
132
132
  Rest.user_agent = PROGRAM_NAME
@@ -136,13 +136,13 @@ module Aspera
136
136
  # the Config plugin adds the @preset parser, so declare before TransferAgent which may use it
137
137
  @plugin_env[:config] = Plugins::Config.new(@plugin_env, gem: GEM_NAME, name: PROGRAM_NAME, help: DOC_URL, version: Aspera::Cli::VERSION)
138
138
  # the TransferAgent plugin may use the @preset parser
139
- @plugin_env[:transfer] = TransferAgent.new(@plugin_env[:options],@plugin_env[:config])
139
+ @plugin_env[:transfer] = TransferAgent.new(@plugin_env[:options], @plugin_env[:config])
140
140
  # data persistency
141
- @plugin_env[:persistency] = PersistencyFolder.new(File.join(@plugin_env[:config].main_folder,'persist_store'))
141
+ @plugin_env[:persistency] = PersistencyFolder.new(File.join(@plugin_env[:config].main_folder, 'persist_store'))
142
142
  Log.log.debug('plugin env created'.red)
143
143
  Oauth.persist_mgr = @plugin_env[:persistency] if @option_cache_tokens
144
- Fasp::Parameters.file_list_folder = File.join(@plugin_env[:config].main_folder,'filelists')
145
- Aspera::RestErrorAnalyzer.instance.log_file = File.join(@plugin_env[:config].main_folder,'rest_exceptions.log')
144
+ Fasp::Parameters.file_list_folder = File.join(@plugin_env[:config].main_folder, 'filelists')
145
+ Aspera::RestErrorAnalyzer.instance.log_file = File.join(@plugin_env[:config].main_folder, 'rest_exceptions.log')
146
146
  # register aspera REST call error handlers
147
147
  Aspera::RestErrorsAspera.register_handlers
148
148
  # set banner when all environment is created so that additional extended value modifiers are known, e.g. @preset
@@ -150,7 +150,7 @@ module Aspera
150
150
  end
151
151
 
152
152
  def app_banner
153
- t=' '*8
153
+ t = ' ' * 8
154
154
  return <<~END_OF_BANNER
155
155
  NAME
156
156
  #{t}#{PROGRAM_NAME} -- a command line tool for Aspera Applications (v#{Aspera::Cli::VERSION})
@@ -187,32 +187,31 @@ module Aspera
187
187
  # define header for manual
188
188
  def init_global_options
189
189
  Log.log.debug('init_global_options')
190
- @opt_mgr.add_opt_switch(:help,'-h','Show this message.') { @option_help = true }
191
- @opt_mgr.add_opt_switch(:bash_comp,'generate bash completion for command') { @bash_completion = true }
190
+ @opt_mgr.add_opt_switch(:help, '-h', 'Show this message.') { @option_help = true }
191
+ @opt_mgr.add_opt_switch(:bash_comp, 'generate bash completion for command') { @bash_completion = true }
192
192
  @opt_mgr.add_opt_switch(:show_config, 'Display parameters used for the provided action.') { @option_show_config = true }
193
- @opt_mgr.add_opt_switch(:rest_debug,'-r','more debug for HTTP calls') { @option_rest_debug = true }
194
- @opt_mgr.add_opt_switch(:version,'-v','display version') { @plugin_env[:formater].display_message(:data,Aspera::Cli::VERSION);Process.exit(0) }
195
- @opt_mgr.add_opt_switch(:warnings,'-w','check for language warnings') { $VERBOSE = true }
193
+ @opt_mgr.add_opt_switch(:rest_debug, '-r', 'more debug for HTTP calls') { @option_rest_debug = true }
194
+ @opt_mgr.add_opt_switch(:version, '-v', 'display version') { @plugin_env[:formater].display_message(:data, Aspera::Cli::VERSION); Process.exit(0) } # rubocop:disable Style/Semicolon, Layout/LineLength
195
+ @opt_mgr.add_opt_switch(:warnings, '-w', 'check for language warnings') { $VERBOSE = true }
196
196
  # handler must be set before declaration
197
- @opt_mgr.set_obj_attr(:log_level,Log.instance,:level)
198
- @opt_mgr.set_obj_attr(:logger,Log.instance,:logger_type)
199
- @opt_mgr.set_obj_attr(:insecure,self,:option_insecure,:no)
200
- @opt_mgr.set_obj_attr(:ui,self,:option_ui)
201
- @opt_mgr.set_obj_attr(:http_options,self,:option_http_options)
202
- @opt_mgr.set_obj_attr(:log_secrets,SecretHider,:log_secrets)
203
- @opt_mgr.set_obj_attr(:cache_tokens,self,:option_cache_tokens)
204
- @opt_mgr.add_opt_list(:ui,OpenApplication.user_interfaces,'method to start browser')
205
- @opt_mgr.add_opt_list(:log_level,Log.levels,'Log level')
206
- @opt_mgr.add_opt_list(:logger,Log.logtypes,'log method')
207
- @opt_mgr.add_opt_simple(:lock_port,'prevent dual execution of a command, e.g. in cron')
208
- @opt_mgr.add_opt_simple(:query,'additional filter for API calls (extended value) (some commands)')
209
- @opt_mgr.add_opt_simple(:http_options,'options for http socket (extended value)')
210
- @opt_mgr.add_opt_boolean(:insecure,'do not validate HTTPS certificate')
211
- @opt_mgr.add_opt_boolean(:once_only,'process only new items (some commands)')
212
- @opt_mgr.add_opt_boolean(:log_secrets,'show passwords in logs')
213
- @opt_mgr.add_opt_boolean(:cache_tokens,'save and reuse Oauth tokens')
214
- @opt_mgr.set_option(:ui,OpenApplication.default_gui_mode)
215
- @opt_mgr.set_option(:once_only,false)
197
+ @opt_mgr.set_obj_attr(:log_level, Log.instance, :level)
198
+ @opt_mgr.set_obj_attr(:logger, Log.instance, :logger_type)
199
+ @opt_mgr.set_obj_attr(:insecure, self, :option_insecure, :no)
200
+ @opt_mgr.set_obj_attr(:ui, self, :option_ui)
201
+ @opt_mgr.set_obj_attr(:http_options, self, :option_http_options)
202
+ @opt_mgr.set_obj_attr(:log_secrets, SecretHider, :log_secrets)
203
+ @opt_mgr.set_obj_attr(:cache_tokens, self, :option_cache_tokens)
204
+ @opt_mgr.add_opt_list(:ui, OpenApplication.user_interfaces, 'method to start browser')
205
+ @opt_mgr.add_opt_list(:log_level, Log.levels, 'Log level')
206
+ @opt_mgr.add_opt_list(:logger, Log.logtypes, 'log method')
207
+ @opt_mgr.add_opt_simple(:lock_port, 'prevent dual execution of a command, e.g. in cron')
208
+ @opt_mgr.add_opt_simple(:http_options, 'options for http socket (extended value)')
209
+ @opt_mgr.add_opt_boolean(:insecure, 'do not validate HTTPS certificate')
210
+ @opt_mgr.add_opt_boolean(:once_only, 'process only new items (some commands)')
211
+ @opt_mgr.add_opt_boolean(:log_secrets, 'show passwords in logs')
212
+ @opt_mgr.add_opt_boolean(:cache_tokens, 'save and reuse Oauth tokens')
213
+ @opt_mgr.set_option(:ui, OpenApplication.default_gui_mode)
214
+ @opt_mgr.set_option(:once_only, false)
216
215
  # parse declared options
217
216
  @opt_mgr.parse_options!
218
217
  end
@@ -220,21 +219,21 @@ module Aspera
220
219
  # @return the plugin instance, based on name
221
220
  # also loads the plugin options, and default values from conf file
222
221
  # @param plugin_name_sym : symbol for plugin name
223
- def get_plugin_instance_with_options(plugin_name_sym,env=nil)
222
+ def get_plugin_instance_with_options(plugin_name_sym, env=nil)
224
223
  env ||= @plugin_env
225
- Log.log.debug("get_plugin_instance_with_options(#{plugin_name_sym})")
224
+ Log.log.debug{"get_plugin_instance_with_options(#{plugin_name_sym})"}
226
225
  require @plugin_env[:config].plugins[plugin_name_sym][:require_stanza]
227
226
  # load default params only if no param already loaded before plugin instanciation
228
227
  env[:config].add_plugin_default_preset(plugin_name_sym)
229
228
  command_plugin = Plugins::Config.plugin_class(plugin_name_sym).new(env)
230
- Log.log.debug("got #{command_plugin.class}")
229
+ Log.log.debug{"got #{command_plugin.class}"}
231
230
  # TODO: check that ancestor is Plugin?
232
231
  return command_plugin
233
232
  end
234
233
 
235
234
  def generate_bash_completion
236
- if @opt_mgr.get_next_argument('',expected: :multiple,mandatory: false).nil?
237
- @plugin_env[:config].plugins.keys.each{|p|puts p.to_s}
235
+ if @opt_mgr.get_next_argument('', expected: :multiple, mandatory: false).nil?
236
+ @plugin_env[:config].plugins.each_key{|p|puts p.to_s}
238
237
  else
239
238
  Log.log.warn('only first level completion so far')
240
239
  end
@@ -244,19 +243,19 @@ module Aspera
244
243
  def exit_with_usage(all_plugins)
245
244
  Log.log.debug('exit_with_usage'.bg_red)
246
245
  # display main plugin options
247
- @plugin_env[:formater].display_message(:error,@opt_mgr.parser)
246
+ @plugin_env[:formater].display_message(:error, @opt_mgr.parser)
248
247
  if all_plugins
249
248
  # list plugins that have a "require" field, i.e. all but main plugin
250
- @plugin_env[:config].plugins.keys.each do |plugin_name_sym|
249
+ @plugin_env[:config].plugins.each_key do |plugin_name_sym|
251
250
  next if plugin_name_sym.eql?(Plugins::Config::CONF_PLUGIN_SYM)
252
251
  # override main option parser with a brand new, to avoid having global options
253
252
  plugin_env = @plugin_env.clone
254
253
  plugin_env[:man_only] = true
255
254
  plugin_env[:options] = Manager.new(PROGRAM_NAME)
256
255
  plugin_env[:options].parser.banner = '' # remove default banner
257
- get_plugin_instance_with_options(plugin_name_sym,plugin_env)
256
+ get_plugin_instance_with_options(plugin_name_sym, plugin_env)
258
257
  # display generated help for plugin options
259
- @plugin_env[:formater].display_message(:error,plugin_env[:options].parser.help)
258
+ @plugin_env[:formater].display_message(:error, plugin_env[:options].parser.help)
260
259
  end
261
260
  end
262
261
  Process.exit(0)
@@ -316,7 +315,7 @@ module Aspera
316
315
  # help requested for current plugin
317
316
  exit_with_usage(false) if @option_help
318
317
  if @option_show_config
319
- @plugin_env[:formater].display_results({type: :single_object,data: @opt_mgr.declared_options(only_defined: true)})
318
+ @plugin_env[:formater].display_results({type: :single_object, data: @opt_mgr.declared_options(only_defined: true)})
320
319
  execute_command = false
321
320
  end
322
321
  # locking for single execution (only after "per plugin" option, in case lock port is there)
@@ -324,45 +323,45 @@ module Aspera
324
323
  if !lock_port.nil?
325
324
  begin
326
325
  # no need to close later, will be freed on process exit. must save in member else it is garbage collected
327
- Log.log.debug("Opening lock port #{lock_port.to_i}")
328
- @tcp_server = TCPServer.new('127.0.0.1',lock_port.to_i)
326
+ Log.log.debug{"Opening lock port #{lock_port.to_i}"}
327
+ @tcp_server = TCPServer.new('127.0.0.1', lock_port.to_i)
329
328
  rescue StandardError => e
330
329
  execute_command = false
331
- Log.log.warn("Another instance is already running (#{e.message}).")
330
+ Log.log.warn{"Another instance is already running (#{e.message})."}
332
331
  end
333
332
  end
334
333
  # execute and display (if not exclusive execution)
335
334
  @plugin_env[:formater].display_results(command_plugin.execute_action) if execute_command
336
335
  # finish
337
336
  @plugin_env[:transfer].shutdown
338
- rescue Net::SSH::AuthenticationFailed => e; exception_info = {e: e,t: 'SSH',security: true}
339
- rescue CliBadArgument => e; exception_info = {e: e,t: 'Argument',usage: true}
340
- rescue CliNoSuchId => e; exception_info = {e: e,t: 'Identifier'}
341
- rescue CliError => e; exception_info = {e: e,t: 'Tool',usage: true}
342
- rescue Fasp::Error => e; exception_info = {e: e,t: 'FASP(ascp)'}
343
- rescue Aspera::RestCallError => e; exception_info = {e: e,t: 'Rest'}
344
- rescue SocketError => e; exception_info = {e: e,t: 'Network'}
345
- rescue StandardError => e; exception_info = {e: e,t: 'Other',debug: true}
346
- rescue Interrupt => e; exception_info = {e: e,t: 'Interruption',debug: true}
337
+ rescue Net::SSH::AuthenticationFailed => e; exception_info = {e: e, t: 'SSH', security: true}
338
+ rescue CliBadArgument => e; exception_info = {e: e, t: 'Argument', usage: true}
339
+ rescue CliNoSuchId => e; exception_info = {e: e, t: 'Identifier'}
340
+ rescue CliError => e; exception_info = {e: e, t: 'Tool', usage: true}
341
+ rescue Fasp::Error => e; exception_info = {e: e, t: 'FASP(ascp)'}
342
+ rescue Aspera::RestCallError => e; exception_info = {e: e, t: 'Rest'}
343
+ rescue SocketError => e; exception_info = {e: e, t: 'Network'}
344
+ rescue StandardError => e; exception_info = {e: e, t: 'Other', debug: true}
345
+ rescue Interrupt => e; exception_info = {e: e, t: 'Interruption', debug: true}
347
346
  end
348
347
  # cleanup file list files
349
348
  TempFileManager.instance.cleanup
350
349
  # 1- processing of error condition
351
350
  unless exception_info.nil?
352
351
  Log.log.warn(exception_info[:e].message) if Aspera::Log.instance.logger_type.eql?(:syslog) && exception_info[:security]
353
- @plugin_env[:formater].display_message(:error,"#{ERROR_FLASH} #{exception_info[:t]}: #{exception_info[:e].message}")
354
- @plugin_env[:formater].display_message(:error,'Use option -h to get help.') if exception_info[:usage]
352
+ @plugin_env[:formater].display_message(:error, "#{ERROR_FLASH} #{exception_info[:t]}: #{exception_info[:e].message}")
353
+ @plugin_env[:formater].display_message(:error, 'Use option -h to get help.') if exception_info[:usage]
355
354
  if exception_info[:e].is_a?(Fasp::Error) && exception_info[:e].message.eql?('Remote host is not who we expected')
356
- @plugin_env[:formater].display_message(:error,"For this specific error, refer to:\n"\
355
+ @plugin_env[:formater].display_message(:error, "For this specific error, refer to:\n"\
357
356
  "#{SRC_URL}#error-remote-host-is-not-who-we-expected\nAdd this to arguments:\n--ts=@json:'{\"sshfp\":null}'")
358
357
  end
359
358
  end
360
359
  # 2- processing of command not processed (due to exception or bad command line)
361
360
  if execute_command || @option_show_config
362
361
  @opt_mgr.final_errors.each do |msg|
363
- @plugin_env[:formater].display_message(:error,"#{ERROR_FLASH} Argument: #{msg}")
362
+ @plugin_env[:formater].display_message(:error, "#{ERROR_FLASH} Argument: #{msg}")
364
363
  # add code as exception if there is not already an error
365
- exception_info = {e: Exception.new(msg),t: 'UnusedArg'} if exception_info.nil?
364
+ exception_info = {e: Exception.new(msg), t: 'UnusedArg'} if exception_info.nil?
366
365
  end
367
366
  end
368
367
  # 3- in case of error, fail the process status
@@ -370,7 +369,7 @@ module Aspera
370
369
  # show stack trace in debug mode
371
370
  raise exception_info[:e] if Log.instance.level.eql?(:debug)
372
371
  # else give hint and exit
373
- @plugin_env[:formater].display_message(:error,'Use --log-level=debug to get more details.') if exception_info[:debug]
372
+ @plugin_env[:formater].display_message(:error, 'Use --log-level=debug to get more details.') if exception_info[:debug]
374
373
  Process.exit(1)
375
374
  end
376
375
  return nil