aspera-cli 4.0.0.pre2 → 4.2.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.
- checksums.yaml +4 -4
- data/README.md +761 -210
- data/bin/ascli +2 -0
- data/bin/dascli +13 -0
- data/docs/Makefile +2 -1
- data/docs/README.erb.md +628 -160
- data/docs/test_env.conf +22 -10
- data/docs/transfer_spec.html +1 -1
- data/lib/aspera/aoc.rb +87 -108
- data/lib/aspera/cli/formater.rb +2 -0
- data/lib/aspera/cli/main.rb +48 -45
- data/lib/aspera/cli/manager.rb +19 -6
- data/lib/aspera/cli/plugin.rb +9 -4
- data/lib/aspera/cli/plugins/alee.rb +1 -1
- data/lib/aspera/cli/plugins/aoc.rb +208 -183
- data/lib/aspera/cli/plugins/ats.rb +2 -2
- data/lib/aspera/cli/plugins/config.rb +205 -125
- data/lib/aspera/cli/plugins/console.rb +2 -2
- data/lib/aspera/cli/plugins/faspex.rb +15 -8
- data/lib/aspera/cli/plugins/faspex5.rb +76 -37
- data/lib/aspera/cli/plugins/node.rb +3 -3
- data/lib/aspera/cli/plugins/preview.rb +35 -25
- data/lib/aspera/cli/plugins/server.rb +23 -8
- data/lib/aspera/cli/transfer_agent.rb +7 -6
- data/lib/aspera/cli/version.rb +1 -1
- data/lib/aspera/colors.rb +5 -1
- data/lib/aspera/cos_node.rb +33 -28
- data/lib/aspera/environment.rb +15 -4
- data/lib/aspera/fasp/connect.rb +28 -21
- data/lib/aspera/fasp/http_gw.rb +140 -28
- data/lib/aspera/fasp/installation.rb +119 -57
- data/lib/aspera/fasp/local.rb +174 -178
- data/lib/aspera/fasp/manager.rb +12 -0
- data/lib/aspera/fasp/node.rb +4 -4
- data/lib/aspera/fasp/parameters.rb +6 -18
- data/lib/aspera/fasp/resume_policy.rb +13 -12
- data/lib/aspera/log.rb +10 -2
- data/lib/aspera/node.rb +61 -1
- data/lib/aspera/oauth.rb +36 -13
- data/lib/aspera/persistency_folder.rb +9 -4
- data/lib/aspera/preview/file_types.rb +53 -21
- data/lib/aspera/preview/generator.rb +3 -3
- data/lib/aspera/rest.rb +29 -18
- data/lib/aspera/secrets.rb +20 -0
- data/lib/aspera/temp_file_manager.rb +19 -0
- metadata +40 -22
|
@@ -15,7 +15,7 @@ module Aspera
|
|
|
15
15
|
|
|
16
16
|
# @param src source file path
|
|
17
17
|
# @param dst destination file path
|
|
18
|
-
# @param api_mime_type optional mime type as provided by node api
|
|
18
|
+
# @param api_mime_type optional mime type as provided by node api (or nil)
|
|
19
19
|
# node API mime types are from: http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
|
20
20
|
# supported preview type is one of Preview::PREVIEW_FORMATS
|
|
21
21
|
# the resulting preview file type is taken from destination file extension.
|
|
@@ -25,14 +25,14 @@ module Aspera
|
|
|
25
25
|
# -> preview_format is one of Generator::PREVIEW_FORMATS
|
|
26
26
|
# the conversion video->mp4 is implemented in methods: convert_video_to_mp4_using_<video_conversion>
|
|
27
27
|
# -> conversion method is one of Generator::VIDEO_CONVERSION_METHODS
|
|
28
|
-
def initialize(options,src,dst,main_temp_dir,api_mime_type
|
|
28
|
+
def initialize(options,src,dst,main_temp_dir,api_mime_type)
|
|
29
29
|
@options=options
|
|
30
30
|
@source_file_path=src
|
|
31
31
|
@destination_file_path=dst
|
|
32
32
|
@temp_folder=File.join(main_temp_dir,@source_file_path.split('/').last.gsub(/\s/, '_').gsub(/\W/, ''))
|
|
33
33
|
# extract preview format from extension of target file
|
|
34
34
|
@preview_format_symb=File.extname(@destination_file_path).gsub(/^\./,'').to_sym
|
|
35
|
-
@conversion_type=FileTypes.conversion_type(@source_file_path,api_mime_type
|
|
35
|
+
@conversion_type=FileTypes.instance.conversion_type(@source_file_path,api_mime_type)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
38
|
# name of processing method in this object
|
data/lib/aspera/rest.rb
CHANGED
|
@@ -7,6 +7,7 @@ require 'net/http'
|
|
|
7
7
|
require 'net/https'
|
|
8
8
|
require 'json'
|
|
9
9
|
require 'base64'
|
|
10
|
+
require 'cgi'
|
|
10
11
|
require 'ruby-progressbar'
|
|
11
12
|
|
|
12
13
|
# add cancel method to http
|
|
@@ -33,6 +34,7 @@ module Aspera
|
|
|
33
34
|
# true if https ignore certificate
|
|
34
35
|
@@insecure=false
|
|
35
36
|
@@user_agent='Ruby'
|
|
37
|
+
@@download_partial_suffix='.http_partial'
|
|
36
38
|
|
|
37
39
|
public
|
|
38
40
|
def self.insecure=(v); @@insecure=v;Log.log.debug("insecure => #{@@insecure}".red);end
|
|
@@ -98,9 +100,10 @@ module Aspera
|
|
|
98
100
|
public
|
|
99
101
|
|
|
100
102
|
attr_reader :params
|
|
103
|
+
attr_reader :oauth
|
|
101
104
|
|
|
102
|
-
# @param a_rest_params default call parameters and authentication (:auth) :
|
|
103
|
-
# :type (:basic, :oauth2, :url)
|
|
105
|
+
# @param a_rest_params default call parameters (merged at call) and (+) authentication (:auth) :
|
|
106
|
+
# :type (:basic, :oauth2, :url, :none)
|
|
104
107
|
# :username [:basic]
|
|
105
108
|
# :password [:basic]
|
|
106
109
|
# :url_creds [:url]
|
|
@@ -117,16 +120,6 @@ module Aspera
|
|
|
117
120
|
# default is no auth
|
|
118
121
|
@params[:auth]||={:type=>:none}
|
|
119
122
|
@params[:not_auth_codes]||=['401']
|
|
120
|
-
# translate old auth parameters, remove prefix, place in auth
|
|
121
|
-
[:auth,:basic,:oauth].each do |p_sym|
|
|
122
|
-
p_str=p_sym.to_s+'_'
|
|
123
|
-
@params.keys.select{|k|k.to_s.start_with?(p_str)}.each do |k_sym|
|
|
124
|
-
name=k_sym.to_s[p_str.length..-1]
|
|
125
|
-
name='grant' if k_sym.eql?(:oauth_type)
|
|
126
|
-
@params[:auth][name.to_sym]=@params[k_sym]
|
|
127
|
-
@params.delete(k_sym)
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
123
|
@oauth=Oauth.new(@params[:auth]) if @params[:auth][:type].eql?(:oauth2)
|
|
131
124
|
Log.dump('REST params(2)',@params)
|
|
132
125
|
end
|
|
@@ -153,6 +146,7 @@ module Aspera
|
|
|
153
146
|
Log.log.debug("accessing #{call_data[:subpath]}".red.bold.bg_green)
|
|
154
147
|
call_data[:headers]||={}
|
|
155
148
|
call_data[:headers]['User-Agent'] ||= @@user_agent
|
|
149
|
+
# defaults from @params are overriden by call dataz
|
|
156
150
|
call_data=@params.deep_merge(call_data)
|
|
157
151
|
case call_data[:auth][:type]
|
|
158
152
|
when :none
|
|
@@ -206,10 +200,13 @@ module Aspera
|
|
|
206
200
|
|
|
207
201
|
Log.log.debug("call_data = #{call_data}")
|
|
208
202
|
result={:http=>nil}
|
|
203
|
+
# start a block to be able to retry the actual HTTP request
|
|
209
204
|
begin
|
|
210
205
|
# we try the call, and will retry only if oauth, as we can, first with refresh, and then re-auth if refresh is bad
|
|
211
206
|
oauth_tries ||= 2
|
|
207
|
+
tries_remain_redirect||=4
|
|
212
208
|
Log.log.debug("send request")
|
|
209
|
+
# make http request (pipelined)
|
|
213
210
|
http_session.request(req) do |response|
|
|
214
211
|
result[:http] = response
|
|
215
212
|
if call_data.has_key?(:save_to_file)
|
|
@@ -223,12 +220,12 @@ module Aspera
|
|
|
223
220
|
target_file=call_data[:save_to_file]
|
|
224
221
|
# override user's path to path in header
|
|
225
222
|
if !response['Content-Disposition'].nil? and m=response['Content-Disposition'].match(/filename="([^"]+)"/)
|
|
226
|
-
target_file=m[1]
|
|
223
|
+
target_file=File.join(File.dirname(target_file),m[1])
|
|
227
224
|
end
|
|
228
225
|
# download with temp filename
|
|
229
|
-
target_file_tmp=target_file
|
|
226
|
+
target_file_tmp="#{target_file}#{@@download_partial_suffix}"
|
|
230
227
|
Log.log.debug("saving to: #{target_file}")
|
|
231
|
-
File.open(target_file_tmp,
|
|
228
|
+
File.open(target_file_tmp, 'wb') do |file|
|
|
232
229
|
result[:http].read_body do |fragment|
|
|
233
230
|
file.write(fragment)
|
|
234
231
|
new_process=progress.progress+fragment.length
|
|
@@ -239,7 +236,7 @@ module Aspera
|
|
|
239
236
|
# rename at the end
|
|
240
237
|
File.rename(target_file_tmp, target_file)
|
|
241
238
|
progress=nil
|
|
242
|
-
end
|
|
239
|
+
end # save_to_file
|
|
243
240
|
end
|
|
244
241
|
# sometimes there is a ITF8 char (e.g. (c) )
|
|
245
242
|
result[:http].body.force_encoding("UTF-8") if result[:http].body.is_a?(String)
|
|
@@ -267,10 +264,24 @@ module Aspera
|
|
|
267
264
|
end
|
|
268
265
|
Log.log.debug("using new token=#{call_data[:headers]['Authorization']}")
|
|
269
266
|
retry unless (oauth_tries -= 1).zero?
|
|
270
|
-
end # if
|
|
267
|
+
end # if oauth
|
|
268
|
+
# moved ?
|
|
269
|
+
if e.response.is_a?(Net::HTTPRedirection)
|
|
270
|
+
if tries_remain_redirect > 0
|
|
271
|
+
tries_remain_redirect-=1
|
|
272
|
+
Log.log.info("URL is moved: #{e.response['location']}")
|
|
273
|
+
raise e
|
|
274
|
+
# TODO: rebuild request with new location
|
|
275
|
+
#retry
|
|
276
|
+
else
|
|
277
|
+
raise "too many redirect"
|
|
278
|
+
end
|
|
279
|
+
else
|
|
280
|
+
raise e
|
|
281
|
+
end
|
|
271
282
|
# raise exception if could not retry and not return error in result
|
|
272
283
|
raise e unless call_data[:return_error]
|
|
273
|
-
end
|
|
284
|
+
end # begin request
|
|
274
285
|
Log.log.debug("result=#{result}")
|
|
275
286
|
return result
|
|
276
287
|
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Aspera
|
|
2
|
+
# Manage secrets in CLI using secure way (encryption, wallet, etc...)
|
|
3
|
+
class Secrets
|
|
4
|
+
attr_accessor :default_secret,:all_secrets
|
|
5
|
+
def initialize()
|
|
6
|
+
@default_secret=nil
|
|
7
|
+
@all_secrets={}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_secret(id=nil,mandatory=true)
|
|
11
|
+
secret=@default_secret || @all_secrets[id]
|
|
12
|
+
raise "please provide secret for #{id}" if secret.nil? and mandatory
|
|
13
|
+
return secret
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get_secrets
|
|
17
|
+
return @all_secrets
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -6,6 +6,11 @@ module Aspera
|
|
|
6
6
|
# create a temp file name for a given folder
|
|
7
7
|
# files can be deleted on process exit by calling cleanup
|
|
8
8
|
class TempFileManager
|
|
9
|
+
SEC_IN_DAY=86400
|
|
10
|
+
# assume no transfer last longer than this
|
|
11
|
+
# (garbage collect file list which were not deleted after transfer)
|
|
12
|
+
FILE_LIST_AGE_MAX_SEC=5*SEC_IN_DAY
|
|
13
|
+
private_constant :SEC_IN_DAY,:FILE_LIST_AGE_MAX_SEC
|
|
9
14
|
include Singleton
|
|
10
15
|
def initialize
|
|
11
16
|
@created_files=[]
|
|
@@ -33,5 +38,19 @@ module Aspera
|
|
|
33
38
|
username = Etc.getlogin || Etc.getpwuid(Process.uid).name || 'unknown_user' rescue 'unknown_user'
|
|
34
39
|
return new_file_path_in_folder(Etc.systmpdir,base_name+'_'+username+'_')
|
|
35
40
|
end
|
|
41
|
+
|
|
42
|
+
def cleanup_expired(temp_folder)
|
|
43
|
+
# garbage collect undeleted files
|
|
44
|
+
Dir.entries(temp_folder).each do |name|
|
|
45
|
+
file_path=File.join(temp_folder,name)
|
|
46
|
+
age_sec=(Time.now - File.stat(file_path).mtime).to_i
|
|
47
|
+
# check age of file, delete too old
|
|
48
|
+
if File.file?(file_path) and age_sec > FILE_LIST_AGE_MAX_SEC
|
|
49
|
+
Log.log.debug("garbage collecting #{name}")
|
|
50
|
+
File.delete(file_path)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
end
|
|
36
55
|
end
|
|
37
56
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: aspera-cli
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Laurent Martin
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-
|
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: xml-simple
|
|
@@ -58,28 +58,14 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '6.0'
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
69
|
-
- !ruby/object:Gem::Dependency
|
|
70
|
-
name: mimemagic
|
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
|
72
|
-
requirements:
|
|
73
|
-
- - "~>"
|
|
74
|
-
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0.3'
|
|
76
|
-
type: :runtime
|
|
77
|
-
prerelease: false
|
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
-
requirements:
|
|
80
|
-
- - "~>"
|
|
81
|
-
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0.3'
|
|
68
|
+
version: '6.0'
|
|
83
69
|
- !ruby/object:Gem::Dependency
|
|
84
70
|
name: execjs
|
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -136,6 +122,34 @@ dependencies:
|
|
|
136
122
|
- - "~>"
|
|
137
123
|
- !ruby/object:Gem::Version
|
|
138
124
|
version: '2.0'
|
|
125
|
+
- !ruby/object:Gem::Dependency
|
|
126
|
+
name: websocket
|
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - "~>"
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '1.2'
|
|
132
|
+
type: :runtime
|
|
133
|
+
prerelease: false
|
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
135
|
+
requirements:
|
|
136
|
+
- - "~>"
|
|
137
|
+
- !ruby/object:Gem::Version
|
|
138
|
+
version: '1.2'
|
|
139
|
+
- !ruby/object:Gem::Dependency
|
|
140
|
+
name: websocket-client-simple
|
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
|
142
|
+
requirements:
|
|
143
|
+
- - "~>"
|
|
144
|
+
- !ruby/object:Gem::Version
|
|
145
|
+
version: '0.3'
|
|
146
|
+
type: :runtime
|
|
147
|
+
prerelease: false
|
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
149
|
+
requirements:
|
|
150
|
+
- - "~>"
|
|
151
|
+
- !ruby/object:Gem::Version
|
|
152
|
+
version: '0.3'
|
|
139
153
|
- !ruby/object:Gem::Dependency
|
|
140
154
|
name: bundler
|
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -184,12 +198,14 @@ email:
|
|
|
184
198
|
executables:
|
|
185
199
|
- ascli
|
|
186
200
|
- asession
|
|
201
|
+
- dascli
|
|
187
202
|
extensions: []
|
|
188
203
|
extra_rdoc_files: []
|
|
189
204
|
files:
|
|
190
205
|
- README.md
|
|
191
206
|
- bin/ascli
|
|
192
207
|
- bin/asession
|
|
208
|
+
- bin/dascli
|
|
193
209
|
- docs/Makefile
|
|
194
210
|
- docs/README.erb.md
|
|
195
211
|
- docs/README.md
|
|
@@ -277,6 +293,7 @@ files:
|
|
|
277
293
|
- lib/aspera/rest_call_error.rb
|
|
278
294
|
- lib/aspera/rest_error_analyzer.rb
|
|
279
295
|
- lib/aspera/rest_errors_aspera.rb
|
|
296
|
+
- lib/aspera/secrets.rb
|
|
280
297
|
- lib/aspera/ssh.rb
|
|
281
298
|
- lib/aspera/sync.rb
|
|
282
299
|
- lib/aspera/temp_file_manager.rb
|
|
@@ -290,6 +307,7 @@ metadata:
|
|
|
290
307
|
source_code_uri: https://github.com/IBM/aspera-cli
|
|
291
308
|
changelog_uri: https://github.com/IBM/aspera-cli
|
|
292
309
|
rubygems_uri: https://rubygems.org/gems/aspera-cli
|
|
310
|
+
documentation_uri: https://www.rubydoc.info/gems/aspera-cli
|
|
293
311
|
post_install_message:
|
|
294
312
|
rdoc_options: []
|
|
295
313
|
require_paths:
|
|
@@ -301,12 +319,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
301
319
|
version: '2.4'
|
|
302
320
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
303
321
|
requirements:
|
|
304
|
-
- - "
|
|
322
|
+
- - ">="
|
|
305
323
|
- !ruby/object:Gem::Version
|
|
306
|
-
version:
|
|
324
|
+
version: '0'
|
|
307
325
|
requirements:
|
|
308
|
-
-
|
|
309
|
-
rubygems_version: 3.0.3
|
|
326
|
+
- Read the manual for any requirement
|
|
327
|
+
rubygems_version: 3.0.3.1
|
|
310
328
|
signing_key:
|
|
311
329
|
specification_version: 4
|
|
312
330
|
summary: 'Execute actions using command line on IBM Aspera Server products: Aspera
|