mass-client 1.0.19 → 1.0.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/base-line/profile.rb +1 -1
- data/lib/base-line/source.rb +1 -1
- data/lib/first-line/profile_rpa.rb +63 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9aa67c61c00611402f922ed7988f67bba40ccaab9db879440512fa1b2288bc4
|
4
|
+
data.tar.gz: 21f416174b865c81f5122d2242aea75b55acaae7224d5bc1bc7bef13e64b1f19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdaca0893c886f465fbc617d4b301b5fca7552354bd4daf8d96731de5a4db7b9b0eb9a78500e1a842b21f6d3d6f64f8b12be963db44c0048d4c1f426ee0eed14
|
7
|
+
data.tar.gz: 9dc92ae9b578167df3835499c56bf44de27b94c78356f2972aacb8390f5600f5c5bcac0dbade36dc49e3105abe11653280cb9ba665dab861e7a4a4acd87501c9
|
data/lib/base-line/profile.rb
CHANGED
data/lib/base-line/source.rb
CHANGED
@@ -113,7 +113,7 @@ module Mass
|
|
113
113
|
|
114
114
|
# screenshot
|
115
115
|
l.logs 'Screenshot... '
|
116
|
-
job.desc['screenshots'] << job.profile.screenshot
|
116
|
+
job.desc['screenshots'] << job.profile.screenshot if job.profile.desc['allow_browser_to_download_multiple_files']
|
117
117
|
l.logf 'done'.green + " (#{job.desc['screenshots'].size.to_s.blue} total)"
|
118
118
|
end
|
119
119
|
end
|
@@ -101,7 +101,7 @@ module Mass
|
|
101
101
|
|
102
102
|
# stop the adspower server for headless mode, if it is not already stopped and if headless is activated.
|
103
103
|
def self.clear_driver
|
104
|
-
self.
|
104
|
+
self.buffer_driver = nil
|
105
105
|
end
|
106
106
|
|
107
107
|
# close all tabs except one
|
@@ -175,7 +175,23 @@ module Mass
|
|
175
175
|
automaticDownloads.find_element(:id => status.to_s).click()
|
176
176
|
end # def automatic_downloads
|
177
177
|
|
178
|
-
|
178
|
+
# Waits for the presence of a file in specified file paths within a given timeout period.
|
179
|
+
# This function checks each file path in the provided array and returns the path of the
|
180
|
+
# first file it finds to exist. It raises an exception if none of the files are found
|
181
|
+
# within the specified timeout.
|
182
|
+
#
|
183
|
+
# @param file_paths [Array<String>] An array of file paths to check for the file's existence.
|
184
|
+
# @param timeout [Integer] The maximum number of seconds to wait for the file to appear.
|
185
|
+
# Default is 30 seconds.
|
186
|
+
#
|
187
|
+
# @return [String] The path of the first file found in `file_paths`.
|
188
|
+
# @raise [RuntimeError] If no file is found within the specified timeout, raises an error with a message
|
189
|
+
# listing the paths that were checked and the timeout duration.
|
190
|
+
#
|
191
|
+
# @example
|
192
|
+
# wait_for_file(['/path/to/file1', '/path/to/file2'], timeout: 60)
|
193
|
+
# # => "/path/to/file1" (if the file appears within 60 seconds)
|
194
|
+
#
|
179
195
|
def wait_for_file(file_paths, timeout = 30)
|
180
196
|
Timeout.timeout(timeout) do
|
181
197
|
loop do
|
@@ -189,6 +205,45 @@ module Mass
|
|
189
205
|
raise "Downloaded file not found in paths #{file_paths.join(',')} after #{timeout} seconds."
|
190
206
|
end
|
191
207
|
|
208
|
+
|
209
|
+
# Retrieves the URL of a file stored in Dropbox with a timeout mechanism.
|
210
|
+
# This function continuously attempts to retrieve the file URL until it
|
211
|
+
# becomes available in Dropbox, up to a specified maximum wait time.
|
212
|
+
#
|
213
|
+
# @param path [String] The path to the file in Dropbox.
|
214
|
+
# @param max_wait [Integer] Maximum time to wait (in seconds) for the file to
|
215
|
+
# appear in Dropbox. Default is 30 seconds.
|
216
|
+
# @param interval [Integer] Time interval (in seconds) between each retry
|
217
|
+
# attempt. Default is 2 seconds.
|
218
|
+
#
|
219
|
+
# @return [String] The URL of the file in Dropbox, with the `&dl=1` parameter
|
220
|
+
# replaced by `&dl=0`.
|
221
|
+
# @raise [RuntimeError] If the file is not available within the specified
|
222
|
+
# maximum wait time, raises an error with a timeout message.
|
223
|
+
#
|
224
|
+
# @example
|
225
|
+
# wait_for_dropbox_url('/path/to/file', max_wait: 60, interval: 3)
|
226
|
+
# # => "https://www.dropbox.com/s/yourfile?dl=0"
|
227
|
+
#
|
228
|
+
def wait_for_dropbox_url(path, max_wait: 30, interval: 2)
|
229
|
+
start_time = Time.now
|
230
|
+
|
231
|
+
loop do
|
232
|
+
begin
|
233
|
+
# Try to get the file URL
|
234
|
+
return BlackStack::DropBox.get_file_url(path).gsub('&dl=1', '&dl=0')
|
235
|
+
rescue => e
|
236
|
+
# Check if the timeout has been exceeded
|
237
|
+
if Time.now - start_time > max_wait
|
238
|
+
raise "Timeout exceeded while waiting for file to appear in Dropbox: #{e.message}"
|
239
|
+
end
|
240
|
+
|
241
|
+
# Wait for a short interval before retrying
|
242
|
+
sleep(interval)
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
192
247
|
# download image from Selenium using JavaScript and upload to Dropbox
|
193
248
|
# return the URL of the screenshot
|
194
249
|
#
|
@@ -274,8 +329,12 @@ module Mass
|
|
274
329
|
BlackStack::DropBox.dropbox_upload_file(tmp_path, path)
|
275
330
|
# Delete the local file
|
276
331
|
File.delete(tmp_path)
|
332
|
+
|
277
333
|
# Return the URL of the file in Dropbox
|
278
|
-
|
334
|
+
#
|
335
|
+
# Add a timeout to wait the file is present in the cloud.
|
336
|
+
# Reference: https://github.com/MassProspecting/docs/issues/320
|
337
|
+
self.wait_for_dropbox_url(path).gsub('&dl=1', '&dl=0')
|
279
338
|
end
|
280
339
|
|
281
340
|
# download image from Selenium using JavaScript and upload to Dropbox
|
@@ -344,7 +403,7 @@ module Mass
|
|
344
403
|
|
345
404
|
self.class.buffer_driver = nil if !c.check(self.desc['ads_power_id'])
|
346
405
|
sleep(1)
|
347
|
-
|
406
|
+
|
348
407
|
if self.class.buffer_driver.nil?
|
349
408
|
self.class.buffer_driver = c.driver(self.desc['ads_power_id'], headless)
|
350
409
|
self.class.buffer_driver.manage.window.resize_to(self.desc['browser_width'], self.desc['browser_height'])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mass-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: timeout
|