eco-helpers 1.1.3 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/eco/api/common/session/base_session.rb +13 -1
- data/lib/eco/api/common/session/environment.rb +21 -3
- data/lib/eco/api/session.rb +22 -12
- data/lib/eco/api/session/batch/feedback.rb +3 -3
- data/lib/eco/api/session/config/mailer.rb +6 -1
- data/lib/eco/api/session/config/s3_storage.rb +5 -0
- data/lib/eco/api/session/config/sftp.rb +6 -1
- data/lib/eco/api/session/config/workflow.rb +1 -1
- data/lib/eco/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d691b4d2eccce894adbff1cfa42b20adb8a24a06bbb7518e7367458f91fd7f96
|
4
|
+
data.tar.gz: 1fd8f054a63d1bd3204bbbc13dcebda52edee0160db37746ec4c50521b381970
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b5abae5d92712bcf46f0559221679d1bb47970aa24c902bb91edeee5f40b43a2e3eb209b2980bfe228cf3bd0a47d13c64b3d4bb4ed3dba51846ab31e653d135
|
7
|
+
data.tar.gz: dc0d66aefeb659f8ee7d64a0462c49df1d77667584d09257c64beadd57da5cba7e6c9712419d42651c0607fc606803d57e963e00925f8966109b6a0162d369dd
|
@@ -44,14 +44,26 @@ module Eco
|
|
44
44
|
enviro.mailer
|
45
45
|
end
|
46
46
|
|
47
|
+
def mailer?
|
48
|
+
enviro.mailer?
|
49
|
+
end
|
50
|
+
|
47
51
|
def sftp
|
48
52
|
enviro.sftp
|
49
53
|
end
|
50
|
-
|
54
|
+
|
55
|
+
def sftp?
|
56
|
+
enviro.sftp?
|
57
|
+
end
|
58
|
+
|
51
59
|
def s3uploader
|
52
60
|
enviro.s3uploader
|
53
61
|
end
|
54
62
|
|
63
|
+
def s3uploader?
|
64
|
+
enviro.s3uploader?
|
65
|
+
end
|
66
|
+
|
55
67
|
def logger
|
56
68
|
enviro.logger
|
57
69
|
end
|
@@ -28,15 +28,33 @@ module Eco
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def mailer
|
31
|
-
|
31
|
+
if mailer?
|
32
|
+
@mailer ||= Eco::API::Common::Session::Mailer.new(enviro: self)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def mailer?
|
37
|
+
config.mailer.configured?
|
32
38
|
end
|
33
39
|
|
34
40
|
def sftp
|
35
|
-
|
41
|
+
if sftp?
|
42
|
+
@sftp ||= Eco::API::Common::Session::SFTP.new(enviro: self)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def sftp?
|
47
|
+
config.sftp.configured?
|
36
48
|
end
|
37
49
|
|
38
50
|
def s3uploader
|
39
|
-
|
51
|
+
if s3uploader?
|
52
|
+
@s3uploader ||= Eco::API::Common::Session::S3Uploader.new(enviro: self)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def s3uploader?
|
57
|
+
config.s3storage.configured?
|
40
58
|
end
|
41
59
|
|
42
60
|
def api
|
data/lib/eco/api/session.rb
CHANGED
@@ -208,7 +208,12 @@ module Eco
|
|
208
208
|
# Sends an email
|
209
209
|
# @see Eco::API::Common::Session::Mailer#mail
|
210
210
|
def mail(**kargs)
|
211
|
-
mailer
|
211
|
+
if mailer?
|
212
|
+
mailer.mail(**kargs)
|
213
|
+
else
|
214
|
+
logger.error("You are trying to use the mailer, but it's not configured")
|
215
|
+
nil
|
216
|
+
end
|
212
217
|
end
|
213
218
|
|
214
219
|
# Uploads content into a file, a file or a directory to S3
|
@@ -222,19 +227,24 @@ module Eco
|
|
222
227
|
# @param link [Boolean] **return** _link(s)_ (`true`) or _path(s)_ (`false`: default)
|
223
228
|
# @return [String, Array<String>] either paths to S3 objects if `link` is `false`, or _link_ otherwise
|
224
229
|
def s3upload(content: nil, file: nil, directory: nil, recurse: false, link: false)
|
225
|
-
if
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
230
|
+
if s3uploader?
|
231
|
+
if content == :target
|
232
|
+
path = self.do.s3upload_targets
|
233
|
+
elsif content && file
|
234
|
+
path = s3uploader.upload(file, content)
|
235
|
+
elsif file
|
236
|
+
path = s3uploader.upload_file(file)
|
237
|
+
elsif directory
|
238
|
+
path = s3uploader.upload_directory(directory, recurse: recurse)
|
239
|
+
else
|
240
|
+
logger.error("To use Session.s3upload, you must specify either directory, file or content and file name")
|
241
|
+
end
|
242
|
+
return path unless link
|
243
|
+
s3uploader.link(path)
|
233
244
|
else
|
234
|
-
logger.error("
|
245
|
+
logger.error("You are trying to use S3 uploader, but it's not configured")
|
246
|
+
nil
|
235
247
|
end
|
236
|
-
return path unless link
|
237
|
-
s3uploader.link(path)
|
238
248
|
end
|
239
249
|
|
240
250
|
private
|
@@ -87,9 +87,9 @@ module Eco
|
|
87
87
|
requests ||= job.requests
|
88
88
|
[].tap do |msg|
|
89
89
|
if !requests || !requests.is_a?(Enumerable) || requests.empty?
|
90
|
-
msg << "#{"*" *
|
90
|
+
msg << "#{"*" * 10} Nothing for #{signature} so far :) #{"*" * 10}"
|
91
91
|
else
|
92
|
-
header = "#{"*"*
|
92
|
+
header = "#{"*"*10} #{signature} - Feedback Sample #{"*"*10}"
|
93
93
|
msg << header unless only_stats
|
94
94
|
unless only_stats
|
95
95
|
sample_length = 1
|
@@ -100,7 +100,7 @@ module Eco
|
|
100
100
|
end
|
101
101
|
msg << "#{sample.slice(0, sample_length).pretty_inspect}"
|
102
102
|
end
|
103
|
-
msg << "#{"+"*
|
103
|
+
msg << "#{"+"*3} #{type.to_s.upcase} length: #{requests.length} #{"+"*3} STATS (job '#{name}') #{"+"*3}"
|
104
104
|
msg << "#{request_stats(requests).message}"
|
105
105
|
msg << "*" * header.length unless only_stats
|
106
106
|
end
|
@@ -4,6 +4,11 @@ module Eco
|
|
4
4
|
class Config
|
5
5
|
class Mailer < BaseConfig
|
6
6
|
|
7
|
+
def configured?
|
8
|
+
required = access_key_id && secret_access_key && region
|
9
|
+
!!required
|
10
|
+
end
|
11
|
+
|
7
12
|
def to=(value)
|
8
13
|
self["to"] = value
|
9
14
|
end
|
@@ -11,7 +16,7 @@ module Eco
|
|
11
16
|
def to
|
12
17
|
self["to"]
|
13
18
|
end
|
14
|
-
|
19
|
+
|
15
20
|
def from=(value)
|
16
21
|
self["from"] = value
|
17
22
|
end
|
@@ -4,6 +4,11 @@ module Eco
|
|
4
4
|
class Config
|
5
5
|
class SFTP < BaseConfig
|
6
6
|
|
7
|
+
def configured?
|
8
|
+
required = host && user && key_file
|
9
|
+
!!required
|
10
|
+
end
|
11
|
+
|
7
12
|
def host=(value)
|
8
13
|
self["host"] = value
|
9
14
|
end
|
@@ -51,7 +56,7 @@ module Eco
|
|
51
56
|
def remote_folder
|
52
57
|
base_path + "/" + enviro_subpath
|
53
58
|
end
|
54
|
-
|
59
|
+
|
55
60
|
end
|
56
61
|
end
|
57
62
|
end
|
data/lib/eco/version.rb
CHANGED