aspera-cli 4.7.0 → 4.8.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 +1 -0
  3. data/README.md +844 -861
  4. data/bin/ascli +20 -1
  5. data/bin/asession +37 -34
  6. data/docs/test_env.conf +11 -3
  7. data/examples/aoc.rb +13 -12
  8. data/examples/dascli +26 -0
  9. data/examples/faspex4.rb +34 -29
  10. data/examples/transfer.rb +30 -29
  11. data/lib/aspera/aoc.rb +151 -143
  12. data/lib/aspera/ascmd.rb +56 -45
  13. data/lib/aspera/ats_api.rb +6 -5
  14. data/lib/aspera/cli/basic_auth_plugin.rb +18 -16
  15. data/lib/aspera/cli/extended_value.rb +32 -30
  16. data/lib/aspera/cli/formater.rb +103 -111
  17. data/lib/aspera/cli/info.rb +2 -1
  18. data/lib/aspera/cli/listener/line_dump.rb +1 -0
  19. data/lib/aspera/cli/listener/logger.rb +1 -0
  20. data/lib/aspera/cli/listener/progress.rb +13 -12
  21. data/lib/aspera/cli/listener/progress_multi.rb +21 -20
  22. data/lib/aspera/cli/main.rb +106 -89
  23. data/lib/aspera/cli/manager.rb +96 -85
  24. data/lib/aspera/cli/plugin.rb +50 -32
  25. data/lib/aspera/cli/plugins/alee.rb +6 -5
  26. data/lib/aspera/cli/plugins/aoc.rb +521 -426
  27. data/lib/aspera/cli/plugins/ats.rb +84 -83
  28. data/lib/aspera/cli/plugins/bss.rb +30 -27
  29. data/lib/aspera/cli/plugins/config.rb +483 -397
  30. data/lib/aspera/cli/plugins/console.rb +17 -15
  31. data/lib/aspera/cli/plugins/cos.rb +26 -35
  32. data/lib/aspera/cli/plugins/faspex.rb +201 -168
  33. data/lib/aspera/cli/plugins/faspex5.rb +109 -74
  34. data/lib/aspera/cli/plugins/node.rb +378 -189
  35. data/lib/aspera/cli/plugins/orchestrator.rb +71 -65
  36. data/lib/aspera/cli/plugins/preview.rb +131 -122
  37. data/lib/aspera/cli/plugins/server.rb +94 -93
  38. data/lib/aspera/cli/plugins/shares.rb +42 -28
  39. data/lib/aspera/cli/plugins/sync.rb +15 -14
  40. data/lib/aspera/cli/transfer_agent.rb +56 -52
  41. data/lib/aspera/cli/version.rb +2 -1
  42. data/lib/aspera/colors.rb +29 -28
  43. data/lib/aspera/command_line_builder.rb +50 -43
  44. data/lib/aspera/cos_node.rb +64 -38
  45. data/lib/aspera/data_repository.rb +1 -0
  46. data/lib/aspera/environment.rb +18 -8
  47. data/lib/aspera/fasp/agent_base.rb +26 -23
  48. data/lib/aspera/fasp/agent_connect.rb +35 -30
  49. data/lib/aspera/fasp/agent_direct.rb +68 -60
  50. data/lib/aspera/fasp/agent_httpgw.rb +71 -64
  51. data/lib/aspera/fasp/agent_node.rb +24 -23
  52. data/lib/aspera/fasp/agent_trsdk.rb +19 -20
  53. data/lib/aspera/fasp/error.rb +2 -1
  54. data/lib/aspera/fasp/error_info.rb +79 -68
  55. data/lib/aspera/fasp/installation.rb +122 -114
  56. data/lib/aspera/fasp/listener.rb +1 -0
  57. data/lib/aspera/fasp/parameters.rb +44 -41
  58. data/lib/aspera/fasp/resume_policy.rb +14 -11
  59. data/lib/aspera/fasp/transfer_spec.rb +6 -5
  60. data/lib/aspera/fasp/uri.rb +25 -24
  61. data/lib/aspera/faspex_gw.rb +83 -72
  62. data/lib/aspera/hash_ext.rb +10 -12
  63. data/lib/aspera/id_generator.rb +8 -7
  64. data/lib/aspera/keychain/encrypted_hash.rb +60 -45
  65. data/lib/aspera/keychain/macos_security.rb +26 -24
  66. data/lib/aspera/log.rb +34 -38
  67. data/lib/aspera/nagios.rb +14 -13
  68. data/lib/aspera/node.rb +19 -19
  69. data/lib/aspera/oauth.rb +121 -101
  70. data/lib/aspera/open_application.rb +6 -5
  71. data/lib/aspera/persistency_action_once.rb +9 -8
  72. data/lib/aspera/persistency_folder.rb +10 -9
  73. data/lib/aspera/preview/file_types.rb +261 -266
  74. data/lib/aspera/preview/generator.rb +74 -73
  75. data/lib/aspera/preview/image_error.png +0 -0
  76. data/lib/aspera/preview/options.rb +7 -6
  77. data/lib/aspera/preview/utils.rb +30 -33
  78. data/lib/aspera/preview/video_error.png +0 -0
  79. data/lib/aspera/proxy_auto_config.rb +25 -23
  80. data/lib/aspera/rest.rb +73 -74
  81. data/lib/aspera/rest_call_error.rb +1 -0
  82. data/lib/aspera/rest_error_analyzer.rb +11 -9
  83. data/lib/aspera/rest_errors_aspera.rb +5 -4
  84. data/lib/aspera/secret_hider.rb +68 -0
  85. data/lib/aspera/ssh.rb +12 -10
  86. data/lib/aspera/sync.rb +49 -47
  87. data/lib/aspera/temp_file_manager.rb +7 -5
  88. data/lib/aspera/timer_limiter.rb +9 -8
  89. data/lib/aspera/uri_reader.rb +11 -14
  90. data/lib/aspera/web_auth.rb +17 -15
  91. data.tar.gz.sig +0 -0
  92. metadata +117 -34
  93. metadata.gz.sig +2 -0
  94. data/bin/dascli +0 -13
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'aspera/cli/manager'
3
4
  require 'aspera/cli/formater'
4
5
  require 'aspera/cli/plugins/config'
@@ -14,18 +15,23 @@ require 'aspera/log'
14
15
  require 'aspera/rest'
15
16
  require 'aspera/nagios'
16
17
  require 'aspera/colors'
18
+ require 'aspera/secret_hider'
17
19
 
18
20
  module Aspera
19
21
  module Cli
20
22
  # The main CLI class
21
23
  class Main
22
- # prefix to display error messages
23
- ERROR_FLASH='ERROR:'.bg_red.gray.blink.freeze
24
- private_constant :ERROR_FLASH
24
+ # prefix to display error messages in user messages (terminal)
25
+ ERROR_FLASH = 'ERROR:'.bg_red.gray.blink.freeze
26
+ WARNING_FLASH = 'WARNING:'.bg_red.gray.blink.freeze
27
+ private_constant :ERROR_FLASH,:WARNING_FLASH
25
28
 
26
29
  # store transfer result using this key and use result_transfer_multiple
27
30
  STATUS_FIELD = 'status'
28
31
 
32
+ # for testing only
33
+ SELF_SIGNED_CERT = OpenSSL::SSL.const_get(:enon_yfirev.to_s.upcase.reverse)
34
+
29
35
  class << self
30
36
  # expect some list, but nothing to display
31
37
  def result_empty; return {type: :empty, data: :nil}; end
@@ -41,7 +47,7 @@ module Aspera
41
47
  # raise exception if there is one error
42
48
  # else returns an empty status
43
49
  def result_transfer(statuses)
44
- worst=TransferAgent.session_status(statuses)
50
+ worst = TransferAgent.session_status(statuses)
45
51
  raise worst unless worst.eql?(:success)
46
52
  return Main.result_nothing
47
53
  end
@@ -51,12 +57,12 @@ module Aspera
51
57
  # @return a status object suitable as command result
52
58
  # each element has a key STATUS_FIELD which contains the result of possibly multiple sessions
53
59
  def result_transfer_multiple(status_table)
54
- global_status=:success
60
+ global_status = :success
55
61
  # transform status array into string and find if there was problem
56
62
  status_table.each do |item|
57
- worst=TransferAgent.session_status(item[STATUS_FIELD])
58
- global_status=worst unless worst.eql?(:success)
59
- item[STATUS_FIELD]=item[STATUS_FIELD].map(&:to_s).join(',')
63
+ worst = TransferAgent.session_status(item[STATUS_FIELD])
64
+ global_status = worst unless worst.eql?(:success)
65
+ item[STATUS_FIELD] = item[STATUS_FIELD].map(&:to_s).join(',')
60
66
  end
61
67
  raise global_status unless global_status.eql?(:success)
62
68
  return {type: :object_list,data: status_table}
@@ -72,17 +78,24 @@ module Aspera
72
78
 
73
79
  def option_ui; OpenApplication.instance.url_method; end
74
80
 
75
- def option_ui=(value); OpenApplication.instance.url_method=value; end
81
+ def option_ui=(value); OpenApplication.instance.url_method = value; end
76
82
 
77
83
  # called everytime a new REST HTTP session is opened
78
84
  # @param http [Net::HTTP] the newly created http session object
79
85
  def http_parameters=(http)
80
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @option_insecure
86
+ if @option_insecure
87
+ url=http.inspect.gsub(/^[^ ]* /,'https://').gsub(/ [^ ]*$/,'')
88
+ if !@ssl_warned_urls.include?(url)
89
+ @plugin_env[:formater].display_message(:error,"#{WARNING_FLASH} ignoring certificate for: #{url}. Only for tests, do not use in production.")
90
+ @ssl_warned_urls.push(url)
91
+ end
92
+ http.verify_mode = SELF_SIGNED_CERT
93
+ end
81
94
  http.set_debug_output($stdout) if @option_rest_debug
82
95
  raise 'http_options expects Hash' unless @option_http_options.is_a?(Hash)
83
96
 
84
97
  @option_http_options.each do |k,v|
85
- method="#{k}=".to_sym
98
+ method = "#{k}=".to_sym
86
99
  # check if accessor is a method of Net::HTTP
87
100
  # continue_timeout= read_timeout= write_timeout=
88
101
  if http.respond_to?(method)
@@ -98,91 +111,94 @@ module Aspera
98
111
  # first thing : manage debug level (allows debugging of option parser)
99
112
  early_debug_setup(argv)
100
113
  # compare $0 with expected name
101
- current_prog_name=File.basename($PROGRAM_NAME)
102
- @plugin_env[:formater].display_message(:error,"#{'WARNING'.bg_red.blink.gray} Please use '#{PROGRAM_NAME}' instead of '#{current_prog_name}'") unless current_prog_name.eql?(PROGRAM_NAME)
103
- @option_help=false
104
- @bash_completion=false
105
- @option_show_config=false
106
- @option_insecure=false
107
- @option_rest_debug=false
108
- @option_cache_tokens=true
109
- @option_http_options={}
114
+ current_prog_name = File.basename($PROGRAM_NAME)
115
+ @plugin_env[:formater].display_message(:error,"#{'WARNING'.bg_red.blink.gray} Please use '#{PROGRAM_NAME}' instead of '#{current_prog_name}'") \
116
+ unless current_prog_name.eql?(PROGRAM_NAME)
117
+ @option_help = false
118
+ @bash_completion = false
119
+ @option_show_config = false
120
+ @option_insecure = false
121
+ @option_rest_debug = false
122
+ @option_cache_tokens = true
123
+ @option_http_options = {}
124
+ @ssl_warned_urls=[]
110
125
  # environment provided to plugin for various capabilities
111
- @plugin_env={}
126
+ @plugin_env = {}
112
127
  # give command line arguments to option manager
113
- @plugin_env[:options]=@opt_mgr=Manager.new(PROGRAM_NAME,argv)
128
+ @plugin_env[:options] = @opt_mgr = Manager.new(PROGRAM_NAME,argv: argv)
114
129
  # formatter adds options
115
- @plugin_env[:formater]=Formater.new(@plugin_env[:options])
116
- Rest.user_agent=PROGRAM_NAME
117
- Rest.session_cb=lambda{|http|self.http_parameters=http}
130
+ @plugin_env[:formater] = Formater.new(@plugin_env[:options])
131
+ Rest.user_agent = PROGRAM_NAME
132
+ Rest.session_cb = lambda{|http|self.http_parameters = http}
118
133
  # declare and parse global options
119
- init_global_options()
134
+ init_global_options
120
135
  # the Config plugin adds the @preset parser, so declare before TransferAgent which may use it
121
- @plugin_env[:config]=Plugins::Config.new(@plugin_env, gem: GEM_NAME, name: PROGRAM_NAME, help: DOC_URL, version: Aspera::Cli::VERSION)
136
+ @plugin_env[:config] = Plugins::Config.new(@plugin_env, gem: GEM_NAME, name: PROGRAM_NAME, help: DOC_URL, version: Aspera::Cli::VERSION)
122
137
  # the TransferAgent plugin may use the @preset parser
123
- @plugin_env[:transfer]=TransferAgent.new(@plugin_env[:options],@plugin_env[:config])
138
+ @plugin_env[:transfer] = TransferAgent.new(@plugin_env[:options],@plugin_env[:config])
124
139
  # data persistency
125
- @plugin_env[:persistency]=PersistencyFolder.new(File.join(@plugin_env[:config].main_folder,'persist_store'))
140
+ @plugin_env[:persistency] = PersistencyFolder.new(File.join(@plugin_env[:config].main_folder,'persist_store'))
126
141
  Log.log.debug('plugin env created'.red)
127
- Oauth.persist_mgr=@plugin_env[:persistency] if @option_cache_tokens
128
- Fasp::Parameters.file_list_folder=File.join(@plugin_env[:config].main_folder,'filelists')
129
- Aspera::RestErrorAnalyzer.instance.log_file=File.join(@plugin_env[:config].main_folder,'rest_exceptions.log')
142
+ Oauth.persist_mgr = @plugin_env[:persistency] if @option_cache_tokens
143
+ Fasp::Parameters.file_list_folder = File.join(@plugin_env[:config].main_folder,'filelists')
144
+ Aspera::RestErrorAnalyzer.instance.log_file = File.join(@plugin_env[:config].main_folder,'rest_exceptions.log')
130
145
  # register aspera REST call error handlers
131
146
  Aspera::RestErrorsAspera.register_handlers
132
147
  # set banner when all environment is created so that additional extended value modifiers are known, e.g. @preset
133
- @opt_mgr.parser.banner=app_banner
148
+ @opt_mgr.parser.banner = app_banner
134
149
  end
135
150
 
136
151
  def app_banner
152
+ t=' '*8
137
153
  return <<~END_OF_BANNER
138
154
  NAME
139
- \t#{PROGRAM_NAME} -- a command line tool for Aspera Applications (v#{Aspera::Cli::VERSION})
155
+ #{t}#{PROGRAM_NAME} -- a command line tool for Aspera Applications (v#{Aspera::Cli::VERSION})
140
156
 
141
157
  SYNOPSIS
142
- \t#{PROGRAM_NAME} COMMANDS [OPTIONS] [ARGS]
158
+ #{t}#{PROGRAM_NAME} COMMANDS [OPTIONS] [ARGS]
143
159
 
144
160
  DESCRIPTION
145
- \tUse Aspera application to perform operations on command line.
146
- \tDocumentation and examples: #{GEM_URL}
147
- \texecute: #{PROGRAM_NAME} conf doc
148
- \tor visit: #{DOC_URL}
149
- \tsource repo: #{SRC_URL}
161
+ #{t}Use Aspera application to perform operations on command line.
162
+ #{t}Documentation and examples: #{GEM_URL}
163
+ #{t}execute: #{PROGRAM_NAME} conf doc
164
+ #{t}or visit: #{DOC_URL}
165
+ #{t}source repo: #{SRC_URL}
150
166
 
151
167
  ENVIRONMENT VARIABLES
152
- \t#{@plugin_env[:config].conf_dir_env_var} config folder, default: $HOME/#{Plugins::Config::ASPERA_HOME_FOLDER_NAME}/#{PROGRAM_NAME}
153
- \tAny option can be set as an environment variable, refer to the manual
168
+ #{t}#{@plugin_env[:config].conf_dir_env_var} config folder, default: $HOME/#{Plugins::Config::ASPERA_HOME_FOLDER_NAME}/#{PROGRAM_NAME}
169
+ #{t}Any option can be set as an environment variable, refer to the manual
154
170
 
155
171
  COMMANDS
156
- \tTo list first level commands, execute: #{PROGRAM_NAME}
157
- \tNote that commands can be written shortened (provided it is unique).
172
+ #{t}To list first level commands, execute: #{PROGRAM_NAME}
173
+ #{t}Note that commands can be written shortened (provided it is unique).
158
174
 
159
175
  OPTIONS
160
- \tOptions begin with a '-' (minus), and value is provided on command line.
161
- \tSpecial values are supported beginning with special prefix @pfx:, where pfx is one of:
162
- \t#{ExtendedValue.instance.modifiers.map(&:to_s).join(', ')}
163
- \tDates format is 'DD-MM-YY HH:MM:SS', or 'now' or '-<num>h'
176
+ #{t}Options begin with a '-' (minus), and value is provided on command line.
177
+ #{t}Special values are supported beginning with special prefix @pfx:, where pfx is one of:
178
+ #{t}#{ExtendedValue.instance.modifiers.map(&:to_s).join(', ')}
179
+ #{t}Dates format is 'DD-MM-YY HH:MM:SS', or 'now' or '-<num>h'
164
180
 
165
181
  ARGS
166
- \tSome commands require mandatory arguments, e.g. a path.
182
+ #{t}Some commands require mandatory arguments, e.g. a path.
167
183
  END_OF_BANNER
168
184
  end
169
185
 
170
186
  # define header for manual
171
187
  def init_global_options
172
188
  Log.log.debug('init_global_options')
173
- @opt_mgr.add_opt_switch(:help,'-h','Show this message.') { @option_help=true }
174
- @opt_mgr.add_opt_switch(:bash_comp,'generate bash completion for command') { @bash_completion=true }
175
- @opt_mgr.add_opt_switch(:show_config, 'Display parameters used for the provided action.') { @option_show_config=true }
176
- @opt_mgr.add_opt_switch(:rest_debug,'-r','more debug for HTTP calls') { @option_rest_debug=true }
189
+ @opt_mgr.add_opt_switch(:help,'-h','Show this message.') { @option_help = true }
190
+ @opt_mgr.add_opt_switch(:bash_comp,'generate bash completion for command') { @bash_completion = true }
191
+ @opt_mgr.add_opt_switch(:show_config, 'Display parameters used for the provided action.') { @option_show_config = true }
192
+ @opt_mgr.add_opt_switch(:rest_debug,'-r','more debug for HTTP calls') { @option_rest_debug = true }
177
193
  @opt_mgr.add_opt_switch(:version,'-v','display version') { @plugin_env[:formater].display_message(:data,Aspera::Cli::VERSION);Process.exit(0) }
178
- @opt_mgr.add_opt_switch(:warnings,'-w','check for language warnings') { $VERBOSE=true }
194
+ @opt_mgr.add_opt_switch(:warnings,'-w','check for language warnings') { $VERBOSE = true }
179
195
  # handler must be set before declaration
180
196
  @opt_mgr.set_obj_attr(:log_level,Log.instance,:level)
181
197
  @opt_mgr.set_obj_attr(:logger,Log.instance,:logger_type)
182
198
  @opt_mgr.set_obj_attr(:insecure,self,:option_insecure,:no)
183
199
  @opt_mgr.set_obj_attr(:ui,self,:option_ui)
184
200
  @opt_mgr.set_obj_attr(:http_options,self,:option_http_options)
185
- @opt_mgr.set_obj_attr(:log_secrets,Log.instance,:log_secrets)
201
+ @opt_mgr.set_obj_attr(:log_secrets,SecretHider,:log_secrets)
186
202
  @opt_mgr.set_obj_attr(:cache_tokens,self,:option_cache_tokens)
187
203
  @opt_mgr.add_opt_list(:ui,OpenApplication.user_interfaces,'method to start browser')
188
204
  @opt_mgr.add_opt_list(:log_level,Log.levels,'Log level')
@@ -204,19 +220,19 @@ module Aspera
204
220
  # also loads the plugin options, and default values from conf file
205
221
  # @param plugin_name_sym : symbol for plugin name
206
222
  def get_plugin_instance_with_options(plugin_name_sym,env=nil)
207
- env||=@plugin_env
223
+ env ||= @plugin_env
208
224
  Log.log.debug("get_plugin_instance_with_options(#{plugin_name_sym})")
209
225
  require @plugin_env[:config].plugins[plugin_name_sym][:require_stanza]
210
226
  # load default params only if no param already loaded before plugin instanciation
211
227
  env[:config].add_plugin_default_preset(plugin_name_sym)
212
- command_plugin=Plugins::Config.plugin_class(plugin_name_sym).new(env)
228
+ command_plugin = Plugins::Config.plugin_class(plugin_name_sym).new(env)
213
229
  Log.log.debug("got #{command_plugin.class}")
214
230
  # TODO: check that ancestor is Plugin?
215
231
  return command_plugin
216
232
  end
217
233
 
218
234
  def generate_bash_completion
219
- if @opt_mgr.get_next_argument('',:multiple,:optional).nil?
235
+ if @opt_mgr.get_next_argument('',expected: :multiple,mandatory: false).nil?
220
236
  @plugin_env[:config].plugins.keys.each{|p|puts p.to_s}
221
237
  else
222
238
  Log.log.warn('only first level completion so far')
@@ -233,10 +249,10 @@ module Aspera
233
249
  @plugin_env[:config].plugins.keys.each do |plugin_name_sym|
234
250
  next if plugin_name_sym.eql?(Plugins::Config::CONF_PLUGIN_SYM)
235
251
  # override main option parser with a brand new, to avoid having global options
236
- plugin_env=@plugin_env.clone
237
- plugin_env[:man_only]=true
238
- plugin_env[:options]=Manager.new(PROGRAM_NAME)
239
- plugin_env[:options].parser.banner='' # remove default banner
252
+ plugin_env = @plugin_env.clone
253
+ plugin_env[:man_only] = true
254
+ plugin_env[:options] = Manager.new(PROGRAM_NAME)
255
+ plugin_env[:options].parser.banner = '' # remove default banner
240
256
  get_plugin_instance_with_options(plugin_name_sym,plugin_env)
241
257
  # display generated help for plugin options
242
258
  @plugin_env[:formater].display_message(:error,plugin_env[:options].parser.help)
@@ -250,12 +266,12 @@ module Aspera
250
266
  # early debug for parser
251
267
  # Note: does not accept shortcuts
252
268
  def early_debug_setup(argv)
253
- Log.instance.program_name=PROGRAM_NAME
269
+ Log.instance.program_name = PROGRAM_NAME
254
270
  argv.each do |arg|
255
271
  case arg
256
272
  when '--' then break
257
273
  when /^--log-level=(.*)/ then Log.instance.level = Regexp.last_match(1).to_sym
258
- when /^--logger=(.*)/ then Log.instance.logger_type=Regexp.last_match(1).to_sym
274
+ when /^--logger=(.*)/ then Log.instance.logger_type = Regexp.last_match(1).to_sym
259
275
  end
260
276
  end
261
277
  end
@@ -266,9 +282,9 @@ module Aspera
266
282
  def process_command_line
267
283
  Log.log.debug('process_command_line')
268
284
  # catch exception information , if any
269
- exception_info=nil
285
+ exception_info = nil
270
286
  # false if command shall not be executed ("once_only")
271
- execute_command=true
287
+ execute_command = true
272
288
  begin
273
289
  # find plugins, shall be after parse! ?
274
290
  @plugin_env[:config].add_plugins_from_lookup_folders
@@ -276,23 +292,23 @@ module Aspera
276
292
  exit_with_usage(true) if @option_help && @opt_mgr.command_or_arg_empty?
277
293
  generate_bash_completion if @bash_completion
278
294
  @plugin_env[:config].periodic_check_newer_gem_version
279
- command_sym=
280
- if @option_show_config && @opt_mgr.command_or_arg_empty?
281
- Plugins::Config::CONF_PLUGIN_SYM
282
- else
283
- @opt_mgr.get_next_command(@plugin_env[:config].plugins.keys.dup.unshift(:help))
284
- end
295
+ command_sym =
296
+ if @option_show_config && @opt_mgr.command_or_arg_empty?
297
+ Plugins::Config::CONF_PLUGIN_SYM
298
+ else
299
+ @opt_mgr.get_next_command(@plugin_env[:config].plugins.keys.dup.unshift(:help))
300
+ end
285
301
  # command will not be executed, but we need manual
286
- @opt_mgr.fail_on_missing_mandatory=false if @option_help || @option_show_config
302
+ @opt_mgr.fail_on_missing_mandatory = false if @option_help || @option_show_config
287
303
  # main plugin is not dynamically instanciated
288
304
  case command_sym
289
305
  when :help
290
306
  exit_with_usage(true)
291
307
  when Plugins::Config::CONF_PLUGIN_SYM
292
- command_plugin=@plugin_env[:config]
308
+ command_plugin = @plugin_env[:config]
293
309
  else
294
310
  # get plugin, set options, etc
295
- command_plugin=get_plugin_instance_with_options(command_sym)
311
+ command_plugin = get_plugin_instance_with_options(command_sym)
296
312
  # parse plugin specific options
297
313
  @opt_mgr.parse_options!
298
314
  end
@@ -300,17 +316,17 @@ module Aspera
300
316
  exit_with_usage(false) if @option_help
301
317
  if @option_show_config
302
318
  @plugin_env[:formater].display_results({type: :single_object,data: @opt_mgr.declared_options(only_defined: true)})
303
- execute_command=false
319
+ execute_command = false
304
320
  end
305
321
  # locking for single execution (only after "per plugin" option, in case lock port is there)
306
- lock_port=@opt_mgr.get_option(:lock_port,:optional)
322
+ lock_port = @opt_mgr.get_option(:lock_port)
307
323
  if !lock_port.nil?
308
324
  begin
309
325
  # no need to close later, will be freed on process exit. must save in member else it is garbage collected
310
326
  Log.log.debug("Opening lock port #{lock_port.to_i}")
311
- @tcp_server=TCPServer.new('127.0.0.1',lock_port.to_i)
327
+ @tcp_server = TCPServer.new('127.0.0.1',lock_port.to_i)
312
328
  rescue StandardError => e
313
- execute_command=false
329
+ execute_command = false
314
330
  Log.log.warn("Another instance is already running (#{e.message}).")
315
331
  end
316
332
  end
@@ -318,14 +334,14 @@ module Aspera
318
334
  @plugin_env[:formater].display_results(command_plugin.execute_action) if execute_command
319
335
  # finish
320
336
  @plugin_env[:transfer].shutdown
321
- rescue CliBadArgument => e; exception_info={e: e,t: 'Argument',usage: true}
322
- rescue CliNoSuchId => e; exception_info={e: e,t: 'Identifier'}
323
- rescue CliError => e; exception_info={e: e,t: 'Tool',usage: true}
324
- rescue Fasp::Error => e; exception_info={e: e,t: 'FASP(ascp)'}
325
- rescue Aspera::RestCallError => e; exception_info={e: e,t: 'Rest'}
326
- rescue SocketError => e; exception_info={e: e,t: 'Network'}
327
- rescue StandardError => e; exception_info={e: e,t: 'Other',debug: true}
328
- rescue Interrupt => e; exception_info={e: e,t: 'Interruption',debug: true}
337
+ rescue CliBadArgument => e; exception_info = {e: e,t: 'Argument',usage: true}
338
+ rescue CliNoSuchId => e; exception_info = {e: e,t: 'Identifier'}
339
+ rescue CliError => e; exception_info = {e: e,t: 'Tool',usage: true}
340
+ rescue Fasp::Error => e; exception_info = {e: e,t: 'FASP(ascp)'}
341
+ rescue Aspera::RestCallError => e; exception_info = {e: e,t: 'Rest'}
342
+ rescue SocketError => e; exception_info = {e: e,t: 'Network'}
343
+ rescue StandardError => e; exception_info = {e: e,t: 'Other',debug: true}
344
+ rescue Interrupt => e; exception_info = {e: e,t: 'Interruption',debug: true}
329
345
  end
330
346
  # cleanup file list files
331
347
  TempFileManager.instance.cleanup
@@ -334,7 +350,8 @@ module Aspera
334
350
  @plugin_env[:formater].display_message(:error,"#{ERROR_FLASH} #{exception_info[:t]}: #{exception_info[:e].message}")
335
351
  @plugin_env[:formater].display_message(:error,'Use option -h to get help.') if exception_info[:usage]
336
352
  if exception_info[:e].is_a?(Fasp::Error) && exception_info[:e].message.eql?('Remote host is not who we expected')
337
- @plugin_env[:formater].display_message(:error,"For this specific error, refer to:\n#{SRC_URL}#error-remote-host-is-not-who-we-expected\nAdd this to arguments:\n--ts=@json:'{\"sshfp\":null}'")
353
+ @plugin_env[:formater].display_message(:error,"For this specific error, refer to:\n"\
354
+ "#{SRC_URL}#error-remote-host-is-not-who-we-expected\nAdd this to arguments:\n--ts=@json:'{\"sshfp\":null}'")
338
355
  end
339
356
  end
340
357
  # 2- processing of command not processed (due to exception or bad command line)
@@ -342,7 +359,7 @@ module Aspera
342
359
  @opt_mgr.final_errors.each do |msg|
343
360
  @plugin_env[:formater].display_message(:error,"#{ERROR_FLASH} Argument: #{msg}")
344
361
  # add code as exception if there is not already an error
345
- exception_info={e: Exception.new(msg),t: 'UnusedArg'} if exception_info.nil?
362
+ exception_info = {e: Exception.new(msg),t: 'UnusedArg'} if exception_info.nil?
346
363
  end
347
364
  end
348
365
  # 3- in case of error, fail the process status